Submitted by 0xDjango
LiquidityPool.sol#L790-L792
The _updateUserFeesOnDeposit() function in LiquidityPool.sol is used to update a users withdrawal fees after an action such as deposit, transfer in, etc. The withdrawal fee decays toward a minimum withdrawal fee over a period of 1 or 2 weeks (discussed with developer). Since anyone can transfer lp tokens to any user, a griefer can transfer 1 wei of lp tokens to another user to reset their lastActionTimestamp used in the withdrawal fee calculation.
The developers nicely weight the updated withdrawal fee by taking the original balance/original fee vs the added balance/added fee. The attacker will only be able to extend the runway of the withdrawal fee cooldown by resetting the lastActionTimestamp for future calculations. Example below:
Assumptions:
Based on the formula to calculated User As new feeRatio:
In reality, User As withdrawal fee will only increase by a negligible amount since the shares added were very small in proportion to the original shares. We can assume user As current withdrawal fee is still 5%.
The issue is that the function then resets User As lastActionTimestamp to the current time. This means that User A will have to wait the maximum 2 weeks for the withdrawal fee to reduce from 5% to 0%. Effectively the cooldown runway is the same length as the original runway length, so the decay down to 0% will take twice as long.
meta.lastActionTimestamp = uint64(_getTime());
Instead of resetting lastActionTimestamp to the current time, scale it the same way the feeRatio is scaled. I understand that this would technically not be the timestamp of the last action, so the variable would probably need to be renamed.
chase-manning (Backd) confirmed and resolved
