0

I'm running into some issues trying to swap when specifying buyAmount. Specifically, I'd like to set my allowance to exactly sellAmount returned by the API before doing a swap, but I'm getting "ERC20: transfer amount exceeds allowance" errors, suggesting that 0x is swapping more than the sellAmount returned from the API.

Is the sellAmount an actual maximum that I can use for allowance setting, or am I unable to depend on it?

1 Answer 1

1

Sell amount is an estimation from the current market conditions which could vary to higher depending on slippage tolerance. You can consider the max allowance the sell amount plus the slippage tolerance that you set in your quote.

1
  • Got it, and the sellAmount already includes any portion used to pay the buyTokenPercentageFee, correct?
    – Kevin Ji
    Jul 7, 2022 at 23:28

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.