Contract 0c11feab7a8d073a155ed03dc875239e39f9d08554c3720824282759a5262428

โ† Back to Index ๐Ÿ“ฅ Download WASM

Meta

cliver 26.1.0#1228cff8022b804659750b94b315932b0e0f3f6a
rssdkver 22.0.11#34f7f53ae31e0fd02aab436a9872e79fa671ca02
rsver 1.95.0

Instances

  • CD2TXQSRGH2XHUWH3VIDGLQGVT6KXMBJPT6QR2RBBCGFVFVTRTD2E5SU

Interface

Toolchain / deploy sanity check: returns ["Hello", <to>].

fn hello(
    env: soroban_sdk::Env,
    to: soroban_sdk::String,
) -> soroban_sdk::Vec
fn pause(env: soroban_sdk::Env) -> Result<(), PrismError>

Deposit USDC into a tranche; mint pTokens to the user.

Mirrors contracts/programs/prism-core/src/instructions/deposit.rs. First deposit mints 1:1 (NAV = 1.0). Subsequent deposits compute shares = amount ร— Q_ONE / nav_per_share_q.

fn deposit(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    vault_id: u32,
    kind: u32,
    amount: i128,
) -> Result
fn unpause(env: soroban_sdk::Env) -> Result<(), PrismError>
fn get_loan(env: soroban_sdk::Env, loan_id: u32) -> Option

Burn pTokens; pay out USDC at current NAV.

Mirrors contracts/programs/prism-core/src/instructions/withdraw.rs. Allowed when vault is Active or Defaulted (so LPs can exit a written-down tranche). Returns the USDC amount paid out.

fn withdraw(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    vault_id: u32,
    kind: u32,
    shares: i128,
) -> Result
fn get_vault(env: soroban_sdk::Env, vault_id: u32) -> Option

Originate a loan against a vault. Admin-only. No USDC moves yet โ€” disbursement happens via disburse_loan (so admins can verify off-chain collateral before unlocking funds, even though the IKA collateral feature itself was dropped).

Mirrors contracts/programs/prism-core/src/instructions/initialize_loan.rs.

fn init_loan(
    env: soroban_sdk::Env,
    vault_id: u32,
    loan_id: u32,
    borrower: soroban_sdk::Address,
    principal: i128,
    apr_bps: u32,
    maturity_ts: u64,
) -> Result<(), PrismError>
fn get_config(env: soroban_sdk::Env) -> GlobalConfig

Create a new credit vault. Admin-only. Vault starts in Active state with zero balances.

fn init_vault(env: soroban_sdk::Env, vault_id: u32) -> Result<(), PrismError>

Borrower repays USDC against a loan. State flips to Repaid once total_repaid >= principal.

Mirrors contracts/programs/prism-core/src/instructions/repay_loan.rs.

fn repay_loan(
    env: soroban_sdk::Env,
    borrower: soroban_sdk::Address,
    loan_id: u32,
    amount: i128,
) -> Result<(), PrismError>
fn get_tranche(env: soroban_sdk::Env, vault_id: u32, kind: u32) -> Option

Initialize protocol global config. Single-shot; subsequent calls error.

fn init_config(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    usdc_token: soroban_sdk::Address,
    default_yield_rate_bps: u32,
    oracle_allowlist: soroban_sdk::Vec>,
) -> Result<(), PrismError>

Distribute USDC yield across the three tranches using the waterfall: Prime fills its time-weighted target APY first, Core next, Alpha takes the residual.

Mirrors contracts/programs/prism-core/src/instructions/accrue_yield.rs. Caller must be config.admin or in oracle_allowlist. payer is the borrower-ish address that ships the USDC into the contract (kept explicit so the auth flow is clear on Soroban).

fn accrue_yield(
    env: soroban_sdk::Env,
    authority: soroban_sdk::Address,
    vault_id: u32,
    payer: soroban_sdk::Address,
    amount: i128,
) -> Result<(), PrismError>

Create a tranche (Prime=0, Core=1, Alpha=2) inside an existing vault. Admin-only. The ptoken argument is the Stellar Asset Contract address of the pre-deployed pTranche token; this contract must be its admin so it can mint/burn on deposit/withdraw (Phase 2).

fn init_tranche(
    env: soroban_sdk::Env,
    vault_id: u32,
    kind: u32,
    target_apy_bps: u32,
    ptoken: soroban_sdk::Address,
) -> Result<(), PrismError>

