0

I'm trying to test the 0x quote API, ran into an issue with the Goerli endpoint.

I sent a quote request to mainnet, to sell WETH and buy USDC: https://api.0x.org/swap/v1/quote?buyToken=USDC&sellToken=WETH&sellAmount=100000000000000000

There is no issue, I received the correct response:

{"chainId":1,"price":"1323.97485","guaranteedPrice":"1310.7351","estimatedPriceImpact":"0","to":"0xdef1c0ded9bec7f1a1670819833240f027b25eff","data":"0x6af479b20000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000000000007d005e60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002bc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000869584cd000000000000000000000000100000000000000000000000000000000000001100000000000000000000000000000000000000000000007ec526fe6c63bc2562","value":"0","gas":"125195","estimatedGas":"125195","gasPrice":"18500000000","protocolFee":"0","minimumProtocolFee":"0","buyTokenAddress":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","sellTokenAddress":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","buyAmount":"132397485","sellAmount":"100000000000000000","sources":[{"name":"0x","proportion":"0"},{"name":"Uniswap","proportion":"0"},{"name":"Uniswap_V2","proportion":"0"},{"name":"Curve","proportion":"0"},{"name":"Balancer","proportion":"0"},{"name":"Balancer_V2","proportion":"0"},{"name":"Bancor","proportion":"0"},{"name":"BancorV3","proportion":"0"},{"name":"mStable","proportion":"0"},{"name":"SushiSwap","proportion":"0"},{"name":"Shell","proportion":"0"},{"name":"DODO","proportion":"0"},{"name":"DODO_V2","proportion":"0"},{"name":"CryptoCom","proportion":"0"},{"name":"Lido","proportion":"0"},{"name":"MakerPsm","proportion":"0"},{"name":"KyberDMM","proportion":"0"},{"name":"Component","proportion":"0"},{"name":"Saddle","proportion":"0"},{"name":"Uniswap_V3","proportion":"1"},{"name":"Curve_V2","proportion":"0"},{"name":"ShibaSwap","proportion":"0"},{"name":"Synapse","proportion":"0"},{"name":"Synthetix","proportion":"0"},{"name":"Aave_V2","proportion":"0"},{"name":"Compound","proportion":"0"}],"orders":[{"type":0,"source":"Uniswap_V3","makerToken":"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","takerToken":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","makerAmount":"132397485","takerAmount":"100000000000000000","fillData":{"router":"0xe592427a0aece92de3edee1f18e0157c05861564","tokenAddressPath":["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"],"uniswapPath":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48","gasUsed":65195},"fill":{"input":"100000000000000000","output":"132397485","adjustedOutput":"129967849","gas":99195}}],"allowanceTarget":"0xdef1c0ded9bec7f1a1670819833240f027b25eff","decodedUniqueId":"7ec526fe6c-1673274722","sellTokenToEthRate":"1","buyTokenToEthRate":"1323.97485","expectedSlippage":"-0.001112727338236046"}

I then sent the exact same request to the Goerli endpoint: https://goerli.api.0x.org/swap/v1/quote?buyToken=USDC&sellToken=WETH&sellAmount=100000000000000000

It returned me the following error message:

{'code': 100, 'reason': 'Validation Failed', 'validationErrors': [{'field': 'buyToken', 'code': 1000, 'reason': 'buyToken and sellToken must be different'}, {'field': 'sellToken', 'code': 1000, 'reason': 'buyToken and sellToken must be different'}]}

Any idea what caused the issue here? Thanks for your time!

1 Answer 1

1

As of Jan 10, 2023, there is no token symbol support on Goerli, and limited token symbol support on Mainnet. The request works on Mainnet but fails on Goerli for this reason

For Goerli, you will need to use token addresses instead of token symbols. For example:

https://goerli.api.0x.org/swap/v1/quote?buyToken=0x07865c6e87b9f70255377e024ace6630c1eaa37f&sellToken=0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6&sellAmount=100000000000000000
1
  • It works now, thanks!
    – Stevey
    Jan 11, 2023 at 1:30

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.