Initialize the Zap Router
factory - DEX factory address (for pool lookups and token ordering)xlm - Native XLM token address (for gas refunds)position_manager - NonFungiblePositionManager address (for NFT minting)swap_router - SwapRouter address (for ALL swaps - single and multi-hop)Zap uses the existing swap-router for ALL swap operations. This means:
fn init(
env: soroban_sdk::Env,
factory: soroban_sdk::Address,
xlm: soroban_sdk::Address,
position_manager: soroban_sdk::Address,
swap_router: soroban_sdk::Address,
) -> Result<(), ZapError>
Zap in with a single token to receive an NFT LP position
token_id - NFT position IDliquidity - Liquidity mintedamount0 - Amount of token0 usedamount1 - Amount of token1 usedfn zap_in(env: soroban_sdk::Env, params: ZapInParams) -> Result
Zap out from an NFT LP position to a single token
NFT burning is NOT supported via zap_out. To burn an NFT after a full exit,
call position_manager.burn(token_id) directly.
amount_out - Total amount of token_out receivedfn zap_out(
env: soroban_sdk::Env,
params: ZapOutParams,
) -> Result
Quote a zap in operation (no state changes)
Estimated liquidity, amounts, and optimal swap split
fn quote_zap_in(
env: soroban_sdk::Env,
params: QuoteZapInParams,
) -> Result
Quote a zap out operation (no state changes)
Estimated output amount after swaps
fn quote_zap_out(
env: soroban_sdk::Env,
params: QuoteZapOutParams,
) -> Result
Get the factory address
fn get_factory(env: soroban_sdk::Env) -> Result
Get the XLM address
fn get_xlm_address(env: soroban_sdk::Env) -> Result
Get the position manager address
fn get_position_manager(
env: soroban_sdk::Env,
) -> Result
Get the swap router address
fn get_swap_router(env: soroban_sdk::Env) -> Result
Check if the contract is initialized
fn is_initialized(env: soroban_sdk::Env) -> bool