Stream.withdraw amount subtraction can be unchecked #69
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
G (Gas Optimization)
Handle
hyh
Vulnerability details
Impact
Gas is overspent on check (compiler is 0.8.0). As withdraw is a core user facing function even small optimizations are recommended.
Proof of Concept
withdraw function:
https://github.com/code-423n4/2021-11-streaming/blob/main/Streaming/src/Locke.sol#L455
Also, depositTokenAmount variable always changes along with ts.tokens one, with the only difference that ts.tokens can be reduced by updateStreamInternal logic:
https://github.com/code-423n4/2021-11-streaming/blob/main/Streaming/src/Locke.sol#L229
Recommended Mitigation Steps
This way depositTokenAmount is always not less than ts.tokens and can be decreased unchecked.
Now:
To be:
The text was updated successfully, but these errors were encountered: