Omniscia Euler Audit

EulStakes Code Style Findings

EulStakes Code Style Findings

ESS-01C: Potential Lookup Optimizations

Description:

The linked mapping lookup operations incur an extraneous keccak256 instruction gas cost as they are performed each time.

Example:

contracts/mining/EulStakes.sol
64uint newAmount = staked[beneficiary][underlying] + amount;
65
66staked[beneficiary][underlying] = newAmount;

Recommendation:

We advise the staked[msg.sender] & staked[beneficiary] lookups to be stored to a local mapping(address => uint) storage stakedPerUnderlying variable that is consequently utilized for both reading the value and writing to it in the linked statements, significantly optimizing the gas cost of the code blocks.

Alleviation:

The Euler team has noted the gas optimization achievable but they wish to avoid complicating the code at this stage.