Contract 0cfd0831a78ebeb232e691e71109726b1f787b901c341e63061253b0a9bbb709

← Back to Index 📥 Download WASM

Meta

cliver 27.1.0#8e402ea28202950b272fbabc34caad4d2f64fe87
rssdk_spec_shaking 2
rssdkver 27.0.6#60926a20d1f9f0a669d5fe551636f42a1302f0c0
rsver 1.95.0

Instances

  • CDA3XS2HETVCW5GSRN3FH4X3YJ45IA6DNVSZTEOYDFGOCXQK4ZJG22JM

Interface

Renews the contract's instance storage TTL and upgrades the contract to the WASM code at new_wasm_hash.

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

Returns the current contract owner, if set.

fn get_owner(env: soroban_sdk::Env) -> Option

Initializes the contract: sets admin as owner and stores the initial signer set, submission threshold, price resolution, and default staleness, submission-age, and skew bounds. Fails with InvalidThreshold if threshold is zero, exceeds the number of signers, or signers contains a duplicate address.

fn __constructor(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    signers: soroban_sdk::Vec,
    threshold: u32,
    resolution: u32,
) -> Result<(), soroban_sdk::Error>

Accepts a pending ownership transfer, making the caller the new owner.

fn accept_ownership(env: soroban_sdk::Env)

Renounces ownership, leaving the contract without an owner.

fn renounce_ownership(env: soroban_sdk::Env)

Starts an ownership transfer to new_owner, valid for acceptance until live_until_ledger.

fn transfer_ownership(
    env: soroban_sdk::Env,
    new_owner: soroban_sdk::Address,
    live_until_ledger: u32,
)

Maps asset to feed_id in both directions, registers feed_id as known, and adds asset to the asset registry. Fails with FeedAlreadyMapped if asset already has a feed mapping or feed_id already has an owning asset.

fn add_feed(
    env: soroban_sdk::Env,
    feed_id: soroban_sdk::String,
    asset: ReflectorAsset,
) -> Result<(), soroban_sdk::Error>

Adds signer to the set of addresses authorized to submit prices. Fails with SignerAlreadyRegistered if the address is already present.

