Incorrect calculation of minMarketTokenAmt
in the function deposit can cause loss of funds when depositing liquidity to GMX.since it calculate it based on the deposited value from the user not the actual value to be deposited.
when a user make a deposit to the strategyVault
, the function deposit get called which do the following :
get the token from the user .
get the value of the deposited token from the oracle in terms of usd
.
calculate how many additional tokens needed to borrow , then borrow them
calculate the minAmountOut. and then create a deposit on gmx.
the calculation of the minMarketTokenAmt
in this function is incorrect. Since it gets calculated based on the value of the deposited tokens from the user.while the actual value to be deposited is : userDepositedValue + borrowedValue
. we can see that here :
and here how it get calculated in calcMinMarketSlippageAmt
function :
in this case the minMarketTokenAmt
will be way less then what it should be. EX :
in 3x delta strategy . a user deposited : 100usd
value , the contract borrowed more 200usd
(in terms of longToken).
assume the lp
value is 2usd
.and slippage is 1%
.
the contract will calculate minMarketTokenAmt
amount like : 100 / 2 * (100-1) / 100 = 49.5
but the actual minMarketTokenAmt
amount should be : 300 / 2 * (100-1) / 100 = 148.5
incorrect minMarketTokenAmc
can cause lose of funds .
manual review
vs code
calculate the minMarketTokenAmt
based on the actual value deposited :
depositValue = borrowed + userDeposit .
Impact: High Likelihood: High Logic error in the core functionality that can cause loss of user funds.
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.