Transfer contract admin rights to a new address. Requires the current admin's auth. Irreversible without the new admin's key.

fn update_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), PrismError>

Disburse a loan: contract sends USDC from its reserve to the borrower. Admin-only. Loan must be in Originated state and vault must be Active.

Mirrors contracts/programs/prism-core/src/instructions/disburse_loan.rs, minus the IKA collateral gate (cut for v1).

fn disburse_loan(
    env: soroban_sdk::Env,
    vault_id: u32,
    loan_id: u32,
) -> Result<(), PrismError>
fn get_collateral(env: soroban_sdk::Env, loan_id: u32) -> Option
fn get_cloak_payout(
    env: soroban_sdk::Env,
    vault_id: u32,
    seq: u32,
) -> Option

Register a PRISM Collateral Oracle pubkey for a loan. Creates a CollateralRecord in Pending state. The oracle_pubkey must be in config.oracle_allowlist. This does NOT disburse or lock anything โ€” disburse_loan remains blocked until verify_collateral succeeds.

fn attach_collateral(
    env: soroban_sdk::Env,
    borrower: soroban_sdk::Address,
    loan_id: u32,
    oracle_pubkey: soroban_sdk::BytesN<32>,
) -> Result<(), PrismError>

Oracle attests collateral is locked (status byte 0x01). Advances record from Pending โ†’ Attached. After this call disburse_loan is unblocked.

Attestation message layout (73 bytes, ยง6.6): bytes 0..8 b"col_atts" bytes 8..12 loan_id (u32 LE) bytes 12..16 chain_id (u32 LE) bytes 16..48 asset_address (32 bytes) bytes 48..56 amount_usd_micro (u64 LE) bytes 56..64 valued_at_ts (i64 LE) bytes 64..72 nonce (u64 LE) byte 72 status (must be 0x01 for verify_collateral)

fn verify_collateral(
    env: soroban_sdk::Env,
    relayer: soroban_sdk::Address,
    loan_id: u32,
    message: soroban_sdk::Bytes,
    signature: soroban_sdk::BytesN<64>,
) -> Result<(), PrismError>
fn get_encrypt_health(env: soroban_sdk::Env, loan_id: u32) -> Option

Oracle attests collateral is released (status byte 0x02). Advances record from Attached โ†’ Released. Called on full loan repayment.

fn release_collateral(
    env: soroban_sdk::Env,
    borrower: soroban_sdk::Address,
    loan_id: u32,
    message: soroban_sdk::Bytes,
    signature: soroban_sdk::BytesN<64>,
) -> Result<(), PrismError>

Record a Cloak batch payout. The oracle attests that a batch of yield has been shielded into Cloak's privacy pool and fanned out to LPs. Verification is purely informational โ€” it doesn't move USDC on-chain.

Attestation message layout (73 bytes): bytes 0..8 "clk_atts" prefix bytes 8..40 vault_id_padded (u32 LE, zero-padded to 32 bytes) bytes 40..72 batch_id (sha256 of off-chain disbursement receipt) byte 72 result (0x01 = batch confirmed)

The signing pubkey must be in config.oracle_allowlist.

fn record_cloak_payout(
    env: soroban_sdk::Env,
    relayer: soroban_sdk::Address,
    vault_id: u32,
    cloak_oracle: soroban_sdk::BytesN<32>,
    message: soroban_sdk::Bytes,
    signature: soroban_sdk::BytesN<64>,
    total_shielded_amount: i128,
) -> Result

Seed initial USDC + pToken liquidity into a Soroswap pool for one tranche.

Admin-only. Call once per tranche after the vault has been funded with deposits and the Soroswap pair has been created (via the Soroswap factory frontend). The core contract is the LP โ€” it approves the router, calls add_liquidity, and receives LP tokens back to its own address.

usdc_min and ptoken_min are slippage guards forwarded to Soroswap; pass 0 for initial seeding where no pool price exists yet.

Returns (usdc_used, ptoken_used, lp_minted).

fn seed_pool_liquidity(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    vault_id: u32,
    kind: u32,
    soroswap_router: soroban_sdk::Address,
    usdc_amount: i128,
    ptoken_amount: i128,
    usdc_min: i128,
    ptoken_min: i128,
) -> Result<(i128, i128, i128), PrismError>

Borrower registers a sha256 commitment of their Encrypt-sealed credit data, plus the pubkey of the oracle that will later sign default proofs.

