spot icon indicating copy to clipboard operation
spot copied to clipboard

Consider improving packing in PerpetualTranche.sol

Open marktoda opened this issue 3 years ago • 1 comments

    /// @notice The minimum maturity time in seconds for a tranche below which
    ///         it can be rolled over.
    uint256 public minTrancheMaturitySec;

    /// @notice The maximum maturity time in seconds for a tranche above which
    ///         it can NOT get added into the reserve.
    uint256 public maxTrancheMaturitySec;

    /// @notice The percentage of the reserve value to be held as mature tranches.
    uint256 public matureValueTargetPerc;

each of these could easily fit in smaller sizes to pack them all into 1 storage slot. With some improvements to read-sites can probably save several thousand gas for every afterStateUpdate operation.

uint32 should be enough for the *Sec ones (136 years of maturity window) *Perc should also fit in uint32 (100% * 10e16 fits in uint32)

marktoda avatar Dec 08 '22 19:12 marktoda

with sizes as defined above could also pack _decmials

marktoda avatar Dec 08 '22 19:12 marktoda