Skip to content
log(swap)

Getting started

An F-pool has a shared floor and composition. It can hold one base asset or several base assets against one quote token; a multi-asset pool is an F-pool. Depositors receive shares under the same terms, including any shared generation cap.

A C-pool trades one base against one quote and lets each LP choose a floor and optional cap for their position.

The examples below show direct, in-kind deposits through each pool manager: you supply the tokens the position requires, without swapping them. The router provides swaps and convenience operations, including single-asset entry with zapIn. Applications can use the TypeScript SDK.

Token and position permissions

Direct in-kind deposits

For the mint calls below, approve the relevant pool manager on every token you supply:

token.approve(address(managerF), amount); // each base asset and the quote for an F-pool
// For a C-pool deposit, approve address(managerC) on its base and quote instead.

The manager transfers the required tokens from the caller. These direct calls do not use Permit2 or require an ERC-6909 operator grant to mint new shares.

Router operations (RouterF, RouterC)

For swaps or deposits through the router, the approval path depends on whether the deployed router uses Permit2.

For a Permit2 deployment, each token needs two permissions:

  1. Approve Permit2 on the token contract. amount is the spending limit you authorize:
    token.approve(PERMIT2, amount);
  2. Allow the router to spend that token through Permit2, with an amount and expiry:
    permit2.approve(token, ROUTER, amount, expiration);
    This permission can also be signed using EIP-712 and submitted with the operation.

To let the router burn or modify existing position shares, grant it ERC-6909 operator permission on the manager that holds those shares:

manager.setOperator(ROUTER, true);

This position permission is separate from token allowances. It is not required for a swap. Token allowances can run out, and Permit2 permissions can expire; setup is not necessarily permanent. The SDK's onboard module checks the permissions for an operation.

First swap

For a C-pool:

router.swapExactIn(key, baseIn, amountIn, minOut, recipient, deadline);

Get a quote with lens.previewSwapExactIn(key, baseIn, amountIn), then set minOut to the lowest output you accept. The lens simulates the swap through a call that reverts with the quoted result. The SDK decodes that result. A quote describes the current state; another trade can change it before your transaction executes. minOut and deadline bound what you accept.

Markets can have different fixed swap fees. Select the market before requesting a quote; a route through several markets may also be needed. See Swapper.

First position

F-pool: mint in kind

Choose the liquidity amount dL to add to an existing pool. You inherit its shared floor, composition and any generation cap; you do not choose individual boundaries.

uint256 shares = managerF.mint(poolId, recipient, dL, maxQuoteIn);

Supply every base asset and the quote in proportion to the pool's current reserves. For example, adding 1% of the pool's liquidity requires approximately 1% of each reserve, with token amounts rounded up. A single-base F-pool needs its base and quote; a multi-asset F-pool needs each base and the quote. If the pool holds no quote, no quote deposit is required.

maxQuoteIn bounds the quote contribution; it does not bound base-token inputs. The returned shares are the recipient's shares after the mint fee. Fees from trading accrue within the pool. Review its policy before depositing: operator actions can change the shared floor or end a generation. See F-pool and Basket holder.

C-pool: mint in kind at your chosen boundaries

Choose liquidity size L, a floor and, for a capped position, an upper cap. The floor and cap use log-price coordinates on the market's tick ladder; cap = 0 selects an uncapped position.

uint256 shares = managerC.mint(key, floor, cap, L, recipient);

Supply the base and quote required by those boundaries at the current pool price, plus any mint fee in quote. For an active uncapped position, the reserves are R = L / p base and Q = L * log(p / pMin) quote. A position below its floor holds only base; a capped position above its cap holds only quote. The manager transfers the required amounts and mints ERC-6909 position shares to recipient.

This basic manager call has no token-amount bounds or deadline arguments. For an arbitrary floor between ladder rungs and explicit deposit limits, the router offers mintBlended, which also accepts the required tokens in kind. See Liquidity provider.

Optional: enter with a single asset

If you prefer to supply one token, the router's zapIn combines swaps with the mint. For an F-pool, it buys the required bases using quote; for a C-pool, it supports entry funded with base or quote. It is an alternative to the in-kind deposits above. See F-pool and Liquidity provider for the router entry points.

Where to go next