Position is not updated when fees are collected #254
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
insufficient quality report
This report is not of sufficient quality
🤖_03_group
AI based duplicate group recommendation
Lines of code
https://github.com/code-423n4/2024-08-superposition/blob/main/pkg/seawater/src/position.rs#L43-L93
https://github.com/code-423n4/2024-08-superposition/blob/main/pkg/seawater/src/lib.rs#L688-L727
Vulnerability details
Impact
When fees for LP positions are being collected they are not being updated and owners should either increase or decrease them in order to get their latest fee accrued.
Proof of Concept
LP position fees (
token_owed_0
andtoken_owed_1
) are being updated only whenlib::update_position_internal
is being called:lib.rs
And only
update_position_internal
function callsposition::update
. That means owners can’t just collect their fees but they always have modify their position, either by adding or removing liquidity in order to have their position updated:position.rs
Owners can’t just call
lib::collect_single_to_6_D_76575_F
andlib::collect_7_F21947_C
because they only process the transfers and doesn’t update the position:lib.rs
Basically,
collect_7_F21947_C
will become ineffective due to the fact that the owner should update all the IDs manually. The bigger impact will be when a position is entirely closed, unsuspecting users will lose all the fees because they won’t be accrued when collect is executed along with a decrease and then burn position, which leaves any liquidity or fees left in the position inaccessible.For reference, let’s check how collect is implemented in
UniswapV3
:NFPM.sol
Only the relevant:
Superposition
.tokensOwed0
andtokensOwed1
, which are the fees for that position, is increased representing the latest fee for that position, this is also missing here, it’s only done inupdate_position_internal
Tools Used
Manual Review
Recommended Mitigation Steps
Call
update_position_internal
with 0 in order to perform taken the latest fee per position and avoid losing them.Assessed type
Uniswap
The text was updated successfully, but these errors were encountered: