0

Tried 0x swap quote API GET /swap/v1/quote to sell the SHIBA INU tokens but it is not working. Although working for other tokens like USDT, DAI, etc.

Query params I used:

  1. With symbol https://api.0x.org/swap/v1/quote?buyToken=ETH&sellToken=SHIB&sellAmount=85

    Getting this:

    {
    "code": 100,
    "reason": "Validation Failed",
    "validationErrors": [
        {
            "field": "sellToken",
            "code": 1004,
            "reason": "Could not find token `SHIB`"
        }
    ]
    }
    
  2. With token address https://api.0x.org/swap/v1/quote?buyToken=ETH&sellToken=0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE&sellAmount=85

    Getting this:

    {
    "code": 100,
    "reason": "Validation Failed",
    "validationErrors": [
        {
            "field": "sellAmount",
            "code": 1004,
            "reason": "INSUFFICIENT_ASSET_LIQUIDITY"
        }
    ]
    }
    

Also, tried swapping on Uniswap and it is showing a possible exchange. So, feel like something is wrong with 0x API because as per the doc, 0x considers all DEXs to find the best quote. enter image description here

2 Answers 2

0

Your sell amount is to low to the algorithm calculate a quote. Please note the sell amount is in base units as explained on the docs: https://docs.0x.org/0x-api-swap/api-references/get-swap-v1-quote, SHIB is a token with 18 decimals so your quote for 85 SHIB should be with amount 85 000 000 000 000 000 000 resulting in an API call of

https://api.0x.org/swap/v1/quote?buyToken=ETH&sellToken=0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE&sellAmount=85000000000000000000

As you can see, now the API is able to generate a quote for that pair.

3
  • oh yeah, I am actually scalling the amount in my code but forgot to do it while trying with postman and shared it here. Nice catch and it worked with sellToken Address but still giving above error with sellToken symbol. Do you know why it is not working when symbol 'SHIB' is used instead of shiba inu address as my code uses symbol and not address. Aug 18, 2022 at 4:50
  • Symbols are not supported for majority of tokens, I believe only ETH symbol works on this, so you need mandatory set the contract address. Aug 22, 2022 at 12:12
  • Sure pal, thanks. I switched to addresses. Aug 22, 2022 at 18:33
0

I don't have enough reputation to comment, hence an answer.

I would strongly recommend switching to addresses in your app.

In general using token Symbols or Names is not a good practice, because it is trivial to create another token with the same data.

And when there are more than one, someone has to decide which one is the "correct" one, that could lead to errors, manipulation or the list being out of date.

The native token are an exception, as they (usually) do not have an address

Native token such as "ETH" can be provided as a valid sellToken

https://docs.0x.org/0x-api-swap/api-references/get-swap-v1-quote

1
  • Yeah, I switched to address as it makes more sense as it is something that uniquely defines the tokens rather than the name/symbol. Still, I will wait for the 0x team's response as I think they should either stop supporting Symbol as query values or give more insight into why their service is unable to find the SHIB token(there could be others as well). Curious to know this. Aug 22, 2022 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.