Contract 1400833dffad8232baca9f5e0a85320ebf2cb3e8a474842c611d4295ee48e598

← Back to Index 📥 Download WASM

Meta

rssdkver 23.0.2#a97daf8b07cdf24e9bd45e344db51a21b9ea77d3
rsver 1.88.0

Instances

  • CAWICHYVJ77SNJS2FJRZCNUHCMXDT52FZJ5NLD24WTF7TANZ6UDTK62Y

Interface

Initialize the Zap Router

Arguments

  • 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)

Note on Router Architecture

Zap uses the existing swap-router for ALL swap operations. This means:

  • swap-router remains the authorized router (no changes needed)
  • Zap does NOT need to be authorized as a router
  • No duplication of swap/multi-hop logic
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

Flow

  1. Transfer token_in from sender to zap contract
  2. Calculate optimal split (or use hint)
  3. Execute swaps to acquire pool tokens
  4. Mint NFT position via position manager
  5. Refund any dust to sender

Returns

  • token_id - NFT position ID
  • liquidity - Liquidity minted
  • amount0 - Amount of token0 used
  • amount1 - Amount of token1 used
fn zap_in(env: soroban_sdk::Env, params: ZapInParams) -> Result

Zap out from an NFT LP position to a single token

Flow

  1. Decrease liquidity on position
  2. Collect tokens + accrued fees
  3. Swap all to desired output token
  4. Transfer to recipient

Note

NFT burning is NOT supported via zap_out. To burn an NFT after a full exit, call position_manager.burn(token_id) directly.

Returns

  • amount_out - Total amount of token_out received
fn zap_out(
    env: soroban_sdk::Env,
    params: ZapOutParams,
) -> Result

Quote a zap in operation (no state changes)

Returns

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)

Returns

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

Imports

WebAssembly Text (WAT) ▶