Closed lumtis closed 7 months ago
Looks like getAmountIn()
returns
Returns the minimum input asset amount required to buy the given output asset amount (accounting for fees) given reserves.
Note the "minimum".
It might not be possible to get exact output amount, as we are using Uniswap v2
SwapExactTokensForTokens()
. To get exact output we might need to use
SwapTokensForExactTokens()
instead.
Looks no longer relevant
When using Uniswap to obtain gas for payment, it appears there can be small differences between the amount expected and obtained:
The amount we swap out from the
GetAmountIn
call in Uniswap contract doesn't exactly match the value we provide to theGetAmountIn
function.We should investigate the cause of these small mismatches. It can be caused by low liquidity if
GetAmountIn
doesn't account the slippage during swapsIf we find the cause of it and it can be fixed so the amounts always exactly match, we should introduce the checks and return errors during mismatch.