Contract 1cfa6745881012285b11bbc9f246c4752d4db22ae3fcf12c488fef625b993124

← Back to Index 📥 Download WASM

Meta

cliver 26.0.0#60f7458e7ecffddf2f2d91dc6d0d2db4fab03ecc
rssdkver 26.0.1#f52b6aad85f18c5e312ff3f60e57cb613274e6bb
rsver 1.95.0

Instances

  • CAFYUWC2U7GX4DNG6JRZLPYDNXDOLJNHP5RWVAMOTOA5QO75N4B56X45

Interface

Buy tres_amount (share base units) at the current price. Returns the payment cost in stroops. The buyer authorizes both this call and the payment transfer out of their account.

The payment stays in this contract rather than going straight to the treasury: that balance is what the buyback draws on.

fn buy(env: soroban_sdk::Env, buyer: soroban_sdk::Address, tres_amount: i128) -> i128

Sell tres_amount (share base units) back to the contract. Returns the payment received, net of the fee. The seller authorizes both this call and the share transfer out of their account.

Shares return to inventory and become sellable again. The fee goes to the treasury; the rest goes to the seller.

fn sell(env: soroban_sdk::Env, seller: soroban_sdk::Address, tres_amount: i128) -> i128
fn admin(env: soroban_sdk::Env) -> soroban_sdk::Address
fn price(env: soroban_sdk::Env) -> i128

Payment cost (stroops) to buy tres_amount share base units.

fn quote(env: soroban_sdk::Env, tres_amount: i128) -> i128
fn fee_bps(env: soroban_sdk::Env) -> u32
fn treasury(env: soroban_sdk::Env) -> soroban_sdk::Address

Shares still available for sale (contract balance, in base units).

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

Admin: update the sale price (payment-asset stroops per whole share).

fn set_price(env: soroban_sdk::Env, price: i128)
fn auto_allow(env: soroban_sdk::Env) -> bool

Payment received (stroops) for selling tres_amount back, fee deducted. This is the authoritative number to show a seller.

fn quote_sell(env: soroban_sdk::Env, tres_amount: i128) -> i128

Payment asset held by the contract — the buyback float.

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

Admin: update the buyback fee, in basis points (500 = 5%).

fn set_fee_bps(env: soroban_sdk::Env, fee_bps: u32)

Admin: change where fees are sent.

fn set_treasury(env: soroban_sdk::Env, treasury: soroban_sdk::Address)

Admin: withdraw sale proceeds. Whatever is left behind is what remains available for buybacks, so this is the lever that decides how much liquidity the window offers.

fn withdraw_pay(env: soroban_sdk::Env, to: soroban_sdk::Address, amount: i128)

Runs once at deploy.

  • price — payment-asset stroops per one whole share.
  • buyback_price — same unit; 0 closes the buyback window.
  • fee_bps — fee taken on buybacks only, in basis points (500 = 5%).
  • auto_allow — whether to allowlist buyers on the token before delivering shares. Requires this contract to hold the token's admin role. Set it to false for a plain SAC, which has no allowlist.
fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    tres_sac: soroban_sdk::Address,
    pay_sac: soroban_sdk::Address,
    treasury: soroban_sdk::Address,
    price: i128,
    buyback_price: i128,
    fee_bps: u32,
    auto_allow: bool,
)
fn buyback_price(env: soroban_sdk::Env) -> i128

Admin: recover unsold shares from the contract.

fn withdraw_tres(env: soroban_sdk::Env, to: soroban_sdk::Address, amount: i128)

How many share base units the contract can currently buy back, given its payment-asset balance. 0 when the window is closed or unfunded.

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

Admin: update the buyback price. 0 closes the buyback window.

fn set_buyback_price(env: soroban_sdk::Env, buyback_price: i128)

Imports

WebAssembly Text (WAT) ▶