Contract 0f07a598439581a0fc5990d4d1cbc4e2b7447109c505295ad9f7268790028cbf

← Back to Index 📥 Download WASM

Meta

cliver 25.2.0#28484880988199233a7e8e87c97cb12dac323cb3
rssdkver 25.3.0#dcbea44513feb7734af6b6c4aced2c4a7a2715d0
rsver 1.86.0

Interface

Initialize the per-offer settlement contract. Called once after deployment.

admin: issuer public key (SAC admin for clawback authority). usdc_sac: USDC SAC contract address. token_sac: security token SAC contract address. treasury: platform treasury for fee routing. max_fee_bps: maximum platform fee in basis points (200 = 2%). Immutable after init. Enforced in settle_batch().

fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    usdc_sac: soroban_sdk::Address,
    token_sac: soroban_sdk::Address,
    treasury: soroban_sdk::Address,
    max_fee_bps: u32,
) -> Result<(), SettleError>

Company deposits USDC into this settlement contract. Depositor signs via passkey (C... smart wallet). Multiple deposits from the same depositor accumulate (checked_add).

fn deposit(
    env: soroban_sdk::Env,
    depositor: soroban_sdk::Address,
    amount: i128,
) -> Result<(), SettleError>

Atomically settle a batch of investors:

  1. Validate: no duplicates, no phantom investors
  2. USDC → each investor (payout)
  3. Read on-chain token balance → clawback ALL (burn)
  4. USDC → treasury (aggregated fee)

TRUSTLESS: Clawback is automatic. The contract reads each investor's token balance from the chain and burns ALL of it. No backend input needed for burns — the public ledger is the source of truth.

MULTI-BATCH: Can be called multiple times with different investor sets. Per-investor idempotency prevents double-payouts across batches.

fn settle_batch(
    env: soroban_sdk::Env,
    items: soroban_sdk::Vec,
    total_fee: i128,
) -> Result<(), SettleError>

Admin withdraws any token from the contract (emergency recovery).

fn withdraw(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    amount: i128,
    to: soroban_sdk::Address,
) -> Result<(), SettleError>

Admin refunds a depositor's USDC. Blocked after settlement (V-1). Only callable by admin (not depositor) to prevent company self-refund attack.

fn refund(
    env: soroban_sdk::Env,
    depositor: soroban_sdk::Address,
) -> Result<(), SettleError>

Upgrade contract WASM. Admin only (high-privilege). Intentionally NOT pause-gated — upgrade is the recovery path when a pause has been triggered to contain a bug.

fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)

Pause the contract. Admin-only. Blocks deposit/settle/withdraw/refund. Upgrade and accept_admin remain accessible (recovery paths).

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

Resume the contract. Admin-only.

fn resume(env: soroban_sdk::Env) -> Result<(), SettleError>

Step 1 of admin rotation: current admin proposes a new admin. The new admin must then call accept_admin() to take ownership. Overwrites any prior pending proposal.

fn propose_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), SettleError>

Step 2 of admin rotation: pending admin accepts ownership. The pending admin must sign — proves they hold the keypair (prevents transfer-to-typo'd-address footgun).

fn accept_admin(env: soroban_sdk::Env) -> Result<(), SettleError>

Returns whether the contract is paused.

fn get_paused(env: soroban_sdk::Env) -> bool

Returns the currently active admin.

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

Returns the pending admin if one has been proposed.

fn get_pending_admin(env: soroban_sdk::Env) -> Option

Extend contract instance TTL. Anyone can call (allows cron jobs).

fn extend_ttl(env: soroban_sdk::Env)

Read: contract's USDC balance.

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

Read: deposit amount for a specific depositor.

fn get_deposit(env: soroban_sdk::Env, depositor: soroban_sdk::Address) -> i128

Returns the contract version.

fn version(env: soroban_sdk::Env) -> u32

Imports

WebAssembly Text (WAT) ▶