Open hats-bug-reporter[bot] opened 1 year ago
Issue looks similar to https://github.com/hats-finance/StakeWise-0xd91cd6ed6c9a112fdc112b1a3c66e47697f522cd/issues/96
Please check _osToken.burnShares()
it does state update, so in _unclaimedAssets()
timeElapsed will be 0 and statement if (timeElapsed == 0) return 0;
will be executed
Github username: @evokid Submission hash (on-chain): 0xd5b0fe1a050e72ec33ebdfda4236d9a277a8fe22bb06db1c690c698db4d9c308 Severity: high
Description: Description
Treasury fee is less than it should be in burnOsToken() function, if you look at it you will see that
_osToken.burnShares()
being called first then_syncPositionFee()
.The proof is simple, on _osToken.burnShares() _totalAssets are being decreased which will affect the fee of the position definitely since profitAccrued in cumulativeFeePerShare() is returning the
_unclaimedAssets()
.Attack Scenario
burnOsToken()
Attachments
If you check burnShares() you will see _totalAssets is being decreased L153:
Now the effect is here because _totalAssets is a factor to calculate
cumulativeFeePerShare()
which calls _unclaimedAssets() L336We can see from the code above, when _totalAssets decreases, the returned value will be decreased too.
As Result on
_syncPositionFee()
profitAccrued will be decreased, Therefore treasury assets will decreased.Recommendations:
_syncPositionFee()
should be called before_osToken.burnShares()
.