Funded claim (L1-18): transfers the claimable balance from THIS contract's own USDC (push-funded by the market's per-trade pot transfers) to the referrer. If the balance cannot cover it, the claim rejects with ClaimUnfunded and claimable is PRESERVED — an earned balance is never burned. Deliberately not pause-gated (claims are exits).
fn claim(
env: soroban_sdk::Env,
referrer: soroban_sdk::Address,
) -> Result
Delete a referee's binding — future trades accrue nothing to the old referrer (self-referral cluster backstop).
fn unbind(
env: soroban_sdk::Env,
referee: soroban_sdk::Address,
) -> Result<(), ReferralError>
Swap the running WASM in place; codes, bindings and balances are preserved (mirrors the market/vault/router upgrade pattern).
fn upgrade(
env: soroban_sdk::Env,
new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), ReferralError>
fn version(env: soroban_sdk::Env) -> soroban_sdk::Symbol
fn get_info(
env: soroban_sdk::Env,
referrer: soroban_sdk::Address,
) -> Result
fn get_admin(env: soroban_sdk::Env) -> Result
Rotate the admin (R-11: the multisig migration path). Both current and new admin must sign — mirrors the vault/router pattern so a mistyped address can't brick the admin role.
fn set_admin(
env: soroban_sdk::Env,
new_admin: soroban_sdk::Address,
) -> Result<(), ReferralError>
fn get_config(env: soroban_sdk::Env) -> Result<(u32, u32, i128), ReferralError>
fn get_market(env: soroban_sdk::Env) -> Result
One-shot initialisation. The market contract address is the only
principal allowed to call record_trade; usdc_token is what the
funded claim pays out in (L1-18). Discount and share are in basis
points; min_code_volume is the 14-day rolling volume floor needed
to mint a code (cross-read from the market at create_code).
fn initialize(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
market: soroban_sdk::Address,
usdc_token: soroban_sdk::Address,
) -> Result<(), ReferralError>
Re-point at a redeployed market without losing code/referrer state.
fn set_market(
env: soroban_sdk::Env,
market: soroban_sdk::Address,
) -> Result<(), ReferralError>
Pause the registry: record_trade becomes a (0,0) no-op, new codes and bindings reject. Claims stay open (exits are never gated).
fn set_paused(env: soroban_sdk::Env, paused: bool) -> Result<(), ReferralError>
Mint a unique referral code for referrer. Each address can hold
at most one code; codes are case-sensitive 3..=16 char strings.
Volume gating (L1-18/R-3): the referrer's 14-day rolling volume is cross-read from market.get_trader_volume and must be at least MinCodeVolume. Fail-closed: an unreadable market counts as zero volume (admin can set the floor to 0 to disable the gate).
fn create_code(
env: soroban_sdk::Env,
referrer: soroban_sdk::Address,
code: soroban_sdk::String,
) -> Result<(), ReferralError>
Revoke a code's referrer: record_trade accrues (0,0) for them and the code takes no new bindings. Reversible via unrevoke.
fn revoke_code(
env: soroban_sdk::Env,
code: soroban_sdk::String,
) -> Result<(), ReferralError>
Public view: returns the referrer bound to referee, or None.
fn get_referrer(
env: soroban_sdk::Env,
referee: soroban_sdk::Address,
) -> Option
Market-only hook called whenever a fee-bearing event happens. Returns (referee_discount, referrer_payout) — the market applies the discount to the referee's fee and transfers the payout to this contract, which then accrues against the referrer's claimable balance.
For referees with no referrer this is a no-op returning (0, 0) so the market doesn't have to branch.
fn record_trade(
env: soroban_sdk::Env,
referee: soroban_sdk::Address,
original_fee: i128,
volume: i128,
) -> Result<(i128, i128), ReferralError>
fn resolve_code(
env: soroban_sdk::Env,
code: soroban_sdk::String,
) -> Option
Bind a referee to a referrer's code. Single-shot per referee: once bound, the relationship is permanent. Self-referral is rejected. Increments the referrer's referred_count.
fn set_referrer(
env: soroban_sdk::Env,
referee: soroban_sdk::Address,
code: soroban_sdk::String,
) -> Result<(), ReferralError>
fn unrevoke_code(
env: soroban_sdk::Env,
code: soroban_sdk::String,
) -> Result<(), ReferralError>
fn set_usdc_token(
env: soroban_sdk::Env,
usdc: soroban_sdk::Address,
) -> Result<(), ReferralError>
fn set_discount_bps(env: soroban_sdk::Env, bps: u32) -> Result<(), ReferralError>
fn set_min_code_volume(
env: soroban_sdk::Env,
volume: i128,
) -> Result<(), ReferralError>
fn set_referrer_share_bps(env: soroban_sdk::Env, bps: u32) -> Result<(), ReferralError>