20,000 USDC
View results
Submission Details
Severity: gas

[G-03] The update() function must be called before updateFor()

Summary

Since calling the updateFor function automatically calls the update function, it would be more gas-efficient to call update directly and then updateFor from the same function.

Impact

Gas Optimization and clearer code

Tools Used

Manual code review

Recommendations

Update the functions involved by first calling update then updateFor`. Like:

function deposit(uint _amount) external {
TKN.transferFrom(msg.sender, address(this), _amount);
+ update();
updateFor(msg.sender);
balances[msg.sender] += _amount;
}

and

function updateFor(address recipient) public {
- update();
uint256 _supplied = balances[recipient];
.....
....
...
..
.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.