Contract 41bc83102ce89d3fede0bbc2c3895476e9a0a544a48b1d3f2abf0a0107352638

← Back to Index 📥 Download WASM

Meta

cliver 25.2.0#28484880988199233a7e8e87c97cb12dac323cb3
rssdkver 26.1.0#175aa41306f383057a8cdfc84b68d931664fc34e
rsver 1.94.0

Instances

  • CA3H4LATX6RHXBW2QM65MBUORBEWIGWMOVMGTF7SGRX5ZQNW22PMYJHJ
  • CACZ2KDZYQXJGWJD7SMJBWGUM5J44SHJQIXC26OOAXJQHD5XA3FSGMNY

Interface

Execute a swap: transfer token_out from router reserves to recipient.

The caller must have already transferred amount_in of token_in to this contract before calling swap (the pool contract does this).

fn swap(
    env: soroban_sdk::Env,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    amount_in: i128,
    min_amount_out: i128,
    recipient: soroban_sdk::Address,
) -> i128

Set the exchange rate for a token pair. rate_bps is in basis points: 10000 = 1:1, 1200 = 0.12:1.

fn set_rate(
    env: soroban_sdk::Env,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    rate_bps: i128,
)

Initialize the swap router with an admin address.

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

Calculate the output amount for a given input.

fn get_amount_out(
    env: soroban_sdk::Env,
    token_in: soroban_sdk::Address,
    token_out: soroban_sdk::Address,
    amount_in: i128,
) -> i128

Imports

WebAssembly Text (WAT) ▶