Open code423n4 opened 2 years ago
@LilYeti: So here before it is sent to the stability pool, the rewards are redirected to the treasury. This is because it is difficult to keep track of rewards for all stability pool stakers for various JLP tokens that are generating the same JOE, for instance, so while they have the WJLP claimed, it no longer generates yield for them, and rewards are directed to the treasury instead. Due to that, it calls end treasury reward when removing from stability pool instead.
Downgraded to code clarity issue.
Handle
kenzo
Vulnerability details
When StabilityPool sends funds to depositor using
_sendGainsToDepositor
(which is called fromprovideToSP
orwithdrawFromSP
), the user's wrapped asset's rewards are not being updated.Impact
Incorrect yield accounting.
Proof of Concept
_sendGainsToDepositor
calls a wrapped asset'sunwrapFor
, but does not update the rewards for the depositor: (Code ref)This means that the user will continue to accrue rewards even though the asset is out of the system.
Recommended Mitigation Steps
Add a call to the wrapped asset's
claimRewardFor
before unwrapping, or call_userUpdate
in the beginning ofunwrapFor
to make sure the rewards are always up to date. This is whatwrap
does.