The formula used to calculate the value change of LP tokens in the UpliftOnlyExample::onAfterRemoveLiquidity
function is incorrect, resulting in miscalculated fee amounts.
In the UpliftOnlyExample::onAfterRemoveLiquidity
function, the formula used for calculating the value change of LP token (localData.lpTokenDepositValueChange
) is flawed:
UpliftOnlyExample::onAfterRemoveLiquidity function:
The formula is lpTokenDepositValueChange = (lpTokenDepositValueNow - lpTokenDepositValue) / lpTokenDepositValue
This formula always returns 0 when lpTokenDepositValueNow - lpTokenDepositValue
is less than lpTokenDepositValue
. For example, if lpTokenDepositValueNow = 1999
and lpTokenDepositValue = 1000
, the calculation results in 0 ((1999 - 1000) / 1000 = 0).
This leads to lpTokenDepositValueChange
equaling 0 in cases where lpTokenDepositValueNow < 2 * lpTokenDepositValue
. Consequently, the feePerLP
is miscalculated, potentially causing the overall fee amount to be less than intended, resulting in financial loss.
The incorrect calculation of the fee amount may lead to financial discrepancies, causing a loss for the protocol.
Update the formula to ensure accurate calculation of lpTokenDepositValueChange
.
Likelihood: High, every call to the function (withdraw) Impact: Low/Medium, uplift fees will be applied only when the price of one asset is doubled but fixed fees will still be collected.
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.