Contract ba052d2552c2b3086dbbc34e2e5eb2c9e7ac2fe0880d2121b97f0bd1d6a25e6b

← Back to Index 📥 Download WASM

Meta

cliver 25.0.0#
rssdkver 23.4.1#e671b396f8bacf1370925f722df158b31c0baae5
rsver 1.91.0-nightly

Instances

  • CBD4KMI4LDH6FDBR4B266JM7YFBUDR5IRQLRUCJFVCAHA5FRZP3N5LYE

Interface

fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    reflector_contract: soroban_sdk::Address,
    base_currency_address: soroban_sdk::Address,
    native_xlm_address: soroban_sdk::Address,
) -> Result<(), OracleError>
fn add_asset(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: Asset,
) -> Result<(), OracleError>
fn remove_asset(env: soroban_sdk::Env, asset: Asset) -> Result<(), OracleError>

Sets a manual price override for emergency situations. Requires an expiry timestamp to prevent permanent mispricing.

Arguments

  • caller - Admin address (must be authorized)
  • asset - Asset to override price for
  • price - Override price (None to remove override)
  • expiry_timestamp - Expiry timestamp in seconds (None to remove override, required when setting price)
fn set_manual_override(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: Asset,
    price: Option,
    expiry_timestamp: Option,
) -> Result<(), OracleError>
fn add_asset_by_address(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset_address: soroban_sdk::Address,
) -> Result<(), OracleError>
fn set_asset_enabled(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: Asset,
    enabled: bool,
) -> Result<(), OracleError>
fn update_reflector_contract(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    new_contract: soroban_sdk::Address,
) -> Result<(), OracleError>

Set a custom oracle for an asset. The oracle must implement:

  • lastprice(asset: Asset) -> Option<PriceData>
  • decimals() -> u32 (skipped if decimals param is provided)
fn set_custom_oracle(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: Asset,
    oracle: Option,
    max_age_seconds: Option,
    decimals: Option,
) -> Result<(), OracleError>

Get custom oracle address for a specific asset

fn get_custom_oracle(
    env: soroban_sdk::Env,
    asset: Asset,
) -> Option
fn set_fallback_oracle(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    fallback_contract: Option,
) -> Result<(), OracleError>
fn pause(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), OracleError>
fn unpause(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), OracleError>
fn is_paused(env: soroban_sdk::Env) -> bool
fn get_asset_price(env: soroban_sdk::Env, asset: Asset) -> Result
fn get_asset_price_data(
    env: soroban_sdk::Env,
    asset: Asset,
) -> Result
fn get_asset_prices_vec(
    env: soroban_sdk::Env,
    assets: soroban_sdk::Vec,
) -> Result, OracleError>
fn get_asset_prices(
    env: soroban_sdk::Env,
    assets: soroban_sdk::Vec,
) -> Result, OracleError>
fn get_oracle_config(env: soroban_sdk::Env) -> Result
fn set_oracle_config(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    config: OracleConfig,
) -> Result<(), OracleError>
fn calculate_collateral_value(
    env: soroban_sdk::Env,
    collateral_asset: Asset,
    collateral_amount: u128,
    base_asset: Asset,
) -> Result
fn calculate_ltv(
    env: soroban_sdk::Env,
    collateral_asset: Asset,
    collateral_amount: u128,
    debt_asset: Asset,
    debt_amount: u128,
) -> Result

Check if a position is liquidatable based on LTV ratio. Returns true if LTV >= liquidation_threshold.

fn is_liquidatable(
    env: soroban_sdk::Env,
    collateral_asset: Asset,
    collateral_amount: u128,
    debt_asset: Asset,
    debt_amount: u128,
    liquidation_threshold: u32,
) -> Result

Check if a position is liquidatable based on collateralization ratio. Returns true if collateralization_ratio >= liquidation_threshold. Both is_liquidatable and check_liquidation use consistent semantics (>=).