fn add_signer(
    env: soroban_sdk::Env,
    signer: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Removes feed_id and all its stored state, including its asset mapping and asset-registry entry if one exists. Fails with FeedNotKnown if the feed is not registered.

fn purge_feed(
    env: soroban_sdk::Env,
    feed_id: soroban_sdk::String,
) -> Result<(), soroban_sdk::Error>

Removes the feed mapping owned by asset, removes asset from the asset registry, and clears all stored state for the underlying feed (aggregate, history, per-signer submissions, and feed index entry). Fails with FeedNotMapped if asset has no feed mapping.

fn remove_feed(
    env: soroban_sdk::Env,
    asset: ReflectorAsset,
) -> Result<(), soroban_sdk::Error>

Registers feed_id as a known feed without mapping it to a ReflectorAsset. Fails with FeedAlreadyRegistered if the feed is already known.

fn register_feed(
    env: soroban_sdk::Env,
    feed_id: soroban_sdk::String,
) -> Result<(), soroban_sdk::Error>

Removes signer from the signer set. Fails with SignerNotRegistered if the address is not currently a signer, and with CannotRemoveBelowThreshold if removal would drop the signer count below the configured threshold. Deletes the signer's latest submission for every feed it had submitted to, recomputes the aggregate for each of those feeds, and clears the signer's feed list.

fn remove_signer(
    env: soroban_sdk::Env,
    signer: soroban_sdk::Address,
) -> Result<(), soroban_sdk::Error>

Sets the minimum number of signer submissions required to accept a price for a feed. Fails with InvalidThreshold if threshold is zero or exceeds the current signer count. Does not re-derive existing aggregates: call recompute_feeds afterwards to apply the new threshold to feeds that already hold one.

fn set_threshold(
    env: soroban_sdk::Env,
    threshold: u32,
) -> Result<(), soroban_sdk::Error>

Sets the price resolution, in seconds, used to decide whether a new aggregate replaces or appends to the last history entry.

fn set_resolution(
    env: soroban_sdk::Env,
    resolution: u32,
) -> Result<(), soroban_sdk::Error>

Re-derives the stored aggregate for each feed in feed_ids under the current threshold, submission-age, and skew configuration.

The configuration setters deliberately do not sweep every registered feed. That cost grows with the feed count and eventually crosses the transaction footprint limit, which would leave those settings permanently unchangeable -- exactly when a signer outage requires lowering the threshold. Call this after a configuration change, in batches small enough to stay inside the limit: each feed costs about one ledger entry per signer plus three. Use feeds() to enumerate the registered ids.

Fails with FeedNotKnown if any id is not registered, in which case no aggregate is recomputed.

fn recompute_feeds(
    env: soroban_sdk::Env,
    feed_ids: soroban_sdk::Vec,
) -> Result<(), soroban_sdk::Error>

Sets the maximum age, in seconds, a stored aggregate can reach before reads treat it as stale. Fails with InvalidSubmissionAge if seconds is smaller than the configured maximum submission age.

fn set_max_stale_seconds(
    env: soroban_sdk::Env,
    seconds: u64,
) -> Result<(), soroban_sdk::Error>

Sets the maximum allowed timestamp skew, in seconds, between clustered signer submissions for the same aggregate. Fails with InvalidRelativeSkew if seconds exceeds the configured maximum submission age or is not greater than MAX_FUTURE_SKEW_SECONDS. Does not re-derive existing aggregates: call recompute_feeds afterwards to apply the new bound to feeds that already hold one.

fn set_max_relative_skew_seconds(
    env: soroban_sdk::Env,
    seconds: u64,
) -> Result<(), soroban_sdk::Error>

Sets the maximum age, in seconds, a signer's submission timestamp can have relative to ledger time to be accepted. Fails with InvalidSubmissionAge if seconds is below MIN_SUBMISSION_AGE_SECONDS or above the configured maximum stale age. Does not re-derive existing aggregates: call recompute_feeds afterwards to apply the new bound to feeds that already hold one.

fn set_max_submission_age_seconds(
    env: soroban_sdk::Env,
    seconds: u64,
) -> Result<(), soroban_sdk::Error>

Returns the quote asset for all prices reported by this contract: ReflectorAsset::Other("USD").

fn base(env: soroban_sdk::Env) -> ReflectorAsset

Returns every registered feed id, including feeds with no asset mapping. Use this to enumerate the ids to pass to recompute_feeds after a configuration change.

fn feeds(env: soroban_sdk::Env) -> soroban_sdk::Vec

Returns the history entry for asset with the newest package timestamp at or before timestamp, converted to ReflectorPriceData. Returns None if asset has no feed mapping, the feed has no current aggregate or that aggregate is stale, the feed's history is unavailable, or no entry satisfies the timestamp bound.

fn price(
    env: soroban_sdk::Env,
    asset: ReflectorAsset,
    timestamp: u64,
) -> Option

Returns every ReflectorAsset currently mapped to a feed.

fn assets(env: soroban_sdk::Env) -> soroban_sdk::Vec

Returns up to records history entries for asset, newest first, converted to ReflectorPriceData. Returns None if asset has no feed mapping, the feed has no current aggregate or that aggregate is stale, or its history is empty or unavailable.

fn prices(
    env: soroban_sdk::Env,
    asset: ReflectorAsset,
    records: u32,
) -> Option>

Returns the number of decimals used for reported prices.

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

Returns the latest price for asset, converted to ReflectorPriceData. Returns None if asset has no feed mapping or the feed's aggregate is unavailable or stale.

fn lastprice(
    env: soroban_sdk::Env,
    asset: ReflectorAsset,
) -> Option

Returns the configured price resolution, in seconds.

fn resolution(env: soroban_sdk::Env) -> u32

Returns the current aggregate price for each feed in feed_ids, in the same order. Fails on the first feed that returns an error from read_price_data_for_feed.

fn read_price_data(
    env: soroban_sdk::Env,
    feed_ids: soroban_sdk::Vec,
) -> Result, soroban_sdk::Error>

Returns the configured maximum staleness, in seconds, for aggregate reads.

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

Returns up to limit history entries for feed_id, newest first. Fails with NoDataForFeed if the feed has no current aggregate or an empty history, and with StaleData if the current aggregate is stale.

fn read_price_history(
    env: soroban_sdk::Env,
    feed_id: soroban_sdk::String,
    limit: u32,
) -> Result, soroban_sdk::Error>

Returns the current aggregate for feed_id. Fails with NoDataForFeed if none is stored, or StaleData if now - write_timestamp (seconds; timestamps stored in ms) exceeds max_stale_seconds. Package timestamp is not used for this check.

fn read_price_data_for_feed(
    env: soroban_sdk::Env,
    feed_id: soroban_sdk::String,
) -> Result

Returns the configured maximum relative timestamp skew, in seconds, between clustered submissions.

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

Returns the configured maximum submission age, in seconds.

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

Submits price for feed_id on behalf of signer, requiring signer's authorization. Validates that signer is registered, feed_id is known, the price is within bounds, and package_timestamp (milliseconds) is not in the future, not stale (age vs max submission age in seconds), and not older than the signer's previous submission for the feed. Stores the submission and recomputes the feed's aggregate.

fn submit_price(
    env: soroban_sdk::Env,
    signer: soroban_sdk::Address,
    feed_id: soroban_sdk::String,
    price: i128,
    package_timestamp: u64,
) -> Result<(), soroban_sdk::Error>

Submits prices for feed_ids on behalf of signer, requiring signer's authorization and using the same package_timestamp (milliseconds) for every entry; fails with LengthMismatch if the two lists differ in length. Validates that signer is registered, the timestamp is not in the future or stale (age vs max submission age in seconds), and each feed is known, monotonic for signer, and its price within bounds, before storing any submission. Stores each submission and recomputes each feed's aggregate.

Faults are reported in that chain's order — unregistered signer, length mismatch, future timestamp, stale timestamp, then the per-feed pass (unknown feed / non-monotonic timestamp), then price — so a batch carrying two different faults reports whichever comes first in that list, not the one in the earliest entry. The unknown-feed and non-monotonic checks are the exception: they run interleaved per entry, so between those two the earlier entry decides. Example: [known-but-non-monotonic, unknown] r

fn submit_prices(
    env: soroban_sdk::Env,
    signer: soroban_sdk::Address,
    feed_ids: soroban_sdk::Vec,
    prices: soroban_sdk::Vec,
    package_timestamp: u64,
) -> Result<(), soroban_sdk::Error>

Imports

WebAssembly Text (WAT) ▶