Contract 15d9219170f69cc712fc210ae265326b990b0c67d3e9c727ecd3522c7318e5c7

← Back to Index 📥 Download WASM

Meta

rssdkver 21.7.7#5da789c50b18a4c2be53394138212fed56f0dfc4
rsver 1.97.0

Instances

  • CDF7WEJI4PT7BMMGNUICOPIZ5QU4JDVC34ENCCMT7OCCNLBW253ZJBHO

Interface

Execute a swap: token_in → token_out with slippage protection

fn swap(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    token_in: soroban_sdk::Address,
    amount_in: i128,
    min_out: i128,
) -> Result

Update pool fee rate (admin only)

fn set_fee(env: soroban_sdk::Env, fee_bps: u32) -> Result<(), SwapError>

Get spot price of token_a in terms of token_b (scaled by 1e7)

fn get_price(
    env: soroban_sdk::Env,
    token_a: soroban_sdk::Address,
    token_b: soroban_sdk::Address,
) -> Result

Preview swap output without executing

fn get_quote(
    env: soroban_sdk::Env,
    token_in: soroban_sdk::Address,
    amount_in: i128,
) -> Result

Transfer admin role

fn set_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), SwapError>

Initialize the AMM with admin

fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
) -> Result<(), SwapError>

Get LP share balance for a user

fn lp_balance(env: soroban_sdk::Env, user: soroban_sdk::Address) -> i128

Create a new liquidity pool (admin only)

fn create_pool(
    env: soroban_sdk::Env,
    token_a: soroban_sdk::Address,
    token_b: soroban_sdk::Address,
    fee_bps: u32,
) -> Result<(), SwapError>

Withdraw accumulated protocol fees (admin only)

fn collect_fees(env: soroban_sdk::Env) -> Result<(i128, i128), SwapError>

Get current pool reserves

fn get_reserves(env: soroban_sdk::Env) -> Result<(i128, i128), SwapError>

Get total LP shares outstanding

fn total_shares(env: soroban_sdk::Env) -> i128

Add liquidity: deposit token_a and token_b, receive LP shares

fn add_liquidity(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    amount_a: i128,
    amount_b: i128,
) -> Result

Get accumulated swap fees

fn accumulated_fees(env: soroban_sdk::Env) -> Result<(i128, i128), SwapError>

Remove liquidity: burn LP shares, receive proportional token_a + token_b

fn remove_liquidity(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    shares: i128,
) -> Result<(i128, i128), SwapError>

Imports

WebAssembly Text (WAT) ▶