You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: Description
The get_virtual_price() function in the StableSwapTwoPool.sol and StableSwapThreePool.solcontract calculates the virtual price of the pool's LP token using a precision of 1e18. This approach does not account for the actual decimals of the LP token, which leads to incorrect virtual price calculations.
function get_virtual_price() externalviewreturns (uint256) {
uint256 D =get_D(_xp(), get_A());
uint256 token_supply = token.totalSupply();
return (D * PRECISION) / token_supply; //@audit-incorrect precision,it should be D*token.decimals/token_supply
}
Attack Scenario
Lets understand issue with example:
The invariant D is calculated as 1e18(as get_D returns scaled value i.e 1e18).
Github username: --
Twitter username: --
Submission hash (on-chain): 0x994d521d911f2bd3bbc2b43c699b07b5427851838d5c5969f39690e96d595615
Severity: high
Description:
Description
The
get_virtual_price()
function in theStableSwapTwoPool.sol
andStableSwapThreePool.sol
contract calculates the virtual price of the pool's LP token using aprecision
of1e18
. This approach does not account for the actual decimals of theLP
token, which leads to incorrect virtual price calculations.Attack Scenario
Lets understand issue with example:
1e18
(as get_D returns scaled value i.e 1e18).Current Calculation:(INCORRECT)
Expected Calculation with Correct Decimals:
As we can see here the current implementation returns incorrect virtual price
Attachments
The text was updated successfully, but these errors were encountered: