code-423n4 / 2021-12-yetifinance-findings

0 stars 0 forks source link

GAS: packing structs saves gas #224

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

Ruhum

Vulnerability details

Impact

Structs should always be packed to save gas

Proof of Concept

Tools Used

none

Recommended Mitigation Steps

Pack structs, e.g.:

// unpacked, higher gas (6 storage slots):
    struct CollateralParams {
        uint256 ratio;
        address oracle;
        uint256 decimals;
        bool active;
        address priceCurve;
        uint256 index;
        bool isWrapped;
    }

// packed (needs 5 storage slots)
    struct CollateralParams {
        uint256 ratio;
        uint256 decimals;
        uint256 index;
        address oracle;
        bool active;
        address priceCurve;
        bool isWrapped;
    }
kingyetifinance commented 2 years ago

@LilYeti : Duplicate with #4 #5 and #6

alcueca commented 2 years ago

Taking as main