sakshamguruji - Not The Entire Token Amounts Provided To AMM Might Get Consumed Leading To Incorrect Accounting Of LV Tokens #171
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Escalation Resolved
This issue's escalations have been approved/rejected
Medium
A Medium severity issue.
Reward
A payout will be made for this issue
sakshamguruji
Medium
Not The Entire Token Amounts Provided To AMM Might Get Consumed Leading To Incorrect Accounting Of LV Tokens
Summary
When RA is deposited into the Vault then a part of that RA is used to to mint CT (and DS) and then RA + CT are added as liquidity in the AMM , this is done by first calculating the ratio and then providing assets in that ratio , but it is possible that assets are not provided in the exact ratio which means not all of the assets will be used by UniV2 to be added as liquidity , therefore there will be some left out assets . But these left out assets are not accounted.
Vulnerability Detail
1.) When RA is deposited in the vault , liquidity is added to the AMM in the calculated ratio ->
https://github.com/sherlock-audit/2024-08-cork-protocol/blob/main/Depeg-swap/contracts/libraries/VaultLib.sol#L204
And inside
calculateProvideLiquidityAmountBasedOnCtPrice
->Therefore if
amountRa
= 33333333333333333333 and ratio was 50e18 , there will be some rounding in the calculated amounts of CT and RA , also the (+ 1e18) in the denominator can will cause some results which will be not necessarily follow the ratio(that's because we must convert the RA to CT, imagine if it would be 50 RA 50 CT but we only had 50 RA, and it's costs us 50 RA to make 50 CT in the PSM. so that's why we add 1 to the equation)2.) Therefore when adding liquidity to the AMM ->
https://github.com/sherlock-audit/2024-08-cork-protocol/blob/main/Depeg-swap/contracts/libraries/VaultLib.sol#L74
Due to above mentioned reasons there will be some unutilised amount of RA/CT since the amounts were not provided in the actual ratio , and by time these amounts will grow larger .
https://github.com/sherlock-audit/2024-08-cork-protocol/blob/main/Depeg-swap/contracts/libraries/VaultLib.sol#L205
The amount of LV minted is the amount of tokens provided to AMM but as discussed not all of the token amounts will be added as liquidity therefore the LV minted will always be a bit higher.
Impact
Not The Entire Token Amounts Provided To AMM Might Get Consumed Leading To Incorrect Accounting Of Ra/Ct and LV Tokens
Code Snippet
https://github.com/sherlock-audit/2024-08-cork-protocol/blob/main/Depeg-swap/contracts/libraries/VaultLib.sol#L74
Tool used
Manual Review
Recommendation
Only account for the tokens actually added as liquidity in the AMM.
Duplicate of #240
The text was updated successfully, but these errors were encountered: