Skip to main content
Helpful?

IPoolManager

The IPoolManager interface defines the main methods for interacting with the Uniswap V4 pool manager contract. It exposes the core swap lifecycle operations

ModifyLiquidityParams

Structure used to modify liquidity in a pool.

  • tickLower: Lower tick boundary of the position
  • tickUpper: Upper tick boundary of the position
  • liquidityDelta: Amount of liquidity to add (positive) or remove (negative)
  • salt: A value to set if you want unique liquidity positions at the same range

Used in the modifyLiquidity function to add or remove liquidity from a specific position in the pool.

SwapParams

Structure used to execute a swap in a pool.

  • zeroForOne: Direction of the swap (true for token0 to token1, false for token1 to token0)
  • amountSpecified: Amount of tokens to swap (positive for exact input, negative for exact output)
  • sqrtPriceLimitX96: Slippage limit represented as Q64X96 notation

Used in the swap function to define the behavior of our swap.

Methods

initialize

function initialize(PoolKey memory key, uint160 sqrtPriceX96, bytes calldata hookData)
external
returns (int24 tick);

Initialize a new pool by defining its parameters: token pair, fee tier, tick spacing, hook contract, and starting price

Param NameTypeDescription
keyPoolKeyThe key defining the pool to initialize
sqrtPriceX96uint160The initial sqrt price of the pool as a Q64.96 value
hookDatabytesAny additional data to pass to our hook contract on the before/after initialization hooks

Returns the initial tick value of the pool.

unlock

function unlock(bytes calldata data) external returns (bytes memory);

Provides a single entry point for all pool operations. The provided data is passed to the callback for execution.

Param NameTypeDescription
databytesAny data to pass to the callback via IUnlockCallback(msg.sender).unlockCallback(data)

Returns the data returned by the callback.

modifyLiquidity

function modifyLiquidity(
PoolKey memory key,
ModifyLiquidityParams memory params,
bytes calldata hookData
) external returns (BalanceDelta, BalanceDelta);

Modifies the liquidity for the given pool. Can be used to add or remove liquidity, or collect fees

passing zero will collect fees for the given tick range

Param NameTypeDescription
keyPoolKeyThe key of the pool to modify liquidity in
paramsModifyLiquidityParamsThe parameters for modifying the liquidity position
hookDatabytesAny data to pass to a hook contract on the before/add liquidity hooks

Returns the balance delta for the caller (total of principal and fees) and the fee delta generated in the liquidity range.

swap

function swap(PoolKey memory key, SwapParams memory params, bytes calldata hookData)
external
returns (BalanceDelta);

Executes a swap against the given pool using the provided parameters.

Param NameTypeDescription
keyPoolKeyThe key of the pool to swap in
paramsSwapParamsThe parameters for executing the swap
hookDatabytesAny data to pass to a hook contract on the before/afterSwap hooks

Returns the balance delta for the address initiating the swap. Note swapping on low liquidity pools may cause unexpected amounts. Interacting with certain hooks may also alter the swap amounts.

function donate(PoolKey memory key, uint256 amount0, uint256 amount1, bytes calldata hookData)
external
returns (BalanceDelta);

Donates the specified currency amounts to the pool.

Param NameTypeDescription
keyPoolKeyThe key of the pool to donate to
amount0uint256The amount of token0 to donate
amount1uint256The amount of token1 to donate
hookDatabytesAny data to pass to a hook contract on the before/afterDonate hooks

Returns the balance delta representing the donated amounts.

Helpful?