Contract 5f7bc3f7da81fcaaf721d192bd69377a241fca674f056734ca06295953de5946

← Back to Index 📥 Download WASM

Meta

rssdkver 23.0.2#a97daf8b07cdf24e9bd45e344db51a21b9ea77d3
rsver 1.88.0

Instances

  • CBR7DFVZUKT66D3Z5JEIG75DOFOCUHUPO6LU74BYHXKEPBCYJQFBX2PD

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)
fn init(
    env: soroban_sdk::Env,
    factory: soroban_sdk::Address,
    xlm: soroban_sdk::Address,
    position_manager: 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

Check if the contract is initialized

fn is_initialized(env: soroban_sdk::Env) -> bool

Imports

WebAssembly Text (WAT) ▶