QuickSwap and StellaSwap contest - 0xRoxas'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: 111/113

Findings: 1

Award: $24.02

🌟 Selected for report: 0

🚀 Solo Findings: 0

Gas Report

Optimizations found [5]

[G-01] Use != 0 instead of > 0 for Unsigned Integer Comparison ⓘ

Findings:

/src/core/contracts/AlgebraPool.sol Line(s): 224, 228, 237 (NOT liquidityDelta), 434, 451, 452, 454 ((amount0 != 0)), 455 ((amount0 != 0)), 469, 505, 506, 617, 667, 808, 814, 898, 904, 911, 924, 927, 938, 941

224: require(currentLiquidity > 0, 'NP'); 228: if (_liquidityCooldown > 0) { 237: liquidityNext > 0 ? (liquidityDelta > 0 ? _blockTimestamp() : lastLiquidityAddTimestamp) : 0 434: require(liquidityDesired > 0, 'IL'); 451: if (amount0 > 0) receivedAmount0 = balanceToken0(); 452: if (amount1 > 0) receivedAmount1 = balanceToken1(); 454: if (amount0 > 0) require((receivedAmount0 = balanceToken0() - receivedAmount0) > 0, 'IIAM'); 455: if (amount1 > 0) require((receivedAmount1 = balanceToken1() - receivedAmount1) > 0, 'IIAM'); 469: require(liquidityActual > 0, 'IIL2'); 505: if (amount0 > 0) TransferHelper.safeTransfer(token0, recipient, amount0); 506: if (amount1 > 0) TransferHelper.safeTransfer(token1, recipient, amount1); 617: if (communityFee > 0) { 667: if (communityFee > 0) { 808: if (cache.communityFee > 0) { 814: if (currentLiquidity > 0) cache.totalFeeGrowth += FullMath.mulDiv(step.feeAmount, Constants.Q128, currentLiquidity); 898: require(_liquidity > 0, 'L'); 904: if (amount0 > 0) { 911: if (amount1 > 0) { 924: if (paid0 > 0) { 927: if (_communityFeeToken0 > 0) { 938: if (paid1 > 0) { 941: if (_communityFeeToken1 > 0) {

[G-02] Break Apart Require Statments Instead of && ⓘ

Findings:

/src/core/contracts/AlgebraFactory.sol Line(s): 110

110: require(gamma1 != 0 && gamma2 != 0 && volumeGamma != 0, 'Gammas must be > 0');

/src/core/contracts/AlgebraPool.sol Line(s): 739, 743, 953, 968

739: require(limitSqrtPrice < currentPrice && limitSqrtPrice > TickMath.MIN_SQRT_RATIO, 'SPL'); 743: require(limitSqrtPrice > currentPrice && limitSqrtPrice < TickMath.MAX_SQRT_RATIO, 'SPL'); 953: require((communityFee0 <= Constants.MAX_COMMUNITY_FEE) && (communityFee1 <= Constants.MAX_COMMUNITY_FEE)); 968: require(newLiquidityCooldown <= Constants.MAX_LIQUIDITY_COOLDOWN && liquidityCooldown != newLiquidityCooldown);

[G-03] Unless Used for Variable Packing uint8 May Be More Expensive Than Using uint256 ⓘ

Findings:

/src/core/contracts/AlgebraPool.sol Line(s): 925, 939

925: uint8 _communityFeeToken0 = globalState.communityFeeToken0; 939: uint8 _communityFeeToken1 = globalState.communityFeeToken1;

/src/core/contracts/libraries/Constants.sol Line(s): 5, 16

5: uint8 internal constant RESOLUTION = 96; 16: uint8 internal constant MAX_COMMUNITY_FEE = 250;

/src/core/contracts/libraries/TickTable.sol Line(s): 18, 84, 102

18: uint8 bitNumber; 84: uint8 bitNumber; 102: uint8 bitNumber;

/src/core/contracts/base/PoolState.sol Line(s): 13, 14

13: uint8 communityFeeToken0; 14: uint8 communityFeeToken1;

[G-04] Variables Only Used Through Initialization in Constructor Should Be Immutable ⓘ

src/core/contracts/AlgebraPoolDeployer.sol Line(s): 13

19: address private owner;

[G-05] Make Constants Private to Prevent Unneeded Getters

src/core/contracts/DataStorageOperator.sol Line(s): 15, 16

15: uint256 constant UINT16_MODULO = 65536; 16: uint128 constant MAX_VOLUME_PER_LIQUIDITY = 100000 << 64;
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