Contract de0e67cd70cb295d999b3a3b29f0f366aa2d159ce0a2d8755eee8b2879b44fc6

← Back to Index 📥 Download WASM

Meta

cliver 26.1.0#1228cff8022b804659750b94b315932b0e0f3f6a
rssdkver 27.0.6#60926a20d1f9f0a669d5fe551636f42a1302f0c0
rsver 1.96.0

Instances

  • CASLGK7OGQBATSXXIFUCHU5GU2ERDYOYBYDF5DBWB4YDDRHNVZLHSZQP

Interface

Halts all four swaps and add_liquidity. Guardian or admin.

remove_liquidity is deliberately never blocked: an LP must always be able to withdraw. Quotes stay readable too, so a paused market is still legible rather than opaque.

fn pause(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn state(env: soroban_sdk::Env) -> Result

Moves a non-protocol token out of the pool. PT and SY are refused: they are the reserves.

fn sweep(
    env: soroban_sdk::Env,
    token_id: soroban_sdk::Address,
    to: soroban_sdk::Address,
) -> Result
fn config(env: soroban_sdk::Env) -> Result
fn unpause(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn bump_ttl(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn guardian(env: soroban_sdk::Env) -> Result
fn maturity(env: soroban_sdk::Env) -> u64
fn spot_apy(env: soroban_sdk::Env) -> Result
fn total_lp(env: soroban_sdk::Env) -> Result
fn twap_apy(env: soroban_sdk::Env) -> Result
fn is_paused(env: soroban_sdk::Env) -> bool
fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    pt_token: soroban_sdk::Address,
    sy_token: soroban_sdk::Address,
    yt_token: soroban_sdk::Address,
    tokenizer: soroban_sdk::Address,
    maturity: u64,
    scalar_root: i128,
    initial_anchor: i128,
    fee_bps: i128,
    twap_window: u64,
) -> Result<(), soroban_sdk::Error>
fn lp_balance(
    env: soroban_sdk::Env,
    holder: soroban_sdk::Address,
) -> Result

PT backing the curve. This is accounted state, not balanceOf(amm): tokens donated straight to this contract are deliberately excluded, so nobody can move the curve by transferring to it.

fn reserve_pt(env: soroban_sdk::Env) -> Result

SY backing the curve. Same accounting rule as reserve_pt.

fn reserve_sy(env: soroban_sdk::Env) -> Result
fn bump_lp_ttl(
    env: soroban_sdk::Env,
    holder: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>
fn implied_apy(env: soroban_sdk::Env) -> i128
fn accept_admin(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn is_renounced(env: soroban_sdk::Env) -> bool
fn set_guardian(
    env: soroban_sdk::Env,
    guardian: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>
fn add_liquidity(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    pt_in: i128,
    sy_in: i128,
    min_lp_out: i128,
) -> i128
fn pending_admin(env: soroban_sdk::Env) -> Option
fn propose_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>
fn cancel_upgrade(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn renounce_admin(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn swap_pt_for_sy(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    pt_in: i128,
    min_sy_out: i128,
) -> i128
fn swap_sy_for_pt(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    sy_in: i128,
    min_pt_out: i128,
) -> i128
fn swap_sy_for_yt(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    sy_in: i128,
    min_yt_out: i128,
) -> i128
fn swap_yt_for_sy(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    yt_in: i128,
    min_sy_out: i128,
) -> i128
fn execute_upgrade(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn pending_upgrade(env: soroban_sdk::Env) -> Option<(soroban_sdk::BytesN<32>, u64)>
fn propose_upgrade(
    env: soroban_sdk::Env,
    wasm_hash: soroban_sdk::BytesN<32>,
) -> Result
fn quote_pt_for_sy(
    env: soroban_sdk::Env,
    pt_in: i128,
) -> Result
fn quote_sy_for_pt(
    env: soroban_sdk::Env,
    sy_in: i128,
) -> Result
fn quote_sy_for_yt(
    env: soroban_sdk::Env,
    sy_in: i128,
) -> Result
fn quote_yt_for_sy(
    env: soroban_sdk::Env,
    yt_in: i128,
) -> Result
fn twap_warming_up(env: soroban_sdk::Env) -> Result
fn remove_liquidity(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    lp_in: i128,
    min_pt_out: i128,
    min_sy_out: i128,
) -> (i128, i128)

Routes share_bps of the swap fee (not of the trade) to treasury.

Ships at 0, so launch economics are byte-identical to having no switch at all. It exists because the alternative — adding it later — is impossible once governance is renounced, and a protocol with no revenue path is not a business. Capped at 50% of the fee so LPs always keep the majority of what they earn.

fn set_protocol_fee(
    env: soroban_sdk::Env,
    share_bps: i128,
    treasury: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

(pt, sy) this contract custodies beyond what backs the curve — donations, and any token sent here by mistake. Always >= 0 in a healthy market; a negative value would mean custody is short of the reserves the curve believes it has, so it is surfaced rather than saturated.

fn untracked_balance(env: soroban_sdk::Env) -> Result<(i128, i128), soroban_sdk::Error>

(pt_out, sy_used) for an exact-SY-in PT buy. sy_used <= sy_in, and sy_used is what the swap will actually debit — the solver is bounded by the curve, so past the saturation point extra input buys nothing and is simply not charged. Callers should surface sy_used and warn when it is materially below sy_in, because that means the market cannot absorb the requested size.

fn quote_sy_for_pt_cost(
    env: soroban_sdk::Env,
    sy_in: i128,
) -> Result<(i128, i128), soroban_sdk::Error>

(yt_out, sy_used) for an exact-SY-in YT buy. Same contract as quote_sy_for_pt_cost: sy_used is the shortfall the pool cannot fund from selling the PT leg into its own curve, and is exactly what the swap will debit.

fn quote_sy_for_yt_cost(
    env: soroban_sdk::Env,
    sy_in: i128,
) -> Result<(i128, i128), soroban_sdk::Error>
fn protocol_fees_accrued(env: soroban_sdk::Env) -> i128
fn protocol_fee_share_bps(env: soroban_sdk::Env) -> i128

Pays accrued protocol fees out to the treasury. Treasury-authorized, so a compromised admin cannot redirect an already-accrued balance.

fn withdraw_protocol_fees(env: soroban_sdk::Env) -> Result

Imports

WebAssembly Text (WAT) ▶