Soroban smart contracts for the Fluxora treasury streaming protocol on Stellar. Stream USDC from a treasury to recipients over time with configurable rate, duration, and cliff.
- Stream contract docs — Lifecycle, accrual formula, cliff/end_time, access control, events, and error codes.
- Stream contract (
contracts/stream) — Lock USDC, accrue per second, withdraw on demand. - Data model —
Stream(sender, recipient, deposit_amount, rate_per_second, start/cliff/end time, withdrawn_amount, status). - Status — Active, Paused, Completed, Cancelled.
- Methods (stubs) —
init,create_stream,pause_stream,resume_stream,cancel_stream,withdraw,calculate_accrued,get_stream_state. - Cancel semantics —
cancel_streamis valid only inActiveorPaused;CompletedandCancelledreturnInvalidState.
Implementation is scaffolded; storage, token transfers, and events are left for you to complete.
- Methods —
init,create_stream,pause_stream,resume_stream,cancel_stream,withdraw,calculate_accrued,get_stream_state,set_admin. - Admin functions —
pause_stream_as_admin,resume_stream_as_admin,cancel_stream_as_admin,set_adminfor key rotation.
Documentation: Audit preparation (entrypoints and invariants for auditors).
- Rust (edition 2021)
- soroban-sdk (Stellar Soroban)
- Build target:
wasm32-unknown-unknownfor deployment
Everything below runs locally. No secrets or mainnet access are required to build or test.
git clone https://github.com/Fluxora-Org/Fluxora-Contracts.git
cd Fluxora-Contracts- Rust 1.70+ (install from rustup.rs)
- Add the Soroban build target:
rustup target add wasm32-unknown-unknownStellar CLI is optional and only needed if you want to deploy to testnet later.
From the repo root:
# Development build (faster compile, for local testing)
cargo build -p fluxora_stream
# Release build (optimized WASM for deployment)
cargo build --release -p fluxora_streamRelease WASM output: target/wasm32-unknown-unknown/release/fluxora_stream.wasm.
To run all tests (unit and integration tests), use:
cargo test -p fluxora_streamThis runs unit tests and integration tests in one go. No environment variables or external services are required. Integration tests use Soroban’s in-process test environment (soroban_sdk::testutils): the contract and a mock Stellar asset are built in memory, so no emulator or network is needed.
Note: Tests rely on the testutils feature of the soroban-sdk to simulate the ledger environment and manipulate time (e.g., fast-forwarding to test cliff and end periods).
This feature is already enabled in contracts/stream/Cargo.toml under [dev-dependencies]. No extra environment setup is required.
The test files are located at:
-
Unit tests:
contracts/stream/src/test.rs -
Integration tests:
contracts/stream/tests/integration_suite.rs -
Unit tests:
contracts/stream/src/test.rs(contract logic, accrual, auth, edge cases). -
Integration tests:
contracts/stream/tests/integration_suite.rs— full flows withinit,create_stream,withdraw,get_stream_state, lifecycle and edge cases (double init, pre-cliff withdraw, unknown stream id, underfunded deposit).
To run only unit tests or only the integration suite:
cargo test -p fluxora_stream --lib
cargo test -p fluxora_stream --test integration_suiteIf you have the Stellar CLI configured (no secrets required in the repo):
stellar contract deploy \
--wasm-file target/wasm32-unknown-unknown/release/fluxora_stream.wasm \
--network testnetThen call init with your token and admin addresses, and use create_stream, withdraw, etc. as needed.
fluxora-contracts/
Cargo.toml # workspace
docs/
storage.md # storage layout and key design
contracts/
stream/
Cargo.toml
src/
lib.rs # contract types and impl
test.rs # unit tests
tests/
integration_suite.rs # integration tests (Soroban testutils)
- Storage Layout — Contract storage architecture, key design, and TTL policies
- Accrued =
min((current_time - start_time) * rate_per_second, deposit_amount) - Withdrawable =
Accrued - withdrawn_amount - Before
cliff_time: withdrawable = 0.
- fluxora-backend — API and Horizon sync
- fluxora-frontend — Dashboard and recipient UI
Each is a separate Git repository.