v2-sdk
v2-sdk copied to clipboard
Providing low input amount raises an error that's never returned
As a developer testing out the uniswap SDK, when an error is raised because the input amount I provided is too low, instead of returning that and surfacing it up to me. The SDK just swallows it and silently carries before another part of my code blows up.
Why do we do that?
https://github.com/Uniswap/uniswap-v2-sdk/blob/main/src/entities/trade.ts#L266
Pair.getOutputAmount
can throw the InsufficientInputAmount
error when a swap would result in 0 output, the involvesToken
invariant, as well as the InsufficientReservesError
are already checked before that. In all cases it makes sense to consider this Pair as invalid and continue with the loop. If all pairs are invalid, the result of the recursive function will just be an empty Array.