0xNirix - Reserve Ratio Can Become Zero Through Reward Operations #29
Labels
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
0xNirix
Medium
Reserve Ratio Can Become Zero Through Reward Operations
Summary
Mathematical operations in updateRatioForReward function can cause the reserve ratio to become zero when processing large rewards, leading to a denial of service in the exchange as division by zero occurs in subsequent Bancor formula calculations.
Root Cause
In https://github.com/sherlock-audit/2024-10-mento-update/blob/main/mento-core/contracts/goodDollar/GoodDollarExchangeProvider.sol#L206, the mathematical formula for calculating new reserve ratio can result in zero:
The core issue lies in the mathematical relationship:
newRatio = reserveBalance / ((tokenSupply + reward) * currentPrice)
When reward is significantly larger than tokenSupply, the denominator grows so large that the division result becomes less than 1e-10, which truncates to zero in the final conversion.
In contrast, this situation is avoided in other scenarios like
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
Initial Exchange State
Ratio calculation in updateRatioForReward:
Impact
When ratio becomes zero:
PoC
No response
Mitigation
No response
The text was updated successfully, but these errors were encountered: