Contract b32107d6bbab839395fb35c1bb086e21e025553a1e186cffed0e769fc38a589c

← Back to Index 📥 Download WASM

Meta

rssdkver 27.0.5#ea54f95d3f2f49e0487b29fd1a9f469638f09aba
rsver 1.95.0

Instances

  • CBSF6G7HXYWHXQDGZROJU4MLONCTNZXF7U3LNURUYMWR5B75TZJGAUJW

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

Complete an admin rotation — callable only by the proposed admin, proving the new key is live before it holds power.

fn accept_admin(env: soroban_sdk::Env) -> Result<(), RouterError>

ATOMIC MULTI-HOP: execute a whole path (up to MAX_PATH_HOPS swaps, venues mixed freely per hop) in ONE invocation. One signature; if any hop disappoints, the entire path reverts and the user keeps exactly what they started with. Funds never rest in a wallet between hops, and each hop swaps the previous hop's ACTUAL output (no conservative min-out chaining as with multi-transaction plans).

The protocol fee applies once, on the FINAL output, and min_final_out protects the user net of it.

fn execute_path(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    token_in: soroban_sdk::Address,
    total_amount_in: i128,
    min_final_out: i128,
    hops: soroban_sdk::Vec,
) -> Result

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>

Propose a new admin (two-step rotation). Admin only. The proposed address must call accept_admin to take over, so a mistyped transfer is recoverable until accepted.

fn transfer_admin(
    env: soroban_sdk::Env,
    new_admin: 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) ▶