Closed sherlock-admin closed 5 months ago
shaka
medium
StableModule.executeWithdraw
StableModule.executeWithdraw reverts when the stable collateral per share is lower than 1e6.
StableModule.executeWithdraw has a check to prevent significant impact on stable token price during withdrawal.
The problem is that when the stable collateral per share is lower than 1e6, the check will provoke a revert due to an underflow error.
Stable token holder will not be able to withdraw their funds when the stable collateral per share is lower than 1e6.
https://github.com/sherlock-audit/2023-12-flatmoney/blob/main/flatcoin-v1/src/StableModule.sol#L122
Manual Review
File: StableModule.sol if (totalSupply() > 0) { if ( stableCollateralPerShareAfter < stableCollateralPerShareBefore - 1e6 || + (stableCollateralPerShareBefore >= 1e6 && stableCollateralPerShareAfter < stableCollateralPerShareBefore - 1e6) || stableCollateralPerShareAfter > stableCollateralPerShareBefore + 1e6 ) revert FlatcoinErrors.PriceImpactDuringWithdraw();
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid
Invalid, stableCollateralPerShare will have a minimum value of 1e18 as seen here
stableCollateralPerShare
shaka
medium
StableModule.executeWithdraw
reverts when the stable collateral per share is lower than 1e6Summary
StableModule.executeWithdraw
reverts when the stable collateral per share is lower than 1e6.Vulnerability Detail
StableModule.executeWithdraw
has a check to prevent significant impact on stable token price during withdrawal.The problem is that when the stable collateral per share is lower than 1e6, the check will provoke a revert due to an underflow error.
Impact
Stable token holder will not be able to withdraw their funds when the stable collateral per share is lower than 1e6.
Code Snippet
https://github.com/sherlock-audit/2023-12-flatmoney/blob/main/flatcoin-v1/src/StableModule.sol#L122
Tool used
Manual Review
Recommendation