Contract 8fe9c0e27f850c34ee7303b3b034853c0b49a174a96fa657775ccfea10a53eca

← Back to Index 📥 Download WASM

Meta

rssdkver 21.7.7#5da789c50b18a4c2be53394138212fed56f0dfc4
rsver 1.96.0

Instances

  • CCMIT3N6MFNMRI4DALO2IYWJUX3KCAISBLQMXVYLGMQNCIEALNG6BNCS

Interface

L0-9: time-weighted mean over the newest records ring entries, paired with the RING'S NEWEST timestamp so callers can age-bound liveness. (Upstream twap returns the bare mean; the newest entry comes from prices(feed, 1) — the oldest-used timestamp is not exposed upstream, and ring liveness is the operative bound.) Mode 1 (SEP-40) delegates twap to the vendor and age-bounds it with the feed's newest lastprice tick (R-7) — a fabricated "now" would defeat the market's twap_max_age_secs staleness gate. None whenever the backend/ring cannot answer (<2 entries, unknown pair) — callers degrade to spot, never trap on None.

fn twap(
    env: soroban_sdk::Env,
    asset: soroban_sdk::Symbol,
    records: u32,
) -> Option<(i128, u64)>

Swap the running WASM in place (admin-gated). Future pair additions (new rows in noether_common::assets::PAIR_TAGS) then ship as an in-place upgrade — the shim keeps its address, so the market's oracle wiring never has to change.

fn upgrade(
    env: soroban_sdk::Env,
    new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), NoetherError>

Same precision as the rest of the Noether oracle chain.

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

SEP-40-compatible reader. The existing oracle_adapter contract calls this via env.invoke_contract::<(i128, u64)>(...), so the return shape must be a bare tuple — we panic on missing data rather than returning Result or Option, both of which the caller can't decode into (i128, u64).

fn lastprice(env: soroban_sdk::Env, asset: soroban_sdk::Symbol) -> (i128, u64)

Rotate the admin address. Both old and new admins must sign.

fn set_admin(
    env: soroban_sdk::Env,
    new_admin: soroban_sdk::Address,
) -> Result<(), NoetherError>

One-time setup. Records the admin (who can rotate the Noeracle address) and the Noeracle contract address itself.

fn initialize(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    noeracle_oracle: soroban_sdk::Address,
) -> Result<(), NoetherError>

Current backend: (mode, oracle address, backend decimals).

fn get_backend(
    env: soroban_sdk::Env,
) -> Result<(u32, soroban_sdk::Address, u32), NoetherError>

Swap the price backend in ONE admin call (T3-D1 "Chainlink-ready"): mode 0 = Noeracle native (decimals must be 7), 1 = standard SEP-40 lastprice(Asset) (e.g. Reflector at 14 decimals, Chainlink when it ships on Stellar). Prices from a backend with different decimals are rescaled to Noether's 7 on every read. The market keeps reading this shim's address throughout — no market change, ever.

fn set_backend(
    env: soroban_sdk::Env,
    mode: u32,
    oracle: soroban_sdk::Address,
    decimals: u32,
) -> Result<(), NoetherError>
fn get_noeracle(env: soroban_sdk::Env) -> Result

Point the shim at a different Noeracle deployment (e.g. mainnet migration, or testnet redeploy). Admin-authenticated. Rotates the address only — the backend mode/decimals are untouched, so this is for Noeracle→Noeracle moves; use set_backend to change vendor.

fn set_noeracle_oracle(
    env: soroban_sdk::Env,
    new_oracle: soroban_sdk::Address,
) -> Result<(), NoetherError>

Imports

WebAssembly Text (WAT) ▶