Contract 03b59a0639399f8b33a6b6f9f03dc897adcb2d4abddbb113e3acf6adefdae2ba

← Back to Index 📥 Download WASM

Meta

rssdkver 25.1.1#94c2a3b3a5ded6b9cf9cef0c207bf8804f3eb294
rsver 1.84.0

Instances

  • CCK2RLE7LRB5FNVF5WKHE7POPNJ2GCHTBUSOAZIAXX73JMA3PM4OTEFN
  • CDNU27HDJIFMOTFFRN6GKUTPTKGX7JXABX3LXZM25KVB2JUUGD7SCHOQ

Interface

Initialize the contract with swap manager address, fee token (native XLM), and admin

fn __constructor(
    env: soroban_sdk::Env,
    swap_manager: soroban_sdk::Address,
    fee_token: soroban_sdk::Address,
    min_fee_reserve: i128,
    admin: soroban_sdk::Address,
)

Set the paused state (admin only) When paused, order execution is blocked but cancellation is allowed

fn set_paused(env: soroban_sdk::Env, paused: bool)

Check if contract is paused

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

Get admin address

fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address

Create a new TWAP order

fn create_twap_order(
    env: soroban_sdk::Env,
    vault: soroban_sdk::Address,
    owner: soroban_sdk::Address,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    total_amount: i128,
    num_chunks: u32,
    interval_seconds: u64,
    min_price: i128,
    max_price: i128,
    fee_reserve_amount: i128,
) -> u64

Create a new VWAP order VWAP executes based on market volume - larger chunks when volume is high vwap_params contains: min_chunk_size, max_chunk_size, participation_rate_bps, min_interval_seconds

fn create_vwap_order(
    env: soroban_sdk::Env,
    vault: soroban_sdk::Address,
    owner: soroban_sdk::Address,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    total_amount: i128,
    vwap_params: VwapParams,
    min_price: i128,
    max_price: i128,
    fee_reserve_amount: i128,
) -> u64

Execute the next chunk of an order (for TWAP orders) For VWAP orders, use execute_vwap_order instead

fn execute_order(
    env: soroban_sdk::Env,
    order_id: u64,
    keeper: soroban_sdk::Address,
) -> i128

Execute a VWAP order chunk with volume-weighted sizing market_volume: Current market volume (from keeper's off-chain data) The chunk size is calculated as: min(max_chunk, max(min_chunk, volume * participation_rate))

fn execute_vwap_order(
    env: soroban_sdk::Env,
    order_id: u64,
    keeper: soroban_sdk::Address,
    market_volume: i128,
) -> i128

Cancel an active order

fn cancel_order(env: soroban_sdk::Env, order_id: u64, owner: soroban_sdk::Address)

Get order details

fn get_order(env: soroban_sdk::Env, order_id: u64) -> Order

Check if TWAP order can be executed For VWAP orders, use can_execute_vwap

fn can_execute(env: soroban_sdk::Env, order_id: u64) -> bool

Check if VWAP order can be executed Returns true if order is active, has remaining amount, and min interval has passed

fn can_execute_vwap(env: soroban_sdk::Env, order_id: u64) -> bool

Get the current order counter (total number of orders ever created)

fn get_order_counter(env: soroban_sdk::Env) -> u64

Get all active order IDs (for keeper efficiency)

fn get_active_order_ids(env: soroban_sdk::Env) -> soroban_sdk::Vec

Imports

WebAssembly Text (WAT) ▶