Contract 89a79f3a1ccfb5ae89dfa32d7c47050170e0ebd8d8cc568acb709965fba9c259

← Back to Index 📥 Download WASM

Meta

rssdkver 23.4.1#e671b396f8bacf1370925f722df158b31c0baae5
rsver 1.91.0-nightly

Instances

  • CCPXDNLCMQLWJBNOVSXXW56QQT4WBIDURHA4DBFFPNZWMKW4M7PUVKBI
  • CCSRDUCAQ2SWUBC35BHADMWACAOKNJDHKHVAK2H37RGTZA342ZMGLC7U

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_oracle_config(env: soroban_sdk::Env) -> Result
fn set_oracle_config(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    config: OracleConfig,
) -> Result<(), OracleError>
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>

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) ▶