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
Rank: 11/113
Findings: 2
Award: $627.08
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: berndartmueller
Also found by: 0xbepresent, 8olidity, tonisives
https://github.com/code-423n4/2022-09-quickswap/blob/15ea643c85ed936a92d2676a7aabf739b210af39/src/core/contracts/AlgebraPool.sol#L546-L549 https://github.com/code-423n4/2022-09-quickswap/blob/15ea643c85ed936a92d2676a7aabf739b210af39/src/core/contracts/AlgebraFactory.sol#L91-L95
In the swap
and swapSupportingFeeOnInputTokens
functions the community fee payment is called by the function _payCommunityFee
. The _payCommunityFee
will fail if the vault address is 0x0 and all the swap will be reverted by the safeTransfer
.
The setVaultAddress
can set the vault address
to zero address.
VisualStudio/Python
Add zero address check to the setVaultAddress
function.
#0 - debych
2022-10-04T13:37:39Z
duplicate of #210
🌟 Selected for report: IllIllI
Also found by: 0x1f8b, 0x5rings, 0xNazgul, 0xRoxas, 0xSmartContract, 0xbepresent, 0xmatt, Aeros, Amithuddar, Awesome, Aymen0909, B2, Bnke0x0, ChristianKuri, CodingNameKiki, Deivitto, Diraco, Fitraldys, HardlyCodeMan, JC, Mukund, Noah3o6, Olivierdem, RaymondFam, ReyAdmirado, RockingMiles, Rolezn, Ruhum, Saintcode_, Shinchan, SnowMan, TomJ, Tomio, Tomo, V_B, Waze, __141345__, ajtra, asutorufos, aysha, beardofginger, bobirichman, brgltd, bulej93, c3phas, ch0bu, cryptonue, defsec, delfin454000, dharma09, durianSausage, emrekocak, erictee, fatherOfBlocks, francoHacker, gianganhnguyen, gogo, imare, kaden, karanctf, ladboy233, lukris02, m_Rassska, martin, medikko, mics, natzuu, oyc_109, peiw, rbserver, ret2basic, rotcivegaf, saian, shark, slowmoses, tnevler, trustindistrust, zeesaw, zishansami
33.8119 USDC - $33.81
Not inlining costs more gas because of extra JUMP
instructions and additional stack operations needed for function calls.
Instances of this issue:
contracts/AlgebraFactory.sol#L122 function computeAddress(address token0, address token1) internal view returns (address pool) {
If needed, the values can be read from the verified contract source code.
Instances of this:
contracts/DataStorageOperator.sol#L15 uint256 constant UINT16_MODULO = 65536; contracts/DataStorageOperator.sol#L16 uint128 constant MAX_VOLUME_PER_LIQUIDITY = 100000 << 64; // maximum meaningful ratio of volume to liquidity core/contracts/libraries/DataStorage.sol#L12 uint32 public constant WINDOW = 1 days;
Pack non-256 bit type into single 256-bit storage slot may save gas.
Instances of this issue:
contracts/libraries/AdaptiveFee.sol#L10 struct Configuration { contracts/AlgebraPool.sol#L41 struct Position { contracts/libraries/TickManager.sol#L17 struct Tick { contracts/AlgebraPool.sol#L675 struct SwapCalculationCache { contracts/AlgebraPool.sol#L692 struct PriceMovementCache {
Require statements including conditions with the && operator can be broken down in multiple require statements to save gas.
Instances of this issue:
contracts/AlgebraPool.sol#L953 require((communityFee0 <= Constants.MAX_COMMUNITY_FEE) && (communityFee1 <= Constants.MAX_COMMUNITY_FEE)); contracts/AlgebraPool.sol#L739 require(limitSqrtPrice < currentPrice && limitSqrtPrice > TickMath.MIN_SQRT_RATIO, 'SPL'); contracts/AlgebraPool.sol#L968 require(newLiquidityCooldown <= Constants.MAX_LIQUIDITY_COOLDOWN && liquidityCooldown != newLiquidityCooldown);
Caching the array length outside a loop saves reading it on each iteration, as long as the array's length is not changed during the loop.
Instances of this issue:
contracts/libraries/DataStorage.sol#L307 for (uint256 i = 0; i < secondsAgos.length; i++) {
Variables that are assigned only in the constructor can be immutable
Instances of this issue:
contracts/AlgebraPoolDeployer.sol#L19 address private owner;