0

Using the following query and conversion for bsc and eth respectively works:

https://bsc.api.0x.org/swap/v1/quote?buyToken=${contractAddress}&sellToken=WBNB&sellAmount=10000000000000000000

Price in dollars = bnb_price / data.price


https://api.0x.org/swap/v1/quote?buyToken=${contractAddress}&sellToken=WETH&sellAmount=10000000000000000000

Price in dollars = eth_price / data.price


Yet doing the same for the avalanche endpoint doesn't yield in the correct price:

https://avalanche.api.0x.org/swap/v1/quote?buyToken=${contractAddress}&sellToken=0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee&sellAmount=10000000000000000000

Price in dollars = avax_price / data.price (WRONG)

Note: 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee is the contract address for the native avalanche token.

1 Answer 1

1

0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee is the contract address for native tokens for the 0x API. In this case it is the address for $AVAX, not wrapped AVAX ($WAVAX) as per the sellToken values of your other requests. The prices may vary slightly if you input the native token address versus the address of its wrapped version.

Please note also that the price returned by the 0x API is not denominated in USD and may not match prices displayed on sites like CoinGecko.

Could you share an example API request to the Avalanche endpoint that returns an incorrect price?

Your Answer

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

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