Contract 60b8687fa152f1ba555fa24e64d0ee9e87b622feead2822a3e8a9061b2cd158a

← Back to Index 📥 Download WASM

Meta

rssdkver 22.0.8#f46e9e0610213bbb72285566f9dd960ff96d03d8
rsver 1.89.0

Instances

  • CCTFWJQZAAKKIKWOXGHFPBX5HZI7G2535UV2CFS2HPK4MQCXUGPB2RQL

Interface

Constructor - Initialize the contract with admin, compliance, and policy addresses

fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    compliance_contract: soroban_sdk::Address,
    policy_contract: soroban_sdk::Address,
)

Set (or repoint) the SEP-40 price oracle used at origination. Admin-gated. Must be called once after deploy (like compliance/policy) before create_loan.

fn set_oracle(env: soroban_sdk::Env, oracle: soroban_sdk::Address)

Get the configured oracle address (panics if unset).

fn get_oracle(env: soroban_sdk::Env) -> soroban_sdk::Address

Get the number of loans created so far

This is derived from NEXT_LOAN_ID, which starts at 1 and is incremented after each successful create_loan.

fn get_loan_count(env: soroban_sdk::Env) -> u64

Get the next loan ID that will be assigned on create_loan

fn get_next_loan_id(env: soroban_sdk::Env) -> u64

Create a new loan

fn create_loan(
    env: soroban_sdk::Env,
    user: soroban_sdk::Address,
    borrowed_amount: i128,
    deposited_amount: i128,
    policy_id: u64,
    institution_id: u64,
    collateral_ticker: soroban_sdk::Symbol,
    collateral_decimals: u32,
    collateral_amount: i128,
    tx: soroban_sdk::BytesN<32>,
    chain: soroban_sdk::Symbol,
) -> u64

Get loan by ID

fn get_loan(env: soroban_sdk::Env, loan_id: u64) -> Loan

Update loan amounts

fn update_loan(
    env: soroban_sdk::Env,
    loan_id: u64,
    borrowed_amount: Option,
    deposited_amount: Option,
)

Pay back part or all of the loan Updates the loan's borrowed_amount and policy's remaining_amount Returns: (remaining_debt, total_paid)

fn payback(env: soroban_sdk::Env, loan_id: u64, payment_amount: i128) -> (i128, i128)

Calculate interest on the loan and return the total amount user needs to pay back Returns: (principal, interest, total_amount_to_pay)

fn calculate_interest(env: soroban_sdk::Env, loan_id: u64) -> (i128, i128, i128)

Check if loan should be liquidated based on current asset price Returns: (should_liquidate: bool, collateral_value: i128, debt_value: i128, threshold_value: i128)

Parameters:

  • loan_id: The loan to check
  • asset_price: Current price of the collateral asset in the borrowed currency (with same decimals as borrowed_amount) e.g., if borrowed_amount is in USD cents (2 decimals), price should be in USD cents
fn check_liquidation(
    env: soroban_sdk::Env,
    loan_id: u64,
    asset_price: i128,
) -> (bool, i128, i128, i128)

Imports

WebAssembly Text (WAT) ▶