Aqua0
Developers

Concepts

The minimum vocabulary developers need to integrate Aqua0.

Strategies

A strategy is a SwapVM program (bytecode) describing how liquidity behaves during a swap. It encodes the curve, fees, and token pair. A strategy is identified by a stable strategyId equal to keccak256(initialStrategyBytes). The protocol-curated strategy catalog is admin-shipped, so end users join existing strategies rather than authoring their own.

When a strategy is shipped, it is registered in 1inch Aqua's 4D virtual ledger:

_balances[maker][app][strategyHash][token]

For Aqua0, maker is the SLP, app is the SwapVM router, and strategyHash rotates on every reship (since Aqua enforces strategy immutability after dock). The stable strategyId lets the brain correlate strategy lifecycle events with its own swap_strategy_commitments table.

Shared Liquidity Pool (SLP)

The SLP is a UUPS-upgradeable custody vault deployed on each supported chain. It holds the tokens, verifies signatures and Aqua handshakes, and emits the events the off-chain brain indexes. It is intentionally a "dumb vault":

  • It does not track per-LP balances. There is no freeBalance mapping.
  • It does not track per-strategy LP commitments or pro-rata attribution.
  • It does not track aggregate committed balances per token.
  • It does not record bridge delivery attribution.

All of that lives in the brain DB. The contract is a passthrough that emits the events the brain consumes. The backend pre-validates against its own ledger before signing any payload that mutates SLP state.

The SLP exposes three single-slot privileged identities, each settable only by the contract owner:

SlotPurpose
backendSignerEIP-712 signer for JITPayload, WithdrawPayload, RepaymentWithdrawPayload
repaymentWorkerThe only EOA allowed to call withdrawForRepayment
operatorThe only EOA allowed to call shipStrategy / dockStrategy / reshipStrategy

These are independent: leaking one does not authorize the others. There is no AccessControl role mapping.

Liquidity providers

LPs are EOAs or ERC-4337 wallets. They interact with the SLP directly. The SLP uses msg.sender as the LP identity. There is no smart-account factory, no LP smart account, no off-chain filler registration step.

LP deposit and withdraw use the SLP's standard surface (deposit, withdraw, signed-withdraw). Per-LP balance and capacity are derived off-chain by the brain from the indexed Deposited / Withdrawn event stream plus the brain's overlay of pending and settled obligations.

Trader flow: single-chain SwapVM

  1. Trader calls POST /api/v1/swaps/quote to size the trade.
  2. Trader calls POST /api/v1/swaps/prepare to receive calldata for AquaSwapVMRouter.swap.
  3. Trader submits the transaction.
  4. The router pulls tokenOut from the SLP and pushes tokenIn to the SLP, atomically inside Aqua's 4D virtual ledger.
  5. The router emits Swapped(orderHash, maker, taker, tokenIn, tokenOut, amountIn, amountOut).
  6. The brain's swapvm-attribution.service.ts poller picks up the event, looks up the matching swap_strategy_commitments rows, and pro-rata-distributes the deltas across each committed LP's overlay.

No on-chain attribution writeback happens. The contract's role ends at the swap.

Trader flow: single-chain V4 JIT

  1. Trader calls POST /api/v2/jit/authorize with the swap params.
  2. The backend signs an EIP-712 JITPayload and returns it.
  3. Trader submits a v4 swap with the signed payload as hookData.
  4. Aqua0Hook.beforeSwap verifies the signature against the SLP's backendSigner, then injects a temporary range backed by SLP capital.
  5. The swap executes against the injected range.
  6. Aqua0Hook.afterSwap removes the range and emits SwapSettled.

Trader flow: cross-chain V4 JIT

Same as the single-chain V4 path, but the JIT payload references chain-A LP capital backing a chain-B swap. Once the swap settles on chain B, the brain's SwapSettled poller marks the SwapJITBreakdown settled and queues a repayment obligation. The repayment-worker then drains the source LP (see "Cross-chain mechanism").

Cross-chain mechanism: LayerZero OFT only

The protocol uses LayerZero V2 OFT adapters for all cross-chain repayment. There is no CCTP path, no Stargate path, no Composer hop.

sequenceDiagram
  participant Be as Backend (brain)
  participant Wk as Repayment-worker
  participant SLPA as SLP_A (source)
  participant OFT as LayerZero OFT
  participant SLPB as SLP_B (destination)

  Be->>Wk: signed RepaymentWithdrawPayload
  Wk->>SLPA: withdrawForRepayment(payload)
  SLPA->>OFT: forwardOut to OFT adapter
  OFT-->>SLPB: bridged delivery → tokens in SLP_B balance
  Be->>Be: credit destination filler in brain DB

The MockTokenOFTAdapter is the testnet stand-in for canonical OFTs. On mainnet, replace it with the canonical OFT for each token.

There is no on-chain attributeDelivery call. Tokens land directly in the destination SLP's balance via the OFT delivery, and the brain credits the destination filler off-chain.

Off-chain attribution

Attribution lives in the brain DB and the Ponder indexer.

  • SwapVM attribution. Brain reads SwapVMRouter.Swapped and applies pro-rata deltas across swap_strategy_commitments.
  • V4 attribution. Brain reads the SLP's SwapSettled event (via Ponder's slp_swap_settled table) and applies the route plan to LP overlays.
  • Cross-chain attribution. Brain walks the same swap_strategy_commitments table and the filler_repayment_jobs queue. The on-chain repayment leg uses the same withdrawForRepayment plus LayerZero OFT path for both V4 and SwapVM.

Read the brain's snapshot via GET /api/v2/jit/debug/snapshot. The full route table and request/response shapes are auto-generated at GET /openapi.json on the running API.

Chains

Live testnet deployments are on Base Sepolia (chainId 84532) and Unichain Sepolia (chainId 1301). Both chains run the SLP, the V4 Aqua0Hook, the 1inch Aqua and SwapVM router, and LayerZero OFT adapters for mUSDC, mDAI, mWBTC, and mWETH. Live addresses are tracked in backend/deployments/{chainId}.json.

On this page