You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Internal _withdraw, reading from storage twice. #26
Unfortunately this is still needed. _mintAccumulatedFloatAndExecuteOutstandingShifts(marketIndex, msg.sender); modifies the userAmountStaked[token][msg.sender], so you do need to read that value again.
Verdict: given the code this optimization introduces a bug. Final code indeed only reads userAmountStaked once, but that is due to other optimizations.
Activity
evertkors issue #26
JasoonS commentedon Aug 11, 2021
Unfortunately this is still needed. _
mintAccumulatedFloatAndExecuteOutstandingShifts(marketIndex, msg.sender);modifies theuserAmountStaked[token][msg.sender], so you do need to read that value again.See below image:

JasoonS commentedon Aug 13, 2021
Verdict: given the code this optimization introduces a bug. Final code indeed only reads
userAmountStakedonce, but that is due to other optimizations.JasoonS commentedon Aug 13, 2021
Not an exact duplicate of #25, #24 and #18 (different variable - but same optimization suggested -closing)
0xean commentedon Aug 25, 2021
I am not sure where the divergence in code is here but the line that was reference by the warden is
where the _mintAccumulatedFloat does not modify the userAmountStaked. Given this information, I am reopening the issue.