QuickSwap and StellaSwap contest - Tomio'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: 98/113

Findings: 1

Award: $24.02

🌟 Selected for report: 0

🚀 Solo Findings: 0

Title: Gas savings for using solidity 0.8.10

Proof of Concept: All contract in scope

Recommended Mitigation Steps: Consider to upgrade pragma to at least 0.8.10.

Solidity 0.8.10 has a useful change which reduced gas costs of external calls Reference: here


Title: Unchecking arithmetics operations that can't underflow/overflow

Proof of Concept: TokenDeltaMath.sol#L52 Should be unchecked due to L#51

Recommended Mitigation Steps: Use unchecked


Title: Using != in require statement is more gas efficient

Proof of Concept: PriceMovementMath.sol#L52-L53 AlgebraPool.sol#L434 AlgebraPool.sol#L469

Recommended Mitigation Steps: Change > 0 to != 0


Title: >= is cheaper than >

Impact: Strict inequalities (>) are more expensive than non-strict ones (>=). This is due to some supplementary checks (ISZERO, 3 gas)

Proof of Concept: AlgebraPool.sol#L237

Recommended Mitigation Steps: Consider using >= instead of > to avoid some opcodes


Title: Default value initialization

Impact: If a variable is not set/initialized, it is assumed to have the default value (0, false, 0x0 etc depending on the data type). Explicitly initializing it with its default value is an anti-pattern and wastes gas.

Proof of Concept: DataStorage.sol#L307

Recommended Mitigation Steps: Remove explicit initialization for default values.


Title: Caching length for loop can save gas

Proof of Concept: DataStorage.sol#L307

Recommended Mitigation Steps: Change to:

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

Title: Using unchecked and prefix increment is more effective for gas saving:

Proof of Concept: DataStorage.sol#L307

Recommended Mitigation Steps: Change to:

for (uint256 i = 0; i < secondsAgos.length;) { // ... unchecked { ++i; } }

Title: Using multiple require instead && can save gas

Proof of Concept: DataStorageOperator.sol#L46 AlgebraPool.sol#L739 AlgebraPool.sol#L743

Recommended Mitigation Steps: Change to:

require(_feeConfig.gamma1 != 0, 'Gammas must be > 0'); require(_feeConfig.gamma2 != 0, 'Gammas must be > 0'); require(_feeConfig.volumeGamma != 0, 'Gammas must be > 0');

Title: abi.encode() is less efficient than abi.encodePacked()

Proof of Concept: AlgebraPoolDeployer.sol#L51


Title: Set as immutable can save gas

Proof of Concept: AlgebraPoolDeployer.sol#L19

Recommended Mitigation Steps: can be set as immutable, which already set once in the constructor


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