Contract 95a9b8b4f76635b83def36c59821ac2967fad454b4a1c3f67509e02a86228c2e

← Back to Index 📥 Download WASM

Meta

rssdkver 27.0.5#ea54f95d3f2f49e0487b29fd1a9f469638f09aba
rsver 1.95.0

Instances

  • CDY6O3L2D4FVJCCW3MBO76ZYKNZXNKCVB4JRXXIWJJSXHA2VE4SSZDXK

Interface

Simple single-venue swap. Backend picks the best venue.

fn swap(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    amount_in: i128,
    min_amount_out: i128,
    venue_id: u32,
) -> Result

Current protocol fee as (numerator, denominator).

fn get_fee(env: soroban_sdk::Env) -> (i128, i128)

Set the protocol fee (per 100,000 of total output). Admin only, hard-capped at MAX_FEE_PER_100K (0.5 bps); 0 is valid (fee holiday).

fn set_fee(env: soroban_sdk::Env, fee_per_100k: i128) -> Result<(), RouterError>

Get the contract address for a venue.

fn get_venue(
    env: soroban_sdk::Env,
    venue_id: u32,
) -> Result

Get all registered venue IDs.

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

Remove a venue. Admin only.

fn remove_venue(env: soroban_sdk::Env, venue_id: u32) -> Result<(), RouterError>

Deploy-time constructor — atomic with deployment, cannot be front-run.

fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    fee_vault: soroban_sdk::Address,
    swap_book: soroban_sdk::Address,
)

Execute a multi-venue routed swap for user.

Verifies: segments are positive and sum to total_amount_in; every venue exists; net output (after the 0.5 bps protocol fee on the TOTAL output) meets min_total_out — otherwise the whole tx reverts.

fn execute_route(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    total_amount_in: i128,
    min_total_out: i128,
    segments: soroban_sdk::Vec,
) -> Result

Register a new DEX venue adapter. Admin only.

fn register_venue(
    env: soroban_sdk::Env,
    venue_id: u32,
    contract_address: soroban_sdk::Address,
) -> Result<(), RouterError>

PERMISSIONLESS keeper entry point: route a timer-expired SwapBook order through DEX venues and settle the maker — all in one invocation.

  1. Claims the order from SwapBook (escrow moves to this contract; SwapBook authorizes us via invoker auth and returns the maker's on-chain price floor min_out).
  2. Executes the provided route segments.
  3. Deducts the protocol fee, enforces net proceeds >= min_out, and pays the maker.

Anyone may call this — a caller gains nothing (proceeds always go to the maker) and a bad route simply reverts, leaving the order claimable again... (revert restores the order's Open state too).

fn route_expired_order(
    env: soroban_sdk::Env,
    order_id: u64,
    segments: soroban_sdk::Vec,
) -> Result

execute_route with an integrator partner fee carved from the output ON TOP of the protocol fee — the partner's cut never comes out of protocol revenue, and min_total_out protects the user net of BOTH fees. partner_fee_per_100k is capped at 100 bps.

fn execute_route_partner(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    total_amount_in: i128,
    min_total_out: i128,
    segments: soroban_sdk::Vec,
    partner: soroban_sdk::Address,
    partner_fee_per_100k: i128,
) -> Result

Imports

WebAssembly Text (WAT) ▶