Contract db8bf67ae190be073f1c172dfe9f4f7e4c7bf4aa294f82338913cdf2744796fe

← Back to Index πŸ“₯ Download WASM

Meta

cliver 26.1.0#1228cff8022b804659750b94b315932b0e0f3f6a
rssdkver 25.3.1#e50d95af029c83196dd122f0154bac3f1302394b
rsver 1.93.0

Instances

  • CBTO72XLCM2HV2MW64GMGWQB57NQFDXO3BZJTW3Y5ENTXBAJQ7Z7G5FV

Interface

fn admin(env: soroban_sdk::Env) -> soroban_sdk::Address
fn pause(env: soroban_sdk::Env)
fn fee_bps(env: soroban_sdk::Env) -> u32

Set the swap fee (bps) for new trades. Bounded by the on-chain max_fee_bps ceiling.

fn set_fee(env: soroban_sdk::Env, fee_bps: u32)
fn unpause(env: soroban_sdk::Env)

Human-readable semver of the source build (informational; for verifiable identity use [Self::code_hash]).

fn version(env: soroban_sdk::Env) -> soroban_sdk::String
fn maturity(env: soroban_sdk::Env) -> u64

PT price in USDC at SCALAR_12 β€” the curve's exchangeRate at the current pool point. Drifts to par (1.0) as now β†’ maturity.

Read-only and panic-free by contract (mainnet-readiness, AMM hardening): returns a safe 0 fallback for any state where a meaningful price is undefined β€” an empty pool, a pool too thin/imbalanced for the curve (proportion outside the 0.5%…99.5% band), or at/after maturity (no live curve). Integrations/frontends can treat 0 as "no price", never a revert.

fn pt_price(env: soroban_sdk::Env) -> i128
fn pt_token(env: soroban_sdk::Env) -> soroban_sdk::Address

Current pool reserves (pt, usdc).

fn reserves(env: soroban_sdk::Env) -> (i128, i128)
fn timelock(env: soroban_sdk::Env) -> u64

The live deployed WASM hash (32-byte SHA-256) of the running code β€” reflects the current build even across upgrades.

fn code_hash(env: soroban_sdk::Env) -> soroban_sdk::BytesN<32>
fn is_paused(env: soroban_sdk::Env) -> bool

One-shot, admin-gated init (SCF #7). The market is told its PT/USDC SACs and maturity explicitly β€” they must match the wrapper market this pool trades against (the deploy script reads them from the wrapper and passes them here, exactly like the vault's underlying).

  • admin β€” operational admin (sets fee, pauses; cannot move LP funds).
  • pt β€” the Principal Token SAC (a pool reserve).
  • usdc β€” the settlement SAC (the other pool reserve, what PT trades against / redeems into).
  • maturity β€” unix seconds; trading halts at/after it (PT then just redeems 1:1 via wrapper).
  • fee_bps β€” initial swap fee, must be ≀ max_fee_bps.
  • max_fee_bps β€” hard ceiling on any future fee (guardrail).
  • scalar_root β€” curve steepness root (SCALAR_12); rateScalar = scalar_root / yearsToMat. A larger root β‡’ steeper β‡’ less price impact per trade. Set from the target liquidity depth.
  • rate_anchor β€” the curve's anchor (SCALAR_12, USDC per PT at proportion 0.5). Set near the target opening PT pr
fn initialize(
    env: soroban_sdk::Env,
    pt: soroban_sdk::Address,
    usdc: soroban_sdk::Address,
    maturity: u64,
    fee_bps: u32,
    max_fee_bps: u32,
    scalar_root: i128,
    rate_anchor: i128,
)
fn underlying(env: soroban_sdk::Env) -> soroban_sdk::Address

The headline implied APY (SCALAR_12 fraction, e.g. 0.08 = 8%): the annualized return of buying PT now and redeeming at par at maturity, derived from the PT price + time to maturity.

Read-only and panic-free by contract: returns a safe 0 for an empty / thin / imbalanced pool, a pool at/above par, or one at/after maturity. Never reverts or divides by zero.

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

An LP's position: (shares, pt_claim, usdc_claim) β€” their shares and the reserves those shares currently redeem for.

fn lp_position(env: soroban_sdk::Env, lp: soroban_sdk::Address) -> (i128, i128, i128)

Accept a pending admin proposal (step 2 of 2). Must be called by the proposed admin.

fn accept_admin(env: soroban_sdk::Env)

Curve params (scalar_root, rate_anchor) as configured at init (SCALAR_12).

fn curve_config(env: soroban_sdk::Env) -> (i128, i128)
fn set_timelock(env: soroban_sdk::Env, secs: u64)
fn total_shares(env: soroban_sdk::Env) -> i128

Atomic deploy-time constructor (no deploy→init front-run). Binds admin the moment the market exists; the remaining [Self::initialize] is then gated to this admin.

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

Add liquidity: pull pt_in PT and usdc_in USDC from lp into the pool and mint LP shares.

  • First LP sets the pool's price; shares minted = sqrt(pt_in * usdc_in) (Uniswap-V2 style). It defines the initial PT/USDC ratio (the deploy script seeds this near the vault's fixed rate).
  • Later LPs must supply at the pool's current ratio (within a dust tolerance) so they don't move the price or dilute existing LPs; shares minted are proportional to the deposit.