encrypt_oracle must be in config.oracle_allowlist. The pubkey is stored on the per-loan EncryptLoanHealth record and re-validated on every verify_encrypt_default call.

Mirrors contracts/programs/prism-core/src/instructions/attach_encrypt_score.rs.

fn attach_encrypt_score(
    env: soroban_sdk::Env,
    borrower: soroban_sdk::Address,
    loan_id: u32,
    commitment: soroban_sdk::BytesN<32>,
    encrypt_oracle: soroban_sdk::BytesN<32>,
) -> Result<(), PrismError>

Admin-triggered liquidation: oracle attests status byte 0x03 and the loss cascade fires for loss_amount against the vault's tranches.

fn liquidate_collateral(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    loan_id: u32,
    message: soroban_sdk::Bytes,
    signature: soroban_sdk::BytesN<64>,
    loss_amount: i128,
    severity_bps: u32,
) -> Result

Read the most recent Reflector oracle price for a given asset symbol.

reflector is the Reflector oracle contract address. asset_symbol is the ticker string, e.g. "BTC", "ETH", "USDC".

This is a simulation target โ€” call via simulateTransaction from the frontend to display mark-to-market collateral prices without a tx fee. Returns None if Reflector has no data for the asset.

fn read_reflector_price(
    env: soroban_sdk::Env,
    reflector: soroban_sdk::Address,
    asset_symbol: soroban_sdk::Symbol,
) -> Option

Reverse waterfall: Alpha absorbs first, then Core, then Prime. On Default, vault state flips to Defaulted.

Mirrors contracts/programs/prism-core/src/instructions/trigger_credit_event.rs. loan_id is recorded on the event but no loan-state mutation happens here.

fn trigger_credit_event(
    env: soroban_sdk::Env,
    authority: soroban_sdk::Address,
    vault_id: u32,
    event_type: u32,
    loss_amount: i128,
    severity_bps: u32,
    loan_id: u32,
) -> Result

Lightweight check for operations tooling.

fn is_oracle_allowlisted(
    env: soroban_sdk::Env,
    oracle_pubkey: soroban_sdk::BytesN<32>,
) -> bool

Verify an Encrypt FHE default attestation and fire the loss cascade.

Attestation message layout (73 bytes), byte-identical to the Solana version so the off-chain oracle can produce one message for either chain by just swapping the loan-identifier semantics: bytes 0..8 "enc_atts" prefix bytes 8..40 loan_id_padded (loan_id as u32 LE, zero-padded to 32 bytes) bytes 40..72 score_commitment (must match attach time) byte 72 result (0x01 = default proven)

On valid signature + valid message:

  1. EncryptLoanHealth โ†’ DefaultProven
  2. Reverse-waterfall cascade (Alpha โ†’ Core โ†’ Prime) for loss_amount
  3. Vault โ†’ Defaulted, credit_event_seq++
fn verify_encrypt_default(
    env: soroban_sdk::Env,
    relayer: soroban_sdk::Address,
    vault_id: u32,
    loan_id: u32,
    message: soroban_sdk::Bytes,
    signature: soroban_sdk::BytesN<64>,
    loss_amount: i128,
    severity_bps: u32,
) -> Result

Add an oracle pubkey to the global allowlist.

Admin-only. Fails if the key is already allowlisted or the list is full.

fn add_oracle_to_allowlist(
    env: soroban_sdk::Env,
    oracle_pubkey: soroban_sdk::BytesN<32>,
) -> Result<(), PrismError>

Return the cumulative USDC absorbed by the loss cascade for a vault. Together with ฮฃ tranche.total_assets, it equals the contract's USDC reserve: reserve == ฮฃ tranche.total_assets + loss_bucket_balance.

fn get_loss_bucket_balance(env: soroban_sdk::Env, vault_id: u32) -> u128

Atomically replace one allowlisted oracle pubkey with another.

Admin-only. Useful for key rotation without a two-transaction gap.

fn rotate_oracle_allowlist_key(
    env: soroban_sdk::Env,
    old_oracle_pubkey: soroban_sdk::BytesN<32>,
    new_oracle_pubkey: soroban_sdk::BytesN<32>,
) -> Result<(), PrismError>

Remove an oracle pubkey from the global allowlist.

Admin-only. Fails if the key is not currently allowlisted.

fn remove_oracle_from_allowlist(
    env: soroban_sdk::Env,
    oracle_pubkey: soroban_sdk::BytesN<32>,
) -> Result<(), PrismError>

Imports

WebAssembly Text (WAT) โ–ถ