WarpX V3 Pool
The WarpX V3 Pool contract manages concentrated liquidity positions and enables token swaps for a specific token pair and fee tier.
Pool Initialization
function initialize(uint160 sqrtPriceX96) externalSets the initial price for the pool. Must be called before any liquidity can be added or swaps executed.
Price is represented as sqrt(amountToken1/amountToken0) in Q64.96 format.
Parameters:
sqrtPriceX96
uint160
Initial sqrt price as a Q64.96 value
Example:
// Initialize pool with 1:1 price ratiouint160 sqrtPrice = 79228162514264337593543950336; // sqrt(1) * 2^96pool.initialize(sqrtPrice);Adding Liquidity
function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data) external returns (uint256 amount0, uint256 amount1)Adds liquidity for a given position. Your contract must implement IUniswapV3MintCallback to provide tokens.
Parameters:
recipient
address
Position owner address
tickLower
int24
Lower tick of the position
tickUpper
int24
Upper tick of the position
amount
uint128
Amount of liquidity to mint
data
bytes
Data passed to the callback
Returns: Token amounts required (amount0, amount1)
Example:
Removing Liquidity
Removes liquidity from a position owned by msg.sender.
Parameters:
tickLower
int24
Lower tick of the position
tickUpper
int24
Upper tick of the position
amount
uint128
Amount of liquidity to burn
Returns: Token amounts withdrawn (amount0, amount1)
Note: Fees are not automatically collected. Use collect() to withdraw fees.
Collecting Fees
Collects fees and tokens owed to a position owned by msg.sender.
Parameters:
recipient
address
Address to receive tokens
tickLower
int24
Lower tick of the position
tickUpper
int24
Upper tick of the position
amount0Requested
uint128
Max token0 to collect (use type(uint128).max for all)
amount1Requested
uint128
Max token1 to collect (use type(uint128).max for all)
Returns: Actual amounts collected (amount0, amount1)
Example:
Swapping Tokens
Swaps tokens in the pool. Your contract must implement IUniswapV3SwapCallback to provide input tokens.
Parameters:
recipient
address
Address to receive output tokens
zeroForOne
bool
true = swap token0 for token1, false = swap token1 for token0
amountSpecified
int256
Positive = exact input, Negative = exact output
sqrtPriceLimitX96
uint160
Price limit as Q64.96 (0 = no limit)
data
bytes
Data passed to the callback
Returns: Token deltas (amount0, amount1) - negative = tokens sent out, positive = tokens received
Example:
Flash Loans
Borrow tokens from the pool and repay within the same transaction. Your contract must implement IUniswapV3FlashCallback.
Parameters:
recipient
address
Address to receive borrowed tokens
amount0
uint256
Amount of token0 to borrow
amount1
uint256
Amount of token1 to borrow
data
bytes
Data passed to the callback
Pool State Queries
Current Price & Tick
Returns the current pool state including price and tick.
Liquidity
Returns the currently in-range liquidity.
Position Information
Returns information about a position. The key is: keccak256(abi.encodePacked(owner, tickLower, tickUpper))
Tick Information
Returns detailed information about a specific tick.
Last updated