Elastic-Finance-DAO / eefi_contracts

0 stars 0 forks source link

[EVT-01C] Inefficient Event Emissions #101

Open stalker474 opened 3 weeks ago

stalker474 commented 3 weeks ago

EVT-01C: Inefficient Event Emissions

Type Severity Location
Gas Optimization ElasticVault.sol:L204, L215, L224, L233, L245, L256

Description:

The referenced event emissions are inefficient as they will read from storage variables when they have been recently assigned with in-memory data.

Example:

function setTraderRequest(ITrader _trader) external onlyOwner {
    require(address(_trader) != address(0), "ElasticVault: invalid trader");
    pending_trader = _trader;
    trader_change_request_time = block.timestamp;
    emit TraderChangeRequest(address(trader), address(pending_trader));
}

Recommendation:

We advise the in-memory variables to be utilized in those event emissions instead, greatly optimizing their gas cost.