Soroban smart contracts for Refract — trustless, oracle-triggered parametric insurance on Stellar.
This repository holds the three on-chain contracts that make up Refract's settlement layer. For the protocol overview, backend, and web app see the sibling repositories:
| Repo | Role |
|---|---|
| refract-contracts (this repo) | Soroban contracts: pool, policy registry, oracle |
refract-backend |
Oracle monitoring, claim processing, REST/WebSocket API |
refract-frontend |
Next.js web app for policyholders & capital providers |
| Crate | Contract | Responsibility |
|---|---|---|
pool/ |
RefractPool |
Holds USDC risk capital, prices & sells policies, settles claims against oracle data |
policy/ |
RefractPolicyRegistry |
Queryable on-chain index of policies per holder (sidecar to the pool) |
oracle/ |
RefractOracle |
Permissioned price/event feed with staleness enforcement and trigger evaluation |
All amounts use 1e7 fixed-point (the Stellar USDC convention). The contracts are #![no_std] and never touch floating point.
- Rust (stable) with the
wasm32-unknown-unknowntarget:rustup target add wasm32-unknown-unknown
- Stellar CLI for deployment (
stellar)
cargo test # run the unit-test suite
cargo fmt --all --check # formatting
cargo clippy --all-targets -- -D warnings # lints
cargo build --target wasm32-unknown-unknown --release # optimized wasmThe release .wasm artifacts land in target/wasm32-unknown-unknown/release/.
Deploy in dependency order — the oracle first, then the pool, then the registry:
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/refract_oracle.wasm \
--source alice --network testnet
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/refract_pool.wasm \
--source alice --network testnet
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/refract_policy.wasm \
--source alice --network testnetThen initialize each contract (admin, USDC token address, and pool↔registry wiring).
- RefractPool —
provide_capital,withdraw_capital, andbuy_policyrequire the caller's auth.update_oracleis admin-only. - RefractOracle — only registered relayers (or the admin) may
submit; readings older than 30 minutes are rejected. - RefractPolicyRegistry — only the registered pool contract or the admin may
register_policy/deactivate_policy.
SECURITY.md.
We welcome contributors — see CONTRIBUTING.md and our CODE_OF_CONDUCT.md.