fee_growth_inside calculations doesnt allow oveflow/underflow #118
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-46
🤖_54_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
upgraded by judge
Original issue severity upgraded from QA/Gas by judge
Lines of code
https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/seawater/src/tick.rs#L163
Vulnerability details
Impact
The get_fee_growth_inside function uses checked_sub to prevent overflow and underflow in fee growth calculations. However, the original Uniswap V3 contract relies on underflow/overflow as part of its fee growth logic. Since fee growth inside a tick range can be both positive and negative, using checked_sub may cause certain users to be unable to update their positions, leading to transaction reverts.
Proof of Concept
get_fee_growth_inside()
implements UniswapV3 math to calculate fee growth.In this function, the use of checked_sub prevents underflow, which can cause the function to revert with an Error::FeeGrowthSubTick. This behavior is different from the Uniswap V3 implementation, where underflows are allowed and expected in certain scenarios.
Tools Used
Manual
Recommended Mitigation Steps
Modify the get_fee_growth_inside function to allow underflow/overflow by removing the checked_sub checks. This will ensure compatibility with the original Uniswap V3 logic and prevent unexpected transaction reverts for users.
Assessed type
Under/Overflow
The text was updated successfully, but these errors were encountered: