chimera-defi / SharedDeposit

13 stars 6 forks source link

Panic error when redeem in wsgEth contract #23

Open devlancer412 opened 1 month ago

devlancer412 commented 1 month ago

When get some rewards, it is distributed by linear on next reward cycle. image

so totalAssets = storedTotalAssets + unlockedRewards

But when redeem storedTotalAssets -= redeemAmount image

If user withdraws all, amount > storedTotalAssets and so it makes panic error https://github.com/chimera-defi/SharedDeposit/blob/1fe4278ab14aac6d9365b102752c130b1256ebee/contracts/lib/xERC4626.sol#L64 https://github.com/chimera-defi/SharedDeposit/blob/1fe4278ab14aac6d9365b102752c130b1256ebee/contracts/lib/xERC4626.sol#L71

devlancer412 commented 1 month ago

@chimera-defi

chimera-defi commented 1 month ago

hmm thats strange. But good find, these are the edge cases we want to detect with the tests.

any ideas for an easy fix? ill spend some time reasoning through it, perhaps its as simple as accounting that there will always be some dust left over, and committing something like 0.001 E in, then running the tests. ? @devlancer412