Users can lose their LP tokens after several withdrawal requests before the first rebalance.
Summary
MainVault.withdrawalRequest can be called several times when rebalancingPeriod = 0 so users can lose their LP tokens when they request withdrawal several times.
Vulnerability Detail
MainVault.withdrawalRequest can be called several times when rebalancingPeriod = 0. withdrawalRequest validates user.withdrawalRequestPeriod = 0 first and then sets user.withdrawalRequestPeriod = rebalancingPeriod.
So when rebalancingPeriod > 0, withdrawalRequest can't be called multiple times. But when rebalancingPeriod = 0 before the first rebalance, withdrawalRequest can be called several times without reversion.
If a user request withdrawal several times by fault, the LP tokens are burned multiple times, but the user’s withdrawalAllowance will be only the last one. So the user can lose his LP tokens.
XKET
medium
Users can lose their LP tokens after several withdrawal requests before the first rebalance.
Summary
MainVault.withdrawalRequest
can be called several times whenrebalancingPeriod
= 0 so users can lose their LP tokens when they request withdrawal several times.Vulnerability Detail
MainVault.withdrawalRequest
can be called several times whenrebalancingPeriod
= 0.withdrawalRequest
validatesuser.withdrawalRequestPeriod
= 0 first and then setsuser.withdrawalRequestPeriod
=rebalancingPeriod
.So when
rebalancingPeriod
> 0,withdrawalRequest
can't be called multiple times. But whenrebalancingPeriod
= 0 before the first rebalance,withdrawalRequest
can be called several times without reversion.If a user request withdrawal several times by fault, the LP tokens are burned multiple times, but the user’s
withdrawalAllowance
will be only the last one. So the user can lose his LP tokens.Impact
The users can lose their LP tokens.
Code Snippet
https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/MainVault.sol#L149-L162
Tool used
Manual Review
Recommendation
Use another flag
withdrawalRequested
inUserInfo
struct to block multiple withdrawal request.Duplicate of #392