-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
G (Gas Optimization)bugSomething isn't workingSomething isn't workingduplicateThis issue or pull request already existsThis issue or pull request already existsfixed-in-upstream-repoThis task has been implemented in the upstream repoThis task has been implemented in the upstream reporesolvedsponsor confirmed
Description
Handle
hickuphh3
Vulnerability details
Impact
Market index is retrieved from storage twice in stakeFromUser(), withdraw() and withdrawAll(). Its value can be cached first before calling updateSystemState().
Recommended Mitigation Steps
function stakeFromUser(address from, uint256 amount) public virtual override onlyValidSynthetic((msg.sender)) {
uint32 marketIndex = marketIndexOfToken[msg.sender];
ILongShort(longShort).updateSystemState(marketIndex );
_stake(msg.sender, marketIndex, amount, from);
}
function withdraw(address token, uint256 amount) external {
uint32 marketIndex = marketIndexOfToken[token];
ILongShort(longShort).updateSystemState(marketIndex );
...
}
function withdrawAll(address token) external {
uint32 marketIndex = marketIndexOfToken[token];
ILongShort(longShort).updateSystemState(marketIndex );
...
}
Metadata
Metadata
Assignees
Labels
G (Gas Optimization)bugSomething isn't workingSomething isn't workingduplicateThis issue or pull request already existsThis issue or pull request already existsfixed-in-upstream-repoThis task has been implemented in the upstream repoThis task has been implemented in the upstream reporesolvedsponsor confirmed