0

Recently, I try to swap token with 0x on Optimism network.

But some transactions were fail. At first, I thought it was due to insufficient estimatedGas. But it not work when I set a larger number.

I've traded 0x with both Matic and AVAX and they haven't had any problem.

Is there anything I might not have noticed?


I use /swap/v1/price? to get the price, like : https://optimism.api.0x.org/swap/v1/price?sellToken=0x68f180fcCe6836688e9084f035309E29Bf0A2095&buyToken=0x7F5c764cBc14f9669B88837ca1490cCa17c31607&sellAmount=10000000

and then use swap/v1/quote? to get the data and send the transactions. like :https://optimism.api.0x.org/swap/v1/quote?buyToken=0x68f180fcCe6836688e9084f035309E29Bf0A2095&sellToken=0x7F5c764cBc14f9669B88837ca1490cCa17c31607&sellAmount=3000000000&slippagePercentage=0.01

1 Answer 1

0

Ensure you have the allowance set correctly and are sending to the correct contract, on Optimism the address is different. It's returned in the to field and you can confirm in the protocol docs and also in the contract-addresses package.

After that try setting the takerAddress parameter with your address, this will run additional validation and provide a more accurate gas estimate.

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.