Cumulative compound index since inception (RAY). 1.0 == RAY == no growth.
fn index(env: soroban_sdk::Env, asset: soroban_sdk::Address) -> i128
Replace the contract's wasm (admin-gated). Address and storage are kept.
fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Index value (RAY) at an arbitrary past timestamp t.
Semantics (mirroring the Solidity _indexAt):
t newer than the latest observation -> the latest index (flat:
the index only moves on updates, so this is the stale-read value);t exactly on an observation -> that observation's index;t between two observations -> geometric interpolation
(constant-rate assumption between the surrounding snapshots);t in the future, or older than the oldest retained observation,
or pool never updated -> panic.fn index_at(env: soroban_sdk::Env, asset: soroban_sdk::Address, t: u64) -> i128
Register a pool/asset and start its index at 1.0 (RAY) "from inception".
obs_capacity sizes the per-pool observation ring buffer (must be >= 1).
fn configure(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
tau_sec: u64,
obs_capacity: u32,
source: Source,
)
fn get_admin(env: soroban_sdk::Env) -> soroban_sdk::Address
Full state for a pool (debugging / off-chain reads).
fn get_state(env: soroban_sdk::Env, asset: soroban_sdk::Address) -> AprState
Accrued rate since pool inception as a RAY fraction (current_index - 1).
e.g. 0.05 * RAY means 5% has accrued since the pool started.
fn accrued_ray(env: soroban_sdk::Env, asset: soroban_sdk::Address) -> i128
Advance a Source::GrowthIndex pool by pulling its source index and
deriving the rate from the index growth since the previous snapshot.
Deliberately permissionless (mirrors the public updateState in the
Solidity implementation): the caller only chooses the moment of the update,
the data comes from the configured source and cannot be forged.
fn update_state(env: soroban_sdk::Env, asset: soroban_sdk::Address)
fn __constructor(env: soroban_sdk::Env, admin: soroban_sdk::Address)
Accrued rate over [from, to] as a RAY fraction:
index(to) / index(from) - 1.
fn accrued_between(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
from: u64,
to: u64,
) -> i128
Read one observation slot (debugging / off-chain reads).
fn get_observation(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
slot: u32,
) -> Observation
Floating rate accrued over [from, to] as a [Wad] (1e18):
index(to) / index(from) - 1, converted down from the RAY-scale index.
fn get_rate_from_to(
env: soroban_sdk::Env,
asset: soroban_sdk::Address,
from: u64,
to: u64,
) -> (Wad, bool)