`Maker.adjustMaker` always reverts when trying to reduce maker liquidity while current price is below position range
The adjustMaker function incorrectly reverts when a user tries to reduce maker liquidity while the current pool price is below the position range, because the calculated token balances have x negative and y zero. This prevents users from reducing their position and can temporarily or permanently lock their funds.
HeckerTrieuTien Follow with JeRRy0422, Theseersec and 9 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-09-ammplify-judging/issues/420
Found by
HeckerTrieuTien, JeRRy0422, Theseersec, anonymousjoe, djshaneden, gh0xt, panprog, r1ver, songyuqi, supernova, tinnohofficial, ubl4nk
Summary
When Maker.adjustMaker is called, it checks for the calculated amounts of 2 tokens to give to / take from the user to be of the same sign:
if (data.xBalance == 0 && data.yBalance == 0) {
revert DeMinimusMaker(targetLiq);
} else if (data.xBalance > 0 || (data.xBalance == 0 && data.yBalance > 0)) {
// Both should go up together.
require(data.yBalance >= 0);
balances[0] = data.xBalance;
balances[1] = data.yBalance;
RFTLib.settle(msg.sender, tokens, balances, rftData);
PoolWalker.settle(pInfo, asset.lowTick, asset.highTick, data);
} else {
require(data.yBalance < 0);
The following cases in regards to x and y signs are possible:
x == 0, y == 0: revertsx > 0, y == 0: take from userx > 0, y > 0: take from userx == 0, y > 0: take from userx < 0, y == 0: revertsx < 0, y < 0: send to userx == 0, y < 0: send to user
Notice that in the case x < 0, y == 0 the transaction incorrectly reverts. This case corresponds to a situation when current pool price is below the position range and user tries to reduce maker liquidity, then liquidity consists of only token x with 0 token y.
User will be unable to reduce position in such situation. And if the price stays below the range for extended time, user will not be able to get his funds for extended time.
Root Cause
In the case of x < 0, y == 0, transaction reverts incorrectly:
https://github.com/sherlock-audit/2025-09-ammplify/blob/main/Ammplify/src/facets/Maker.sol#L72-L82
Internal Pre-conditions
User tries to reduce maker position while the current pool price is below the position range.
External Pre-conditions
None.
Attack Path
Always happens by itself when internal pre-condition is met
Impact
- User funds are temporarily stuck in the contract
- Core protocol function (reducing maker liquidity) not working under listed internal pre-condition (which is fairly frequent)
- If the price never recovers above the lower tick of the position, user will never be able to get back his funds by reducing position
Notes:
- While the funds are stuck only temporarily, it can lead to a permanent loss of funds due to inability to get the funds in time. For example, if the token
xprice starts dropping quickly, user wants to reduce position and sell tokenxbefore it drops more. However, he is unable to do this in time, and if the price keeps dropping, even if he later uses the other method to get funds back (remove maker liquidity, or manipulate spot price to bring it inside range, then back), the price for tokenxwill drop further and he will lose funds due to this. - While maker liquidity reduction reverts, maker liquidity removal doesn't have such issue, so the user can remove liquidity and add (reduced) liquidity as a work-around. However, due to another issue, if the user's liquidity is the last in the range, he will be unable to remove liquidity as well. So in such case both liquidity reduction and liquidity removal will revert.
- The user has an option to manipulate the pool price up to bring it inside the range, reduce liquidity, and manipulate the price back. However, the user will still lose funds to pay for manipulation fees, which can be significant compared to user position (for example, if user's position is worth $100, manipulation fees can be $10, $50, or even $1000 depending on liquidity, so it's either significant percentage of funds loss, or even not worth at all as it can cost more than position value).
Based on all these points, the severity of the issue is High, since a significant percentage of users will lose funds due to it.
Proof of concept
Add this test to Maker.t.sol:
// test the case when maker reduces position and should be given xBalance < 0, yBalance == 0
// (reduce when current price is below range)
function testAdjustMakerReduceRevert() public {
bytes memory rftData = "";
// current price below the range we'll work at
swapTo(0, TickMath.getSqrtRatioAtTick(700));
// Create maker
uint256 makerAssetId = makerFacet.newMaker(
recipient,
poolAddr,
720,
960,
300e18,
true,
minSqrtPriceX96,
maxSqrtPriceX96,
rftData
);
// try to reduce maker
makerFacet.adjustMaker(recipient, makerAssetId, 200e18, minSqrtPriceX96, maxSqrtPriceX96, rftData);
}
This test reverts due to data.yBalance < 0. The log (with added logging in the adjustMaker:
│ │ ├─ [0] console::log("adjustMaker: data.xBalance = ", -1150595527261723251 [-1.15e18]) [staticcall]
│ │ │ └─ ← [Stop]
│ │ ├─ [0] console::log("adjustMaker: data.yBalance = ", 0) [staticcall]
│ │ │ └─ ← [Stop]
│ │ └─ ← [Revert] EvmError: Revert
│ └─ ← [Revert] EvmError: Revert
└─ ← [Revert] EvmError: Revert
Mitigation
Handle case of x < 0, y == 0 correctly:
} else {
require(data.yBalance <= 0);
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/itos-finance/Ammplify/pull/31
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The condition in adjustMaker incorrectly requires yBalance to be strictly negative when xBalance is negative, but it should also allow yBalance to be zero.
Impact
Users cannot reduce their maker liquidity when the price is below the range, so their funds are temporarily stuck and may be permanently lost if the price does not recover.
What the attacker needed
Current price below position range; user has a maker position
The fix
The issue was fixed by changing the condition to allow yBalance to be less than or equal to zero.
How it was found
- Set the current pool price below the position range.
- Create a maker position with a range above the current price.
- Call adjustMaker to reduce the position.
- The transaction reverts because yBalance is zero and the code requires it to be negative.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In a liquidity pool, a maker position can hold two types of tokens. When the pool price moves outside the position's range, the position may contain only one token. The adjustMaker function is supposed to let users reduce their position, but it has a check that wrongly rejects the case where the user should receive only one token back. This means users cannot withdraw their funds in that situation.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.