Open code423n4 opened 2 years ago
The warden identified a logical fallacy that would prevent the code from providing liquidity.
This is because the code is only accounting for one token, ignoring the other token's amount.
Given the information I have I agree with validity and severity of the finding, mitigation could be achieved by following the warden advice or by also using the balance of the pool3
token to calculate the LP amounts
Lines of code
https://github.com/code-423n4/2022-02-concur/blob/main/contracts/USDMPegRecovery.sol#L73-L82
Vulnerability details
Impact
The
provide
function does not take a_steps
argument and will instead calculateaddingLiquidity
by truncating amounts understep
. As a result, if there is an excess ofusdm
such that the truncated amount exceeds the contract'spool3
truncated balance, then the function will revert due to insufficientpool3
collateral.This will prevent guardians from effectively providing liquidity whenever tokens are available. Consider the following example:
500000e18
usdm
tokens and250000e18
pool3
tokens.addingLiquidity
will be calculated as500000e18 / 250000e18 * 250000e18
.500000e18
usdm
andpool3
tokens in which there are insufficientpool3
tokens in the contract. As a result, it will revert even though there is an abundance of tokens that satisfy thestep
amount.Proof of Concept
https://github.com/code-423n4/2022-02-concur/blob/main/contracts/USDMPegRecovery.sol#L73-L82
Tools Used
Manual code review. Discussions with Taek.
Recommended Mitigation Steps
Consider modifying the
provide
function such that a_steps
argument can be supplied. This will allow guardians to maximise the amount of liquidity provided to the Curve pool.