fn check_liquidation(
    env: soroban_sdk::Env,
    collateral_asset: Asset,
    collateral_amount: u128,
    debt_asset: Asset,
    debt_amount: u128,
    liquidation_threshold: u32,
) -> Result
fn get_base_currency(env: soroban_sdk::Env) -> Asset
fn set_base_currency(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    base_currency: Asset,
) -> Result<(), OracleError>
fn get_asset_value_in_base(
    env: soroban_sdk::Env,
    asset: Asset,
    amount: u128,
) -> Result
fn get_asset_price_in_asset(
    env: soroban_sdk::Env,
    base_asset: Asset,
    quote_asset: Asset,
) -> Result
fn get_whitelisted_assets(env: soroban_sdk::Env) -> soroban_sdk::Vec
fn get_asset_config(env: soroban_sdk::Env, asset: Asset) -> Option
fn admin(env: soroban_sdk::Env) -> Result
fn get_reflector_contract(env: soroban_sdk::Env) -> Option

Reset circuit breaker for a specific asset (admin only).

Clears the stored last known price, allowing the next price query to bypass the circuit breaker check. Use this when legitimate large price movements occur (e.g., major market events, token migrations, or oracle upgrades).

fn reset_circuit_breaker(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: Asset,
) -> Result<(), OracleError>

Reset circuit breaker for all assets (admin only).

Emergency function to clear all stored last known prices. Use sparingly and only when necessary, as it temporarily disables circuit breaker protection for all assets until new prices are queried.

fn reset_all_circuit_breakers(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), OracleError>

Get last known price for an asset (for debugging and monitoring).

Returns the stored price used for circuit breaker validation, or None if no price has been recorded yet for this asset.

fn get_last_price(env: soroban_sdk::Env, asset: Asset) -> Option

Configure a batch-capable oracle adapter for direct queries. The adapter must implement: read_price_data_for_feed(String) and read_price_data(Vec<String>) returning {price: U256, package_timestamp: u64, write_timestamp: u64}.

fn set_batch_oracle(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    asset: Asset,
    adapter: Option,
    feed_id: Option,
    decimals: Option,
    max_age_seconds: Option,
) -> Result<(), OracleError>

Set the TTL (in seconds) for the price cache. 0 = disabled.

fn set_price_cache_ttl(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    ttl: u64,
) -> Result<(), OracleError>

Get the current price cache TTL in seconds.

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

Force-refresh cached prices for specific assets. Clears cached price data and fetches fresh prices from external sources. Use this before budget-sensitive operations (liquidation, swap_collateral) to ensure the cache is warm and subsequent calls hit the cache.

fn refresh_prices(
    env: soroban_sdk::Env,
    assets: soroban_sdk::Vec,
) -> Result, OracleError>
fn upgrade(
    env: soroban_sdk::Env,
    new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), OracleError>
fn version(env: soroban_sdk::Env) -> u32

Get current admin address

fn get_admin(env: soroban_sdk::Env) -> Result

Propose a new admin address (two-step transfer, step 1). Only the current admin can propose a new admin. The proposed admin must call accept_admin to complete the transfer.

Arguments

  • caller - Current admin address (must be authorized)
  • pending_admin - Proposed new admin address

Errors

  • Unauthorized - Caller is not current admin
fn propose_admin(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    pending_admin: soroban_sdk::Address,
) -> Result<(), OracleError>

Accept admin role (two-step transfer, step 2). Only the pending admin can call this to finalize the transfer.

Arguments

  • caller - Pending admin address (must be authorized)

Errors

  • InvalidCalculation - No pending admin proposal or caller is not the pending admin
fn accept_admin(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), OracleError>

Cancel a pending admin proposal. Only the current admin can cancel a pending proposal.

Arguments

  • caller - Current admin address (must be authorized)

Errors

  • Unauthorized - Caller is not current admin
  • InvalidCalculation - No pending admin proposal exists
fn cancel_admin_proposal(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
) -> Result<(), OracleError>

Get the pending admin address, if any.

Returns

  • Ok(Address) - Pending admin address
  • Err(InvalidCalculation) - No pending admin proposal exists
fn get_pending_admin(
    env: soroban_sdk::Env,
) -> Result

Imports

WebAssembly Text (WAT) ▶