A constant-product AMM whose liquidity is concentrated into a bounded price range [sqrtPriceMin, sqrtPriceMax]. Inside the range the pool prices swaps on the x × y = k curve; outside it the pool stops pricing. This archetype is analogous to Uniswap V3, though the internal math and fee composition differ.
A concentrated strategy is one instruction program priced by SwapVM (the Aqua swap engine) and run through the single AquaSwapVMRouter. The archetype is selected by the program bytes below, not by a dedicated contract.
The "pool" here is a virtual accounting construct, not a custodial vault. Each maker's tokens stay in their own wallet under a revocable, per-chain, per-token allowance; the protocol holds no tokens and moves them only when a taker fills a swap atomically.
Core instructions
| Instruction | Role |
|---|---|
_dynamicBalancesXD |
Load reserves; persist after swap |
_xycConcentrateGrowLiquidity2D |
Apply price-range bounds to reserves |
_xycSwapXD |
Compute x × y = k pricing within bounded state |
_xycConcentrateGrowLiquidity2D is a pre-swap modifier. It transforms balanceIn and balanceOut before the swap formula runs, and _xycSwapXD then operates on the adjusted reserves.
Program
Program memory program = ProgramBuilder.init(_opcodes());
bytes memory bytecode = bytes.concat(
program.build(_dynamicBalancesXD, BalancesArgsBuilder.build(
dynamic([tokenLt, tokenGt]),
dynamic([uint256(1_000e18), uint256(1_000e18)])
)),
program.build(_xycConcentrateGrowLiquidity2D, XYCConcentrateArgsBuilder.build2D(
sqrtPriceMin,
sqrtPriceMax
)),
program.build(_xycSwapXD)
);
Token ordering: tokenLt is the token with the lower address (price denominator); tokenGt is the token with the higher address. P = tokenGt / tokenLt.
Args (from XYCConcentrate)
| Field | Size | Type | Description |
|---|---|---|---|
sqrtPriceMin |
32 bytes | uint256 |
Lower bound of price range (sqrt of P) |
sqrtPriceMax |
32 bytes | uint256 |
Upper bound of price range (sqrt of P) |
Total: 64 bytes, packed via abi.encodePacked.
Price range behavior
| Condition | Behavior |
|---|---|
P inside [sqrtPriceMin², sqrtPriceMax²] |
Normal swap pricing |
| P at or beyond lower bound | Pool is fully in tokenLt; no more sells of tokenGt accepted |
| P at or beyond upper bound | Pool is fully in tokenGt; no more sells of tokenLt accepted |
Optional modifiers
| Goal | Add |
|---|---|
| Flat fee | _flatFeeAmountInXD before _xycConcentrateGrowLiquidity2D |
| MEV protection | _decayXD before the fee |
| Expiry | _deadline before balance setup |
Related
XYCConcentrate: instruction args and bounds math
XYCSwap: underlying constant-product formula
Constant Product: unbounded variant
Pegged Swap: low-slippage alternative for stable pairs