Contract ec370360bb200c46ad7ca069acacf46ee490fa693c56e4bae183e70f705fdcdd

← Back to Index 📥 Download WASM

Meta

cliver 23.4.1#a152ec2488c25136808ad28277c24b3a0765ffd4
rssdkver 23.5.3#d3e1ab2424388b10893b796b0c8e405c5edd03d2
rsver 1.92.0

Instances

  • CBOJQMXGM3YEMYHVYYJCGTOICDYAHZPYMNRA5S22IUZ32DEHT4QPE6LO

Interface

fn pause(env: soroban_sdk::Env, paused: bool) -> Result<(), DikeError>
fn redeem(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    market_id: u64,
    final_outcome: Outcome,
    redeemed_outcome: Outcome,
    amount: i128,
) -> Result
fn upgrade(
    env: soroban_sdk::Env,
    new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), DikeError>
fn redeemed(
    env: soroban_sdk::Env,
    market_id: u64,
    user: soroban_sdk::Address,
    outcome: Outcome,
) -> i128
fn set_role(
    env: soroban_sdk::Env,
    role: soroban_sdk::Symbol,
    module: soroban_sdk::Address,
) -> Result<(), DikeError>
fn lock_bond(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    request_id: u64,
    market_id: u64,
    amount: i128,
    is_dispute: bool,
) -> Result<(), DikeError>
fn set_admin(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
) -> Result<(), DikeError>
fn accounting(env: soroban_sdk::Env, market_id: u64) -> VaultAccounting
fn child_debt(
    env: soroban_sdk::Env,
    child_market_id: u64,
    user: soroban_sdk::Address,
) -> i128
fn root_stake(
    env: soroban_sdk::Env,
    market_id: u64,
    user: soroban_sdk::Address,
    outcome: Outcome,
) -> i128
fn slash_bond(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    request_id: u64,
    amount: i128,
    is_dispute: bool,
    recipient: soroban_sdk::Address,
) -> Result<(), DikeError>
fn collect_fee(
    env: soroban_sdk::Env,
    market_id: u64,
    lp_fee: i128,
    protocol_fee: i128,
    cod_fee: i128,
) -> Result<(), DikeError>
fn parent_debt(
    env: soroban_sdk::Env,
    parent_market_id: u64,
    user: soroban_sdk::Address,
    outcome: Outcome,
) -> i128
fn child_parent(
    env: soroban_sdk::Env,
    child_market_id: u64,
    user: soroban_sdk::Address,
) -> u64
fn release_bond(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    request_id: u64,
    amount: i128,
    is_dispute: bool,
) -> Result<(), DikeError>
fn set_treasury(
    env: soroban_sdk::Env,
    treasury: soroban_sdk::Address,
) -> Result<(), DikeError>
fn user_deposit(
    env: soroban_sdk::Env,
    market_id: u64,
    user: soroban_sdk::Address,
) -> i128
fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    treasury: soroban_sdk::Address,
)
fn claim_lp_fees(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    market_id: u64,
    lp: soroban_sdk::Address,
    amount: i128,
) -> Result<(), DikeError>
fn redeem_resolved(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    market_id: u64,
    redeemed_outcome: Outcome,
    amount: i128,
) -> Result

Every child market a given parent+user+outcome stake has drawn credit into. Lets keepers discover liquidation targets on-chain instead of relying on off-chain event indexing (and an incomplete keeper-supplied list stranding debt).

fn child_markets_of(
    env: soroban_sdk::Env,
    parent_market_id: u64,
    user: soroban_sdk::Address,
    outcome: Outcome,
) -> soroban_sdk::Vec
fn redeem_cancelled(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    market_id: u64,
    redeemed_outcome: Outcome,
    amount: i128,
) -> Result
fn insurance_reserve(env: soroban_sdk::Env) -> i128

