Cache external call result in the stack can save gas #62
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
WatchPug
Vulnerability details
For the result of an external call being written into a storage variable, cache and read from the stack rather than read from the storage variable can save gas.
Instances include:
IERC20Like(collateralAsset).decimals()
inDebtLocker.sol#getExpectedAmount()
can be cached to avoid an extra external call.https://github.com/maple-labs/debt-locker/blob/81f55907db7b23d27e839b9f9f73282184ed4744/contracts/DebtLocker.sol#L237-L253
Recommendation
Change to:
The text was updated successfully, but these errors were encountered: