Contract e72dca18bdeb7fd4e5980fcc679bf857fbcd2e0d2894676c564b6a81e2a28df8

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.11#34f7f53ae31e0fd02aab436a9872e79fa671ca02
rsver 1.89.0

Instances

  • CCHM7Q7YSTQ4KCHKQS7HJKI5ZZWEPGQRLE4YSVCVZ3DYCTNHXPZ5KFFJ

Interface

One-time setup. Records the admin and the escrow token (a SAC address, e.g. the native XLM contract), zeroes the aggregates, unpauses.

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

Deposit amount of the pool token. The same authorization that the saver gives covers the inner SAC transfer(saver -> contract).

Returns the saver's new total principal.

fn deposit(
    env: soroban_sdk::Env,
    saver: soroban_sdk::Address,
    amount: i128,
) -> Result

Withdraw amount of principal back to the saver. Always available — this is the no-loss guarantee: a saver can reclaim up to their full principal at any time, regardless of draws. A draw never reduces principal.

Returns the saver's remaining principal.

fn withdraw(
    env: soroban_sdk::Env,
    saver: soroban_sdk::Address,
    amount: i128,
) -> Result

Add amount of the token to the prize the next draw pays out. Anyone may fund the prize (the admin, a sponsor, or a yield-routing account); the funder authorizes the inner transfer into the contract.

Returns the new prize-pool balance.

fn fund_prize(
    env: soroban_sdk::Env,
    funder: soroban_sdk::Address,
    amount: i128,
) -> Result

Admin-only draw. Picks ONE winner, weighted by principal, using the on-chain PRNG, and transfers the entire prize pool to them. Principal is untouched — only the prize moves. Returns the winning address.

fn draw(env: soroban_sdk::Env) -> Result
fn principal_of(env: soroban_sdk::Env, saver: soroban_sdk::Address) -> i128
fn total_principal(env: soroban_sdk::Env) -> i128
fn prize_pool(env: soroban_sdk::Env) -> i128
fn total_savers(env: soroban_sdk::Env) -> u32
fn savers(env: soroban_sdk::Env) -> soroban_sdk::Vec
fn draw_count(env: soroban_sdk::Env) -> u32
fn last_winner(env: soroban_sdk::Env) -> Option
fn last_prize(env: soroban_sdk::Env) -> i128
fn is_paused(env: soroban_sdk::Env) -> bool
fn get_admin(env: soroban_sdk::Env) -> Result
fn get_token(env: soroban_sdk::Env) -> Result
fn pause(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn unpause(env: soroban_sdk::Env) -> Result<(), soroban_sdk::Error>
fn set_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Imports

WebAssembly Text (WAT) ▶