QuantAMM

QuantAMM
49,600 OP
View results
Submission Details
Severity: low
Invalid

Missing check in createWithoutArgs() can lead to deploying a malfunctioning Pool.

Summary

No checks to verify the flag of enableHookAdjustedAmounts before setting the params.disableUnbalancedLiquidity to liquidityManagement.disableUnbalancedLiquidity which can lead to undefined behaviour in the deployed pool.

Vulnerability Details

The enableHookAdjustedAmounts flag, when enabled, can modify the amounts involved in a liquidity operation. This is done by using custom logic in hooks to adjust the amounts during key operations like adding liquidity and removing liquidity. In QauntAMMWeightedPoolFactory.sol, the functions create() and createWithoutArgs() are used for deploying new pools. The issue here is that in setting the disableUnbalancedLiquidity the function is supposed to first check if disableUnbalancedLiquidity is set to true and if so, disableUnbalancedLiquidity musst be to set to true also, but this ws not done in the code.
see code below;

function createWithoutArgs(NewPoolParams memory params) external returns (address pool) {
if (params.roleAccounts.poolCreator != address(0)) {
revert StandardPoolWithCreator();
}
LiquidityManagement memory liquidityManagement = getDefaultLiquidityManagement();
liquidityManagement.enableDonation = params.enableDonation;
// disableUnbalancedLiquidity must be set to true if a hook has the flag enableHookAdjustedAmounts = true.
liquidityManagement.disableUnbalancedLiquidity = params.disableUnbalancedLiquidity;
//more code....

Permlink: https://github.com/Cyfrin/2024-12-quantamm/blob/a775db4273eb36e7b4536c5b60207c9f17541b92/pkg/pool-quantamm/contracts/QuantAMMWeightedPoolFactory.sol#L85

Impact

Can lead to irregularities in pool accounting, as if the disableUnbalancedLiquidity is set to false when it should be true, the pool will allow unbalanced liquidity to be added, whereas the hookadjustedamounts is set to true and it will adjust the amount based on fees while trying to balance the amounts of liquidity being added. This creates irregularities in accounting, which may lead to loss of funds if severe.

Tools Used

Manual Review

Recommendations

query the hook for the pool for the flag of enableHookAdjustedAmounts and add checks to ensure that it does not conflict with disableUnbalancedLiquidity

if (hook.enableHookAdjustedAmounts && !params.disableUnbalancedLiquidity) {
revert("Unbalanced liquidity must be disabled if hook adjusted amounts are enabled");
}
// Or...
if (hook.enableHookAdjustedAmounts) {
params.disableUnbalancedLiquidity = true;
}
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas / Admin is trusted / Pool creation is trusted / User mistake / Suppositions

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Appeal created

brazexyz Submitter
10 months ago
n0kto Lead Judge
9 months ago
n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas / Admin is trusted / Pool creation is trusted / User mistake / Suppositions

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.