Contract 3903d1dee59ef048a64d5287bb9e27e05d54c3c8dc3962e28c16b2031d074906

← Back to Index 📥 Download WASM

Meta

cliver 27.0.0#5a7c5fe76530bf4248477ac812fc757146b98cc4
rssdkver 25.3.1#e50d95af029c83196dd122f0154bac3f1302394b
rsver 1.92.0

Instances

  • CASQXSK6VUM7SSGZQ6SGOHAUTLRTQPEVWVDVQCPEZ4QAZ4JOM7VKKUCI

Interface

Pause an active stream.

Sender-only. Snapshots ongoing debt and sets rate to 0.

fn pause(env: soroban_sdk::Env, stream_id: u64, sender: soroban_sdk::Address)

Create a new Flow stream.

The stream starts with zero balance. Use deposit() or create_and_deposit() to fund it.

Arguments

  • sender — Address streaming the tokens (can pause/adjust/refund).
  • recipient — Address receiving the tokens (can withdraw).
  • token — Soroban token contract address (SAC or SEP-41).
  • rate_per_second — Debt accrual rate in 18-decimal fixed-point.
  • token_decimals — Token's decimal count (≤ 18).
  • start_time — Unix timestamp to start. 0 = start now.

Returns

The newly assigned stream ID.

fn create(
    env: soroban_sdk::Env,
    sender: soroban_sdk::Address,
    recipient: soroban_sdk::Address,
    token: soroban_sdk::Address,
    rate_per_second: i128,
    token_decimals: u32,
    start_time: u64,
) -> u64

Refund excess balance from a stream back to the sender.

Sender-only. Only unowed tokens can be refunded.

fn refund(
    env: soroban_sdk::Env,
    stream_id: u64,
    sender: soroban_sdk::Address,
    amount: i128,
)

Deposit tokens into an existing stream.

Anyone can fund a stream, but funder.require_auth() is needed for the token transfer authorization.

fn deposit(
    env: soroban_sdk::Env,
    stream_id: u64,
    funder: soroban_sdk::Address,
    amount: i128,
)

Restart a paused stream with a new rate.

Sender-only. The stream must be paused and not voided.

fn restart(
    env: soroban_sdk::Env,
    stream_id: u64,
    sender: soroban_sdk::Address,
    rate_per_second: i128,
)

Emergency upgrade — bypasses timelock. Use only in critical situations. Emits an upgrade event for auditing.

Admin-only. Consider removing this function after initial mainnet stabilization, or requiring a separate emergency key.

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

Withdraw accrued tokens from a stream.

Only the stream recipient can withdraw. The withdrawn amount is capped at the covered debt (balance-backed portion of total debt).

fn withdraw(
    env: soroban_sdk::Env,
    stream_id: u64,
    caller: soroban_sdk::Address,
    to: soroban_sdk::Address,
    amount: i128,
)

Direct admin transfer (legacy, kept for backwards compatibility).

Admin-only. Prefer propose_admin + accept_admin for safety.

fn set_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)

Get the stream's current status.

fn status_of(env: soroban_sdk::Env, stream_id: u64) -> StreamStatus

Get the full stream record.

fn get_stream(env: soroban_sdk::Env, stream_id: u64) -> FlowStream

Initialize the contract with an admin address.

Must be called exactly once before any other function. The intended admin must authorize the initialization to prevent first-caller takeover attacks.

fn initialize(env: soroban_sdk::Env, admin: soroban_sdk::Address)

Refund the maximum refundable amount.

Sender-only. Returns the amount refunded.

fn refund_max(
    env: soroban_sdk::Env,
    stream_id: u64,
    sender: soroban_sdk::Address,
) -> i128

Adjust the rate per second of an active stream.

Sender-only. The stream must be actively streaming (not paused/voided).

fn adjust_rate(
    env: soroban_sdk::Env,
    stream_id: u64,
    sender: soroban_sdk::Address,
    new_rate: i128,
)

Get the stream's current balance.

fn get_balance(env: soroban_sdk::Env, stream_id: u64) -> i128

Permanently void a stream.

Callable by sender OR recipient. Writes off uncovered debt and prevents the stream from being restarted.

fn void_stream(env: soroban_sdk::Env, stream_id: u64, caller: soroban_sdk::Address)

Accept an admin transfer (two-step transfer, step 2).

Must be called by the address that was proposed via propose_admin().

fn accept_admin(env: soroban_sdk::Env)

Withdraw the maximum available amount from a stream.

Convenience function — withdraws the entire covered debt.

fn withdraw_max(
    env: soroban_sdk::Env,
    stream_id: u64,
    caller: soroban_sdk::Address,
    to: soroban_sdk::Address,
) -> i128

Propose a new admin (two-step transfer, step 1).

The proposed admin must call accept_admin() to complete the transfer. Admin-only.

fn propose_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)

Get the total debt owed (may exceed balance).

fn total_debt_of(env: soroban_sdk::Env, stream_id: u64) -> i128

Get the covered debt (debt backed by balance).

fn covered_debt_of(env: soroban_sdk::Env, stream_id: u64) -> i128

Execute a previously proposed upgrade after the timelock has expired.

Admin-only.

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

Propose a timelocked upgrade. The upgrade can be executed after UPGRADE_TIMELOCK_LEDGERS have passed.

Admin-only.

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

Get the time at which the stream's balance will be depleted.

fn depletion_time_of(env: soroban_sdk::Env, stream_id: u64) -> u64

Extend the TTL of a specific stream record.

Anyone can call this to keep a long-duration stream alive. Does not modify stream state.

fn extend_stream_ttl(env: soroban_sdk::Env, stream_id: u64)

Get the uncovered debt (debt exceeding balance).

fn uncovered_debt_of(env: soroban_sdk::Env, stream_id: u64) -> i128

Create a new Flow stream and immediately deposit tokens.

Convenience function combining create() + deposit().

fn create_and_deposit(
    env: soroban_sdk::Env,
    sender: soroban_sdk::Address,
    recipient: soroban_sdk::Address,
    token: soroban_sdk::Address,
    rate_per_second: i128,
    token_decimals: u32,
    start_time: u64,
    amount: i128,
) -> u64

Get the stream's rate per second.

fn get_rate_per_second(env: soroban_sdk::Env, stream_id: u64) -> i128

Get the refundable amount (excess balance not owed).

fn refundable_amount_of(env: soroban_sdk::Env, stream_id: u64) -> i128

Get the amount withdrawable by the recipient.

fn withdrawable_amount_of(env: soroban_sdk::Env, stream_id: u64) -> i128

Imports

WebAssembly Text (WAT) ▶