Getting amountsOut with uniSwapLikeRouter.getAmountsOut() before calling uniSwapLikeRouter.swapExactTokensForTokens() and set minAmountOut as amountsOut[amountsOut.length - 1] is unnecessary as it will always met minAmountOut, use 0 for minAmountOut instead can save gas.
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-12-amun/blob/98f6e2ff91f5fcebc0489f5871183566feaec307/contracts/basket/contracts/singleJoinExit/SingleTokenJoin.sol#L91-L98
Getting
amountsOut
withuniSwapLikeRouter.getAmountsOut()
before callinguniSwapLikeRouter.swapExactTokensForTokens()
and setminAmountOut
asamountsOut[amountsOut.length - 1]
is unnecessary as it will always metminAmountOut
, use0
forminAmountOut
instead can save gas.Recommendation
Change to: