Opens a rate-lock order. Escrows amount from customer and snapshots
the customer's settlement conditions. Does NOT read or freeze the oracle
rate — target_rate is the customer's condition, not today's price.
fn lock(
env: soroban_sdk::Env,
customer: soroban_sdk::Address,
amount: i128,
target_rate: i128,
expiry: u64,
recipient: soroban_sdk::Address,
payout_ref: soroban_sdk::BytesN<32>,
) -> Result
Cancels an active order at any time before settlement, returning the escrow to the customer. Customer auth only.
fn cancel(env: soroban_sdk::Env, order_id: u64) -> Result<(), soroban_sdk::Error>
Settles an active order to its snapshotted recipient once the oracle rate
meets the target. Admin/operator only. Never accepts a settle-time
recipient — funds always go to order.recipient.
fn settle(env: soroban_sdk::Env, order_id: u64) -> Result<(), soroban_sdk::Error>
Admin-only in-place code upgrade. new_wasm_hash must reference bytecode already uploaded to the network; the contract address and all stored state (config, orders) are preserved.
fn upgrade(
env: soroban_sdk::Env,
new_wasm_hash: soroban_sdk::BytesN<32>,
) -> Result<(), soroban_sdk::Error>
fn get_order(env: soroban_sdk::Env, order_id: u64) -> Result
fn get_config(env: soroban_sdk::Env) -> Result
fn initialize(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
oracle: soroban_sdk::Address,
token: soroban_sdk::Address,
max_staleness: u64,
max_duration: u64,
min_amount: i128,
max_amount: i128,
) -> Result<(), soroban_sdk::Error>
fn set_paused(env: soroban_sdk::Env, paused: bool) -> Result<(), soroban_sdk::Error>
Extends an order's persistent-storage TTL. Callable by anyone so orders can be kept alive through their lifetime without privileged access.
fn bump_order_ttl(
env: soroban_sdk::Env,
order_id: u64,
) -> Result<(), soroban_sdk::Error>
Refunds an expired, still-active order back to the customer. Callable by anyone (no auth) — the funds can only ever go to the snapshotted customer.
fn refund_expired(
env: soroban_sdk::Env,
order_id: u64,
) -> Result<(), soroban_sdk::Error>