code-423n4 / 2022-01-openleverage-findings

0 stars 0 forks source link

Gas in `LPool.initialize()`: `underlying_` should be used instead of `underlying` #187

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

Dravee

Vulnerability details

Impact

SLOADs are expensive (~100 gas) compared to MLOADs/MSTOREs (~3 gas). Minimizing them can save gas.

Proof of Concept

The code is as such (see @audit-info tags):

File: LPool.sol
82:         // Set underlying and sanity check it
83:         underlying = underlying_;
84:         IERC20(underlying).totalSupply(); //@audit-info use underlying_

At line 84, it should be : IERC20(underlying_).totalSupply();, effectively saving 97 gas (- 1 SLOAD + 1 MLOAD)

Tools Used

VS Code

Recommended Mitigation Steps

Use underlying_ instead of underlying

ColaM12 commented 2 years ago

Duplicate to #137

0xleastwood commented 2 years ago

This warden has made a large number of submissions pointing to basically the same area in different parts of the code. Because of how similar issues are, I don't think its fair to other wardens to have these treated as separate. While I understand gas reports should fix this, I've decided for this contest I'll mark similar duplicates as invalid.