code-423n4 / 2022-05-cally-findings

2 stars 0 forks source link

Gas Optimizations #295

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Gas

Set isExercised directly in exercise

Setting the single attribute isExercised directly in exercise is cheaper than storing the full vault struct.

Current:

Cally.sol#277

        // mark the vault as exercised
        vault.isExercised = true;
        _vaults[vaultId] = vault;

Gas usage: 49631 avg, 65473 median, 87933 max

Optimized:

        // mark the vault as exercised
        _vaults[vaultId].isExercised = true;

Gas usage: 48858 avg, 64413 median, 86873 max