Called by the AMM's liquidate_position after it force-sells a user's entire parent-outcome balance (a normal sell() would call release_trade_payout here and pay proceeds straight to the seller — this is the liquidation variant: extract proceeds from the parent's backing exactly like a normal sale would, then instead of paying the user, route it through debt settlement first).

Order: liquidator bonus is taken off the top of proceeds so a keeper always gets paid for a valid call regardless of how underwater the position is (otherwise nobody would bother liquidating the worst positions — exactly the ones most urgent to close). What's left pays down debt across every market in child_markets_of, in list order, via settle_child_debt (which restores the parent's own backing as each debt gets repaid). Any remainder after that goes to the user. Whatever debt survives because proceeds ran short is handed to resolve_parent_default — same insurance-then-shortfall path a resolution-time default wo

fn liquidate_release(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    liquidator: soroban_sdk::Address,
    parent_market_id: u64,
    parent_outcome: Outcome,
    tokens_sold: i128,
    proceeds: i128,
) -> Result
fn record_cash_stake(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    market_id: u64,
    outcome: Outcome,
    collateral_in: i128,
    tokens_out: i128,
) -> Result<(), DikeError>
fn deposit_for_market(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    market_id: u64,
    amount: i128,
) -> Result<(), DikeError>
fn sweep_protocol_fees(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    market_id: u64,
) -> Result
fn child_parent_outcome(
    env: soroban_sdk::Env,
    child_market_id: u64,
    user: soroban_sdk::Address,
) -> Outcome
fn release_trade_payout(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    market_id: u64,
    outcome: Outcome,
    tokens_sold: i128,
    payout: i128,
) -> Result<(), DikeError>
fn child_collateral_loan(
    env: soroban_sdk::Env,
    parent_market_id: u64,
    child_market_id: u64,
    user: soroban_sdk::Address,
) -> i128
fn child_collateral_used(
    env: soroban_sdk::Env,
    parent_market_id: u64,
    user: soroban_sdk::Address,
) -> i128
fn fund_child_prediction(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    parent_market_id: u64,
    child_market_id: u64,
    amount: i128,
) -> Result<(), DikeError>
fn child_loan_for_outcome(
    env: soroban_sdk::Env,
    parent_market_id: u64,
    parent_outcome: Outcome,
    child_market_id: u64,
    child_outcome: Outcome,
    user: soroban_sdk::Address,
) -> i128
fn child_used_for_outcome(
    env: soroban_sdk::Env,
    parent_market_id: u64,
    user: soroban_sdk::Address,
    outcome: Outcome,
) -> i128

Voluntary repayment of an outstanding child-market debt, ahead of that child market resolving. Previously unimplemented — there was no way for a user to close a risky credit line proactively; exposure just sat open until whichever market resolved first.

fn repay_child_collateral(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    child_market_id: u64,
    amount: i128,
) -> Result
fn child_avail_for_outcome(
    env: soroban_sdk::Env,
    parent_market_id: u64,
    user: soroban_sdk::Address,
    outcome: Outcome,
) -> Result

Called by the AMM's liquidate_child_position — the keeper's follow-up close for whatever child debt survived a parent liquidation (or simply never triggered a parent-side liquidation but the child leg itself is now underwater relative to its own debt). Symmetric to liquidate_release but scoped to a single child, since a child market can never itself be a parent (ChainDepthExceeded blocks chaining).

fn liquidate_child_release(
    env: soroban_sdk::Env,
    token: soroban_sdk::Address,
    user: soroban_sdk::Address,
    liquidator: soroban_sdk::Address,
    child_market_id: u64,
    child_outcome: Outcome,
    tokens_sold: i128,
    proceeds: i128,
) -> Result
fn child_collateral_available(
    env: soroban_sdk::Env,
    parent_market_id: u64,
    user: soroban_sdk::Address,
) -> Result
fn open_child_credit_for_trade(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    parent_market_id: u64,
    parent_outcome: Outcome,
    child_market_id: u64,
    child_outcome: Outcome,
    amount: i128,
) -> Result<(), DikeError>
fn assert_position_transfer_allowed(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    market_id: u64,
    outcome: Outcome,
    amount: i128,
) -> Result<(), DikeError>

Imports

WebAssembly Text (WAT) ▶