code-423n4 / 2024-07-basin-validation

0 stars 0 forks source link

precision loss due to division before multiplicaton #122

Closed c4-bot-7 closed 3 months ago

c4-bot-7 commented 3 months ago

Lines of code

https://github.com/code-423n4/2024-07-basin/blob/main/src/functions/Stable2.sol#L380

Vulnerability details

Impact

Detailed description of the impact of this finding. precision loss due to division before multiplication in getBandC.

Proof of Concept

Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept. function getBandC( uint256 Ann, uint256 lpTokenSupply, uint256 reserves ) private pure returns (uint256 c, uint256 b) { @> c = lpTokenSupply lpTokenSupply / (reserves N) lpTokenSupply A_PRECISION / (Ann N); b = reserves + (lpTokenSupply A_PRECISION / Ann); }

Tools Used

Recommended Mitigation Steps

Assessed type

Context

nevillehuang commented 3 months ago

Likely Invalid,

8 and #122 lack numerical proof/PoC of how precision loss will have protocol specific impact. Additionally, known issue [L-2] in automated the report.