Returns the LP shares minted.

fn add_liquidity(
    env: soroban_sdk::Env,
    lp: soroban_sdk::Address,
    pt_in: i128,
    usdc_in: i128,
) -> i128
fn apply_upgrade(env: soroban_sdk::Env)
fn pending_admin(env: soroban_sdk::Env) -> Option

Propose a new admin (step 1 of 2). Current admin authorizes; the proposed admin must then call accept_admin to take control.

fn propose_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
fn cancel_upgrade(env: soroban_sdk::Env)
fn pending_upgrade(env: soroban_sdk::Env) -> Option

Remove liquidity: burn shares LP shares and return the proportional PT + USDC to lp. Allowed any time (including after maturity, so LPs can always exit). Returns (pt_out, usdc_out).

fn remove_liquidity(
    env: soroban_sdk::Env,
    lp: soroban_sdk::Address,
    shares: i128,
) -> (i128, i128)

Schedule a contract upgrade to wasm_hash, applyable after the timelock. Returns the eta.

fn schedule_upgrade(env: soroban_sdk::Env, wasm_hash: soroban_sdk::BytesN<32>) -> u64

Quote USDC out for a PT-in swap (matches swap_exact_pt_for_usdc exactly).

Read-only and panic-free by contract: returns 0 ("no quote") for any state the swap itself would reject β€” a thin/imbalanced pool, output exceeding reserves, or at/after maturity β€” instead of reverting, so frontends can render "amount exceeds liquidity" from a 0.

fn quote_pt_for_usdc(env: soroban_sdk::Env, pt_in: i128) -> i128

Quote PT out for a USDC-in swap (matches swap_exact_usdc_for_pt exactly). Panic-free; 0 means "no quote" (thin/imbalanced pool, exceeds reserves, or matured).

fn quote_usdc_for_pt(env: soroban_sdk::Env, usdc_in: i128) -> i128

Cancel a pending admin proposal. Current admin only.

fn cancel_admin_transfer(env: soroban_sdk::Env)

Swap exactly pt_in PT for USDC along the curve. Reverts if the USDC out is below min_usdc_out (slippage guard). Trading is halted at/after maturity. Returns USDC out.

fn swap_exact_pt_for_usdc(
    env: soroban_sdk::Env,
    trader: soroban_sdk::Address,
    pt_in: i128,
    min_usdc_out: i128,
) -> i128

Swap exactly usdc_in USDC for PT along the curve. Reverts if the PT out is below min_pt_out (slippage guard). Trading is halted at/after maturity. Returns PT out.

fn swap_exact_usdc_for_pt(
    env: soroban_sdk::Env,
    trader: soroban_sdk::Address,
    usdc_in: i128,
    min_pt_out: i128,
) -> i128

Imports

WebAssembly Text (WAT) β–Ά