0

I'm learning how to work with 0x quotes and I still couldn't make a successful request.

Here is what I'm trying to send

https://api.0x.org/swap/v1/quote?buyToken=DAI&sellToken=WETH&sellAmount=1000000000000000000&takerAddress=0xab5801a7d398351b8be11c439e05c5b3259aec9b

Which fails with

{"code":111,"reason":"Gas estimation failed"}

Note that if I replace WETH with ETH OR remove takerAddress this quotes executes fine. Unfortunately I actually want to exchange with for dai with specified takes address.

What am I doing wrong? How do I do this?

P.S. I managed to get this working via skipValidation=true argument added to the query but I'm not sure if it's a good idea to do so

1 Answer 1

0

When a takerAddress is present in a request to the 0x API, the entire transaction is validated. If the validation fails, the reason why this transaction would revert is returned with the request response.

In this case, the taker address (the address that fills the quote) does not have any WETH balance, so attempting to swap WETH for DAI from this address would fail. There is a sufficient balance of ETH to complete the requested swap, however, which is why no errors are returned when you replace sellToken=WETH with sellToken=ETH.

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.