QuickSwap and StellaSwap contest - rotcivegaf's results

A concentrated liquidity DEX with dynamic fees.

General Information

Platform: Code4rena

Start Date: 26/09/2022

Pot Size: $50,000 USDC

Total HM: 13

Participants: 113

Period: 5 days

Judge: 0xean

Total Solo HM: 6

Id: 166

League: ETH

QuickSwap and StellaSwap

Findings Distribution

Researcher Performance

Rank: 47/113

Findings: 2

Award: $76.09

🌟 Selected for report: 0

šŸš€ Solo Findings: 0

QA report

Non-critical

N-NIssueInstances
[N‑01]Missing error message in require statement20
[N‑02]Same error message in require statement4

Total: 24 instances over 2 issues

[N-01] Missing error message in require statements

File: /src/core/contracts/AlgebraFactory.sol

43    require(msg.sender == owner);

60    require(tokenA != tokenB);

62    require(token0 != address(0));

63    require(poolByPair[token0][token1] == address(0));

78    require(owner != _owner);

85    require(farmingAddress != _farmingAddress);

92    require(vaultAddress != _vaultAddress);
File: /src/core/contracts/AlgebraPool.sol

 55    require(msg.sender == IAlgebraFactory(factory).owner());

122      require(_lower.initialized);

134      require(_upper.initialized);

229          require((_blockTimestamp() - lastLiquidityAddTimestamp) >= _liquidityCooldown);

953    require((communityFee0 <= Constants.MAX_COMMUNITY_FEE) && (communityFee1 <= Constants.MAX_COMMUNITY_FEE));

960    require(msg.sender == IAlgebraFactory(factory).farmingAddress());

968    require(newLiquidityCooldown <= Constants.MAX_LIQUIDITY_COOLDOWN && liquidityCooldown != newLiquidityCooldown);
File: /src/core/contracts/AlgebraPoolDeployer.sol

22    require(msg.sender == factory);

27    require(msg.sender == owner);

27    require(_factory != address(0));

28    require(factory == address(0));
File: /src/core/contracts/DataStorageOperator.sol

43    require(msg.sender == factory || msg.sender == IAlgebraFactory(factory).owner());
File: /src/core/contracts/libraries/DataStorage.sol

369    require(!self[0].initialized);
File: /src/core/contracts/libraries/PriceMovementMath.sol

52    require(price > 0);

53    require(liquidity > 0);

70        require((product = amount * price) / amount == price); // if the product overflows, we know the denominator underflows

71        require(liquidityShifted > product); // in addition, we must check that the denominator does not underflow

87        require(price > quotient);
File: /src/core/contracts/libraries/TokenDeltaMath.sol

30    require(priceDelta < priceUpper); // forbids underflow and 0 priceLower

51    require(priceUpper >= priceLower);

[N-02] Same error message in require statement

File: /src/core/contracts/AlgebraPool.sol

454      if (amount0 > 0) require((receivedAmount0 = balanceToken0() - receivedAmount0) > 0, 'IIAM');
455      if (amount1 > 0) require((receivedAmount1 = balanceToken1() - receivedAmount1) > 0, 'IIAM');

474      require((amount0 = uint256(amount0Int)) <= receivedAmount0, 'IIAM2');
475      require((amount1 = uint256(amount1Int)) <= receivedAmount1, 'IIAM2');

608      require(balance0Before.add(uint256(amount0)) <= balanceToken0(), 'IIA');
614      require(balance1Before.add(uint256(amount1)) <= balanceToken1(), 'IIA');
641      require((amountRequired = int256(balanceToken0().sub(balance0Before))) > 0, 'IIA');
645      require((amountRequired = int256(balanceToken1().sub(balance1Before))) > 0, 'IIA');

739        require(limitSqrtPrice < currentPrice && limitSqrtPrice > TickMath.MIN_SQRT_RATIO, 'SPL');
743        require(limitSqrtPrice > currentPrice && limitSqrtPrice < TickMath.MAX_SQRT_RATIO, 'SPL');

Gas report

G-NIssueInstances
[G‑01]++i costs less gas than i++, especially when it's used in for-loops (--i/i-- too)1
[G‑04]<array>.length should not be looked up in every loop of a for-loop1

Total: 2 instances over 2 issues

[G-01] ++i costs less gas than i++, especially when it's used in for-loops (--i/i-- too)

Saves 5 gas per loop

File: /src/core/contracts/libraries/DataStorage.sol

307    for (uint256 i = 0; i < secondsAgos.length; i++) {

[G‑02] <array>.length should not be looked up in every loop of a for-loop

The overheads outlined below are PER LOOP, excluding the first loop

  • storage arrays incur a Gwarmaccess (100 gas)
  • memory arrays use MLOAD (3 gas)
  • calldata arrays use CALLDATALOAD (3 gas)

Caching the length changes each of these to a DUP<N> (3 gas), and gets rid of the extra DUP<N> needed to store the stack offset

File: /src/core/contracts/libraries/DataStorage.sol

307    for (uint256 i = 0; i < secondsAgos.length; i++) {

Also can used in

File: /src/core/contracts/libraries/DataStorage.sol

294    tickCumulatives = new int56[](secondsAgos.length);
295    secondsPerLiquidityCumulatives = new uint160[](secondsAgos.length);
296    volatilityCumulatives = new uint112[](secondsAgos.length);
297    volumePerAvgLiquiditys = new uint256[](secondsAgos.length);
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