Contract 91060e9c28257fef68a650d7a1174baa6e46913137f261a3f2da2648329ea7b1

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.11#34f7f53ae31e0fd02aab436a9872e79fa671ca02
rsver 1.97.1

Instances

  • CC6QAV7JEG5MYRSPO5Z65E5G2M4ZB64BEG2ZXIZXL55TQT35JDI2LC6K

Interface

Execute a swap atomically (single-path or split-order).

sub_routes is always a list of legs; a simple swap is one entry with the full amount_in and its hop steps. Split execution uses multiple entries.

Flow:

  1. Pull total input from user (sum of sub-route amounts)
  2. For each sub-route: execute its path with its allocated amount
  3. Sum outputs (all must produce the same token_out)
  4. Verify total output >= min_amount_out
  5. Transfer total output to user
fn swap(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    sub_routes: soroban_sdk::Vec,
    min_amount_out: i128,
) -> i128

Get the admin address.

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

Upgrade the contract WASM code. Only admin can call.

fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
fn is_venue(
    env: soroban_sdk::Env,
    dex_type: DexType,
    dex_id: soroban_sdk::Address,
) -> bool

Register or remove a DEX venue for escrow-backed fills. Public swaps remain open-routed; this registry only protects order escrow calls.

fn set_venue(
    env: soroban_sdk::Env,
    dex_type: DexType,
    dex_id: soroban_sdk::Address,
    allowed: bool,
)

Initialize the contract with an admin address. Must be called once after deployment.

fn initialize(env: soroban_sdk::Env, admin: soroban_sdk::Address)

Round-trip swap: base → bridge (split OK) → base (split OK) in one atomic invocation.

Funds are pulled from user and the final base_token balance is returned to user. The contract does not retain funds after execution.

Parameters

  • leg_out: sub-routes from base_token to bridge_token. Each SubRoute.amount_in is an absolute base-token input; they must sum to amount_in.
  • leg_back: sub-routes from bridge_token to base_token. Each SubRoute.amount_in is a positive weight (quoted bridge amounts are fine). After leg_out produces actual bridge total o1, weights are rescaled so executed inputs sum exactly to o1 (last sub-route receives the remainder). Callers do not need to know o1 at submit time.
  • min_amount_out: minimum total base_token returned (principal + profit floor)

Integrator note

Same SubRoute type for both legs — no extra fields. Semantics of amount_in differ by leg: absolute on leg_out, proportional weight on leg_back.

fn round_trip_swap(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    base_token: soroban_sdk::Address,
    bridge_token: soroban_sdk::Address,
    amount_in: i128,
    leg_out: soroban_sdk::Vec,
    leg_back: soroban_sdk::Vec,
    min_amount_out: i128,
) -> i128

Execute an escrow-backed swap using only administrator-registered venues. The caller must still authorize the escrow as user.

fn swap_restricted(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    sub_routes: soroban_sdk::Vec,
    min_amount_out: i128,
) -> i128

Imports

WebAssembly Text (WAT) ▶