A Partially Active AMM on 1inch Aqua and Uniswap v4: in any block, arbitrageurs can reach only a fraction λ of the reserves. λ is chosen by a fee-aware keeper from recent real prices, and the idle reserves earn yield in Morpho vaults until the moment they are needed.
On a replay of the real 24 hours ending 21 Sep 2026 (ETH +6.24%), on a Base mainnet fork with the real Uniswap v4 PoolManager and official Aqua, Iceberg cut what liquidity providers lost to arbitrage by 17.6% at λ = 50% and 19.3% at λ = 39%, compared with a real plain Uniswap v4 pool at the same 5 bps fee.
Built at ETHGlobal Tokyo 2026 for 1inch Build an Aqua App and Uniswap Best Uniswap Stack Contribution.
Uniswap v4: IcebergHook on OpenZeppelin's BaseCustomCurve, live on Base mainnet at 0xe5a6…eA88.
| What | Code |
|---|---|
The hook contract (BaseCustomCurve + ERC-20 LP shares) |
IcebergHook.sol:35 |
| Swap pricing: per-block split, x·y=k on the active reserves only, unpark from Morpho mid-swap | IcebergHook.sol:191-212 |
| Per-block split of the reserves (the Partially Active AMM) | IcebergHook.sol:164-176 |
λ read from the keeper's IcebergParams, gas-capped with fallback |
IcebergHook.sol:177-190 |
| Never quote more than the pool can deliver (claims + Morpho withdrawable) | IcebergHook.sol:137-153 |
| Pull parked reserves out of Morpho inside a swap | IcebergHook.sol:154-163 |
| Add / remove liquidity (LP exit unparks from Morpho itself) | IcebergHook.sol:225-268 |
| Park / unpark idle reserves in Morpho | IcebergHook.sol:269-300 |
Hook address mined with HookMiner, deployed via the CREATE2 deployer, pool initialized on the real PoolManager |
Iceberg.s.sol:127-165 |
| Fork tests against the real Base PoolManager | test/fork/IcebergHookFork.t.sol |
| Developer feedback | FEEDBACK.md |
1inch Aqua / SwapVM: custom SwapVM instructions in an extended AquaSwapVMRouter, live on Base mainnet at 0xE498…84b5.
| What | Code |
|---|---|
PAActiveReserves (opcode 0x92): the per-block freeze |
PAActiveReserves.sol:94-120 |
ChainlinkDeviationGuard (opcode 0x21): price check against Chainlink |
ChainlinkDeviationGuard.sol:43-53 |
IcebergRouter: 1inch's official router plus the two opcodes |
IcebergRouter.sol:17-22 |
| The strategy program: Salt → guard → PAActiveReserves → FeeFlatIn → XYCSwap | IcebergConfig.sol:49-57 |
| Morpho-vaulted inventory: withdraw on fill, deposit proceeds back | VaultedInventoryHooks.sol:42-72 |
| Aqua shared liquidity on 1inch's official router (SwapVM v1.0.2) | IcebergConfig.sol:74-77 |
Algorithm 1 of the paper, every block. On the first trade of a block, total reserves R are split into an active part λ·R and a passive part (1 − λ)·R. The passive part is frozen for the rest of the block. Every trade in that block sees only total − passive, on a constant-product curve with a 5 bps fee on the input. Quotes never write storage, so quote == swap.
One kernel, two venues (IcebergMath):
| 1inch Aqua | Uniswap v4 | |
|---|---|---|
| Contract | PAActiveReserves, a SwapVM instruction in free opcode slot 0x92, followed by 1inch's stock FeeFlatIn + XYCSwap |
IcebergHook on OpenZeppelin's BaseCustomCurve; the hook owns the reserves as ERC-6909 claims |
| Router / pool | IcebergRouter = 1inch's AquaSwapVMRouter unchanged + Iceberg opcodes (0x21 guard, 0x52 v4 peg, 0x92 split); stock Aqua programs behave exactly as on the official router |
WETH/USDC pool on the real Base PoolManager, hook deployed through the real CREATE2 deployer at a mined address |
| Where idle funds sit | The maker holds only Morpho vault shares. VaultedInventoryHooks withdraw exactly the fill at the moment of the fill and deposit the proceeds back |
Passive reserves are parked in Morpho (park / unpark), never more than (1 − max λ) |
| λ | Same pluggable ILambdaSource: the fee-aware keeper (IcebergParams, inside a maker-controlled box, revocable) or Theorem 1. Called gas-capped inside try/catch; a broken source falls back to the program λ |
Same |
Same reserves, same λ and same fee give the same price to the wei on both venues: a buy/sell sequence across blocks matches exactly (test).
Never promise more than can be delivered. On Aqua, IcebergParams caps λ at what the maker's wallet plus Morpho vault can release right now (MetaMorpho maxWithdraw). On v4, the hook caps its active side at its in-pool claims plus what its vault will release, and pulls any shortfall out of Morpho inside the swap. LPs can always exit: removeLiquidity unparks their share itself.
Weight tracking (rebalancing). A partially active pool lags the market, so its mix drifts, which is the cost the paper names. When the Aqua position's ETH weight at the live price leaves 50% ± 2%, the keeper:
- retires the strategy (
dock); - rebalances the maker's Morpho holdings to 50/50 through Uniswap v3 (WETH/USDC 0.05%);
- re-ships with a new salt, balanced at the live price.
This resets a stale curve price without paying arbitrageurs. It is resumable if interrupted, and serialised with the keeper through a maker-key lock.
Aqua shared liquidity. The same Morpho vault shares also back a plain 5 bps strategy on 1inch's official, unmodified router. One balance, two strategies, and each fill withdraws exactly what it needs. The official router on Base runs SwapVM v1.0.2, so that order is encoded by SwapVM102.
The fee-aware keeper (frontend/scripts/keeper.ts) runs on its own timer:
- It reads live Base Chainlink.
- Every ~10 minutes it takes the last 6 hours of real ETH/USD and simulates each λ from 100% down to the floor at the pool's fee.
- It publishes the λ with the lowest LP loss to both venues.
- It keeps the v4 pool's idle reserves parked in Morpho.
- It rebalances the Aqua position when its weight drifts outside the band.
Every decision is logged with the table behind it, and the UI charts it.
| Claim | Result | Reproduce |
|---|---|---|
| Real replay, 21 Sep 2026 (1,440 min, 5 bps) | LP loss vs a perfectly rebalanced portfolio: plain v4 $1.077 · Iceberg λ 100% $1.076 · λ 50% $0.888 (−17.6%) · λ 39% $0.869 (−19.3%) · Aqua λ 50% $0.888 (identical to the hook) | REPLAY_MINUTES=1440 BASE_RPC_URL=https://mainnet.base.org forge test --match-contract Replay21Sep -vv → research/replay_2026-09-21_1440min.json |
| Fee-aware λ (7 days, real ETH/USD) | −32% loss at 1 bps, −17% at 5 bps; the keeper tunes λ to each pool's fee | node research/lambda_policy.mjs |
| Kernel matches the paper | λ* within 1e-16, Theorem 1 within 5e-15, ln within 8e-11 of the float reference; v2 closed form satisfies the paper's fixed point | forge test --match-path test/unit/IcebergMath.t.sol -vv |
| 1inch's own invariants hold | CoreInvariants (symmetry, additivity, quote == swap, monotonicity, rounding favours maker, balance sufficiency) at λ = 1, 0.5, 0.25, with and without fee |
forge test --match-path test/invariant/PAInvariants.t.sol |
| Works on real Base contracts | 11 Aqua fork tests (split, same-block second fill, re-split, passive untradable, keeper bounds and fallback, gas-capped source, Theorem 1, Chainlink guard, vaulted + partially active) and 11 v4 hook fork tests (split, λ source, exact-out, park/unpark with real vault yield, blocked direct liquidity, parity with Aqua, real CREATE2 deploy) | BASE_RPC_URL=https://mainnet.base.org forge test (52 tests) |
| Whole stack end to end | keeper, both venues, API swaps, per-block splits, vault moves, activity labels, UI | ./scripts/test_all.sh |
| Mainnet run rehearsed first | the exact mainnet flow on a fork with the real wallet and balance: 64 transactions (both venues, 6 Aqua fills, 4 v4 swaps, keeper λ updates, a rebalance, 2 shared-liquidity fills), then the withdraw script returned every USDC and all the ETH except gas; ≈$0.20 of gas | ./scripts/rehearse_mainnet.sh |
| Aqua on Base, measured | 872 strategies from 144 makers since launch; 51.7% never got a single fill; 66 makers never got any; of 80 live never-filled strategies, 41 have no money behind them (wallet balance or approval is zero) | node research/aqua_base_study.mjs → research/aqua_base_study.json |
| Shared liquidity on 1inch's real official router | Iceberg position and official-router strategy both filled from one maker's Morpho shares | forge test --match-path test/fork/SharedLiquidityFork.t.sol |
| Contracts we build on are genuine | Aqua, official router, PoolManager, both MetaMorpho vaults, Chainlink: source-verified on Base; Aqua has identical code on Base, Ethereum and Polygon | ./scripts/verify_contracts.sh |
| Ethereum Sepolia (public testnet) | Both venues deployed and traded, 21 transactions, all successful: router 0x41983C692Fd7ef800aC6C9E5F1f90737e1C5a79F, hook 0x5e6FF9B22d2cf653559Ecc519394C1Ec8a842A88; Aqua fill 0x321ee148…, v4 swap 0xd00ff66f… |
PK=… forge script script/Sepolia.s.sol:SepoliaSmoke --rpc-url <sepolia> --broadcast |
| Live on Base mainnet | Both venues deployed and trading with one wallet, every transaction successful: router 0xE498…84b5, v4 hook 0xe5a6…eA88 (the first one, 0x1427…ea88, was fully withdrawn and replaced by ./scripts/refund_mainnet.sh), params 0x0e5a…C4B9. Iceberg position shipped to Aqua 0x8c3169b5… · Aqua fill through the SwapVM opcodes 0x0f1ba3fb… · v4 swap through the hook 0x42df14c2… · weight-tracking re-ship 0xa9010841… · shared-liquidity fill on 1inch's official router 0xade98ded…. All addresses in deployments/mainnet.json |
CONFIRM=yes ./scripts/deploy_mainnet.sh · take it all back: ./scripts/withdraw_mainnet.sh · put small positions back: CONFIRM=yes ./scripts/refund_mainnet.sh |
| Contract | What it does | Address |
|---|---|---|
| IcebergRouter | 1inch's Aqua router plus the two Iceberg SwapVM opcodes (PAActiveReserves 0x92, ChainlinkDeviationGuard 0x21) |
0xE4989c27d45bcE9b44c4721daca0790e02BC84b5 |
| IcebergHook | Uniswap v4 hook: the same per-block freeze inside the pool, idle reserves parked in Morpho | 0xe5a690F6F0b10e4EE33DEFa271E8C893dd3ceA88 |
| IcebergParams | The keeper's λ for both venues, with each venue's allowed range | 0x0e5ac4A76930cfa67820d63cC1962a87Ef8FC4B9 |
| VaultedInventoryHooks | Pulls an Aqua fill's output from Morpho and deposits its input back | 0x7478da369578471D621826451Ba67453720Aa4F4 |
| VaultedInventoryHooks (official router) | The same, for the shared-liquidity strategy on 1inch's official router | 0x14D4E5e7f9E475F714c48F030Ad03e3A2C0d8409 |
| IcebergLens | Read-only helper that builds orders for off-chain code | 0x2bC214ea3d908C792bF5def677Cf95ECA407D630 |
| PoolSwapTest | Swap router used to trade the v4 pool | 0xC99519426A499e388F71C1d0EFDEf6067cf475C3 |
| Wallet | The one wallet that deployed everything and plays maker, keeper and taker | 0x3AaAe578f1F6bBE9705363DE4354d64d6a09C8B7 |
Retired after the first full withdraw (no funds left, transactions still on Basescan): IcebergHook 0x1427472E1131061913b1115175c7d106Ed31ea88, PoolSwapTest 0x09F761363302CC531926a21478b53f7F5f520387, official-router hooks 0x9F5A8A90dFC323E8f5F9DC1CEf60BaeE548bB3A6. All addresses are also in deployments/mainnet.json.
git clone --recurse-submodules <repo> iceberg && cd iceberg
(cd lib/swap-vm && yarn install --ignore-scripts) && npm install && (cd frontend && npm install)
forge build
./scripts/test_all.sh # every Solidity test + a fresh local stack + end-to-end check + terminal demo
open http://localhost:8788/live # live dashboard (site: / · /mechanism · /evidence · /contracts); the terminal demo: (cd frontend && PAUSE=1 npx tsx scripts/demo.ts)
./scripts/stop_local.shWatch everything live in the terminal (every swap, split, vault move, park, λ update, rebalance and keeper tick; the same feed as the UI):
(cd frontend && npm run watch)
(cd frontend && npm run swap -- official buy 5) # one real swap: v4 | aqua | official
(cd frontend && FORCE=1 npm run rebalance) # weight-tracking rebalance now
tail -f .run/keeper.log # the keeper's own logAPI (local fork):
curl -s localhost:8788/api/status | jq # both venues, λ, active vs passive, Morpho, keeper
curl -s "localhost:8788/api/quote?venue=aqua&side=buy&usd=25" | jq # quote on either venue
curl -s -X POST "localhost:8788/api/swap?venue=v4&side=buy&usd=25" | jq # real swap (tx hash), appears live in the UI
curl -s localhost:8788/api/activity | jq '.counts' # splits, swaps, vault moves, λ updates, rebalances
curl -s -X POST "localhost:8788/api/rebalance?force=1" | jq # weight-tracking rebalance (retire, Uniswap, re-ship)Run-of-show for the split-screen demo: DEMO.md. Uniswap developer feedback: FEEDBACK.md. Every issue found while building, with its fix and guarding test: docs/REVIEW.md.
- Contract size. 1inch's
AquaSwapVMRouteris already 21,981 bytes, and adding the λ policies inline pushed it to 26,458. We moved policies into externalILambdaSourcecontracts and compiled at 200 optimizer runs, which gives 24,349. - Vault ops and liquidity callbacks. The v4 hook routes park/unpark through the PoolManager's
unlock. OpenZeppelin's liquidity callback data is exactly 96 bytes, so vault operations are tagged with a 32-byte marker (128 bytes) to never be confused with it. - A gas-griefing hole caught in testing. A hostile λ source could burn about 1B gas through try/catch. The read is now capped at 100k gas.
- HookSwap amounts are both positive in OpenZeppelin's event. Direction is inferred from which currency paid the LP fee.
- Foundry with
via_ircachesblock.numberacrossvm.rollin a loop. The replay keeps its own block counter; otherwise every "minute" lands in the same block. - Base Chainlink and anvil. A fork's Chainlink freezes, so the local stack mirrors the live answer. The rehearsal and mainnet flows price against real Chainlink.
- Partially Active AMMs, Sunghun Ko, arXiv 2602.09887. Iceberg implements Algorithm 1, the closed-form λ*(γ) and Theorem 1.
- Tide (ETHGlobal Tokyo 2026, concurrent work) also implements PA-AMM on Aqua and Uniswap v4, on Sepolia, with an agent-proposed λ and a second paper's deep virtual curve. Iceberg differs in the fee-aware λ, running on Base mainnet, vault-held reserves on both venues, and a single-curve core.
- Barker (ETHOnline 2026) showed vault-backed Aqua quotes on a fork. Iceberg brings vault-held inventory to mainnet, inside a PA-AMM position, and to a v4 hook.
- 1inch Aqua and SwapVM (router,
XYCSwap,FeeFlatIn,CoreInvariants) are used unmodified. OpenZeppelin uniswap-hooksBaseCustomCurveis the hook base. Morpho vaults: Moonwell Flagship ETH, Steakhouse USDC.
Built with Claude Code (Anthropic). AI wrote most of the code, tests and docs under the author's direction. Every number above comes from the command next to it.