Alchemix contest - hake's results

A protocol for self-repaying loans with no liquidation risk.

General Information

Platform: Code4rena

Start Date: 05/05/2022

Pot Size: $125,000 DAI

Total HM: 17

Participants: 62

Period: 14 days

Judge: leastwood

Total Solo HM: 15

Id: 120

League: ETH

Alchemix

Findings Distribution

Researcher Performance

Rank: 39/62

Findings: 2

Award: $267.81

🌟 Selected for report: 0

🚀 Solo Findings: 0

NON-CRITICAL

N-01: safeApprove has been deprecated

StrategyController.sol#L499

Consider using safeIncreaseAllowance and safeDecreaseAllowance instead.

REFERENCE

N-02: Floating Pragma

Using a floating pragma (^) might result in the contract being deployed with a version it was not tested with and might result in bugs that affect the contract system negatively.

Locking the pragma (deleting the ^) helps to ensure that contracts do not accidentally get deployed using an outdated compiler version or a version it was not tested with.

GAS

G-01: for loop gas optimization

https://github.com/code-423n4/2022-05-alchemix/blob/de65c34c7b6e4e94662bf508e214dcbf327984f4/contracts-full/StakingPools.sol#L363


for (uint256 _poolId = 0; _poolId < _pools.length(); _poolId++) {
    Pool.Data storage _pool = _pools.get(_poolId);
    _pool.update(_ctx);
}

Gas could be saved by:

  • Not initializing variable to default value of zero
  • Caching array length
  • Using a prefix (++i) instead of a postfix (i++)
  • Unchecking increment count

Example:


uint size = _pools.length();
for (uint256 _poolId; _poolId < size;) {
    Pool.Data storage _pool = _pools.get(_poolId);
    _pool.update(_ctx);

    unchecked { ++_poolId; }
}

Other instances: https://github.com/code-423n4/2022-05-alchemix/blob/de65c34c7b6e4e94662bf508e214dcbf327984f4/contracts-full/AlchemistV2.sol#L990 https://github.com/code-423n4/2022-05-alchemix/blob/de65c34c7b6e4e94662bf508e214dcbf327984f4/contracts-full/AlchemistV2.sol#L1282 https://github.com/code-423n4/2022-05-alchemix/blob/de65c34c7b6e4e94662bf508e214dcbf327984f4/contracts-full/AlchemistV2.sol#L1355 https://github.com/code-423n4/2022-05-alchemix/blob/de65c34c7b6e4e94662bf508e214dcbf327984f4/contracts-full/AlchemistV2.sol#L1461 https://github.com/code-423n4/2022-05-alchemix/blob/de65c34c7b6e4e94662bf508e214dcbf327984f4/contracts-full/AlchemistV2.sol#L1524 https://github.com/code-423n4/2022-05-alchemix/blob/de65c34c7b6e4e94662bf508e214dcbf327984f4/contracts-full/EthAssetManager.sol#L214

G-02: _checkState is redundant

AlchemistV2.sol#L1740

_uadd and _sub methods are redudant as there no risk of overflowing in the current contract implementation.

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