Based on the documentation here: https://0x.org/docs/api#request-1, I expected the 0xApi to obtain the exact amount of buyToken
specified in the request, while applying the "slippageTolerance" to the sellAmount
.
However the api / router seems to buy overbuy the buyToken returning roughly (1+slippagePercentage)*buyAmount
instead of the actual specified amount.
Did I misunderstand the documentation or is this an error in the api / router ?
To reproduce you can run this test against a local mainnet fork : https://github.com/ckoopmann/0xApiExperiments/blob/main/test/index.ts
Which resulted in the following output for me (note that the api was queried for a fixed buyAmount
of 100 sushi tokens with 5% slippage and ended up buying slightly more than 105 tokens: