Debt DAO contest - seyni's results

A cryptonative credit marketplace for fully anon and trustless loans to DAOs.

General Information

Platform: Code4rena

Start Date: 03/11/2022

Pot Size: $115,500 USDC

Total HM: 17

Participants: 120

Period: 7 days

Judge: LSDan

Total Solo HM: 1

Id: 174

League: ETH

Debt DAO

Findings Distribution

Researcher Performance

Rank: 57/120

Findings: 2

Award: $110.58

QA:
grade-b
Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

QA

[L-01] Missing address(0) check in LineFactory constructor

LineFactory.sol#L20-L39

Change this:

    constructor(
        address moduleFactory,
        address arbiter_,
        address oracle_,
        address swapTarget_
    ) {
        factory = IModuleFactory(moduleFactory);
        if (arbiter_ == address(0)) {
            revert InvalidArbiterAddress();
        }
        if (oracle_ == address(0)) {
            revert InvalidOracleAddress();
        }
        if (swapTarget_ == address(0)) {
            revert InvalidSwapTargetAddress();
        }
        arbiter = arbiter_;
        oracle = oracle_;
        swapTarget = swapTarget_;
    }

To this:

    constructor(
        address moduleFactory_,
        address arbiter_,
        address oracle_,
        address swapTarget_
    ) {
        if (moduleFactory_ == address(0)) {
            revert InvalidModuleFactoryAddress();
        }
        if (arbiter_ == address(0)) {
            revert InvalidArbiterAddress();
        }
        if (oracle_ == address(0)) {
            revert InvalidOracleAddress();
        }
        if (swapTarget_ == address(0)) {
            revert InvalidSwapTargetAddress();
        }
        factory = IModuleFactory(moduleFactory_);
        arbiter = arbiter_;
        oracle = oracle_;
        swapTarget = swapTarget_;
    }

#0 - c4-judge

2022-12-06T22:02:07Z

dmvt marked the issue as grade-b

Awards

49.2315 USDC - $49.23

Labels

bug
G (Gas Optimization)
grade-b
G-21

External Links

Gas optimizations

I only put the instances for which there wasn't a trade off between gas saving for deployment vs methods.

Optimizer settings:

optimizer = true optimizer_runs = 200

[G-01] storage pointer to a structure is cheaper than copying each value of the structure into memory

For instance, change this:

          Credit memory credit = credits[id];

To this:

          Credit storage credit = credits[id];

Deployment$\Delta$ Average gas
LineOfCredit1400
Methods$\Delta$ Average gas
accrueInterest12
init()(bool)198
setRates1

LineOfCredit.sol#L205

          Credit memory credit = credits[id];

LineOfCredit.sol#L257

        Credit memory credit = credits[id];

Deployment$\Delta$ Average gas
InterestRateCredit8 006
Methods$\Delta$ Average gas
accrueInterest4

InterestRateCredit.sol#L47

        Rate memory rate = rates[id];

Methods$\Delta$ Average gas
addCollateral3 681
getCollateralRatio939
getCollateralValue7764

EscrowLib.sol#L56

        IEscrow.Deposit memory d;

[G-02] State variables should be cached in stack variables rather than re-reading them from storage

Deployment$\Delta$ Average gas
InterestRateCredit3 006
Methods$\Delta$ Average gas
accrueInterest100

InterestRateCredit.sol#L47-L50

Change this:

        Rate memory rate = rates[id];
        uint256 timespan = block.timestamp - rate.lastAccrued;
        // update last timestamp in storage
        rates[id].lastAccrued = block.timestamp;

To this (rate data location has been set to storage in [G-01]):

        Rate storage rate = rates[id];
        uint256 timespan = block.timestamp - rate.lastAccrued;
        // update last timestamp in storage
        rate.lastAccrued = block.timestamp;

#0 - c4-judge

2022-11-17T22:59:12Z

dmvt marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter