Contract 18c5f74a1a6821cb3312481f3d2f89f66e7b5f62ef15b41b7929a8d02eaafba4

← Back to Index 📥 Download WASM

Meta

rssdkver 26.1.0#175aa41306f383057a8cdfc84b68d931664fc34e
rsver 1.96.0

Instances

  • CAE5C5UJYVED5DAVY4YKYT6E2C4NBZCIUBAK2MXGKGLKZESBBXKFPZ4U

Interface

Circuit breaker: halt new deposits and new borrows. Exits (repay, withdraw, claim_yield) and mark_default always keep working — pausing can never trap anyone's funds, it only stops NEW risk from being taken.

fn pause(env: soroban_sdk::Env)

Agent repays. Payment covers accrued interest first — a cut of which funds the reserve and the rest becomes lender yield — then principal (→ returned to lendable liquidity). Full repayment clears the repayment clock.

fn repay(
    env: soroban_sdk::Env,
    agent: soroban_sdk::Address,
    amount: i128,
) -> Result<(), soroban_sdk::Error>

Full isolated state for an agent's vault.

fn state(env: soroban_sdk::Env, agent: soroban_sdk::Address) -> VaultState
fn token(env: soroban_sdk::Env) -> soroban_sdk::Address

Agent draws against its credit line; USDC is disbursed from its vault. The drawable limit is ramped by repayment history; the first draw from a zero balance starts the repayment clock. Blocked while paused (new risk-taking only — an agent that already has a loan can still repay it while paused).

fn borrow(
    env: soroban_sdk::Env,
    agent: soroban_sdk::Address,
    amount: i128,
) -> Result<(), soroban_sdk::Error>
fn paused(env: soroban_sdk::Env) -> bool

The lender's raw share balance in this agent's vault.

fn shares(
    env: soroban_sdk::Env,
    lender: soroban_sdk::Address,
    agent: soroban_sdk::Address,
) -> i128

Lender deposits USDC into a specific agent's isolated vault, receiving shares priced against the vault's current assets. Frozen after default, blocked while paused, and capped at the global per-vault deposit cap.

fn deposit(
    env: soroban_sdk::Env,
    lender: soroban_sdk::Address,
    agent: soroban_sdk::Address,
    amount: i128,
) -> Result<(), soroban_sdk::Error>
fn reserve(env: soroban_sdk::Env, agent: soroban_sdk::Address) -> i128
fn unpause(env: soroban_sdk::Env)
fn due_date(env: soroban_sdk::Env, agent: soroban_sdk::Address) -> u64

The lender's current claim value (USDC) at the vault's share price.

fn position(
    env: soroban_sdk::Env,
    lender: soroban_sdk::Address,
    agent: soroban_sdk::Address,
) -> i128
fn registry(env: soroban_sdk::Env) -> soroban_sdk::Address

Lender withdraws idle deposited value (only funds not currently lent), burning shares at the current share price.

fn withdraw(
    env: soroban_sdk::Env,
    lender: soroban_sdk::Address,
    agent: soroban_sdk::Address,
    amount: i128,
) -> Result<(), soroban_sdk::Error>
fn defaulted(env: soroban_sdk::Env, agent: soroban_sdk::Address) -> bool
fn liquidity(env: soroban_sdk::Env, agent: soroban_sdk::Address) -> i128
fn term_secs(env: soroban_sdk::Env) -> u64
fn yield_pool(env: soroban_sdk::Env, agent: soroban_sdk::Address) -> i128

Total currently owed (principal + interest accrued to the current ledger).

fn amount_owed(env: soroban_sdk::Env, agent: soroban_sdk::Address) -> i128

Lender claims its pro-rata (by shares) share of accumulated interest yield.

fn claim_yield(
    env: soroban_sdk::Env,
    lender: soroban_sdk::Address,
    agent: soroban_sdk::Address,
) -> i128
fn deposit_cap(env: soroban_sdk::Env) -> i128

Permissionless default trigger: once an agent's loan is past its due date and principal remains outstanding, anyone may crystallise the default. The reserve absorbs the loss first; the unrecovered remainder is socialised to the vault's lenders (share value falls); the agent is frozen out of further borrowing. Isolated to this agent's vault.

fn mark_default(
    env: soroban_sdk::Env,
    agent: soroban_sdk::Address,
    caller: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Bind the vault to a score_registry (for limits), the USDC SEP-41 SAC, the loan term (seconds) a fresh draw must be repaid within, an admin (can pause/unpause and adjust the deposit cap), and an initial global deposit cap per agent vault (0 = uncapped).

fn __constructor(
    env: soroban_sdk::Env,
    registry: soroban_sdk::Address,
    token: soroban_sdk::Address,
    term_secs: u64,
    admin: soroban_sdk::Address,
    deposit_cap: i128,
)

Admin-adjustable global cap on capital at risk (liquidity + principal) per agent vault. Caps the blast radius of an undiscovered bug: no single vault can ever hold more than this, no matter how much lenders want to deposit. 0 = uncapped.

fn set_deposit_cap(env: soroban_sdk::Env, new_cap: i128)

Remaining drawable credit (ramped limit − outstanding principal).

fn available_credit(env: soroban_sdk::Env, agent: soroban_sdk::Address) -> i128

Imports

WebAssembly Text (WAT) ▶