There is a lack of slippage protection in compound()
when swapping tokens.
Let's take a look at this part of the code in the compound()
function:
We're passing amountOut = 0
to swapExactTokensForTokens
where we swap an exact amount of tokenIn for as many possible amount of tokenOut.
So amountOut
is the minimum amount of tokenOut that we're ready to receive. There is a comment saying that amount out minimum is calculated in the Swap but that is not actually present.
The way it is currently implemented it's possible to receive 0 tokenOut if there's a lack of liquidity or bad market conditions.
swapExactTokensForTokens in GMXManager just passes the call to GMXWorker:
And GMXWorker just passes the call to the swapRouter:
In bad market conditions, swaps could be performed at a very bad rate and funds will be lost.
Manual review
Calculate how much tokenOut minimum is sensible to receive and pass that as a parameter.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.