Contract 87f3d83666228cc5f69b1b21a99b9236411d212dbced35dfb616232b02ab0bf8

← Back to Index 📥 Download WASM

Meta

cliver 27.1.0#8e402ea28202950b272fbabc34caad4d2f64fe87
rssdkver 27.0.0#e5cb4b52c3da8e56fc48adfd7b85d85976c1a059
rsver 1.97.1

Instances

  • CDPPM2LRO3RRO3TGP7NYTWPD2EPEJIJ6S6QHESMZCC5LSOPAZJRFCDZO

Interface

Read AMM protocol identifier

fn name(env: soroban_sdk::Env) -> soroban_sdk::String

Read pool reserves for market

fn get_pool(env: soroban_sdk::Env, market_id: u64) -> PoolReserves

Initialize the AMM contract with admin and default fee in BPS (e.g. 30 = 0.3%)

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

Calculate shares received for a buy order under constant-product formula (x*y=k) Also returns protocol fee and estimated price impact in BPS

fn calculate_buy(
    env: soroban_sdk::Env,
    yes_reserves: i128,
    no_reserves: i128,
    payment: i128,
    is_yes: bool,
    fee_bps: u32,
) -> (i128, i128, u32)

Calculate collateral payout for a sell order

fn calculate_sell(
    env: soroban_sdk::Env,
    yes_reserves: i128,
    no_reserves: i128,
    shares: i128,
    is_yes: bool,
    fee_bps: u32,
) -> (i128, i128)

Calculate outcome probability in BPS (0 to 10,000 basis points) Price of YES = no_reserves / (yes_reserves + no_reserves) * 10000

fn calculate_price(
    env: soroban_sdk::Env,
    yes_reserves: i128,
    no_reserves: i128,
    is_yes: bool,
) -> u32

Imports

WebAssembly Text (WAT) ▶