This document provides a function-level reference for each FlowFi contract. For architecture context, see architecture.md.
All contracts are deployed to Stellar Testnet for development. Mainnet deployment is pending security review.
Path: contracts/vault/src/lib.rs
Sets up the vault with an admin and the underlying token. Must be called once after deployment.
| Param | Type | Description |
|---|---|---|
| admin | Address | Protocol admin |
| token | Address | Stellar token contract address |
Deposits amount of the underlying token and mints shares to from.
Returns the number of shares minted.
Requires from to authorize the call.
| Param | Type | Description |
|---|---|---|
| from | Address | Depositing user |
| amount | i128 | Token amount (in token's smallest unit) |
Events emitted: ("deposit", from) → (amount, shares_minted)
Burns shares and returns the proportional underlying asset amount to from.
Returns the number of underlying tokens returned.
| Param | Type | Description |
|---|---|---|
| from | Address | Withdrawing user |
| shares | i128 | Number of shares to burn |
Events emitted: ("withdraw", from) → (shares, assets_out)
Returns the share balance of a given user.
Returns total assets held in the vault. Note: Does not include assets deployed to strategies yet.
Returns total shares outstanding.
Returns the current share price in 6-decimal fixed point (1_000_000 = 1.0).
Path: contracts/rewards/src/lib.rs
Initializes the rewards engine.
| Param | Type | Description |
|---|---|---|
| admin | Address | Admin address |
| reward_token | Address | Token to pay out as rewards |
| vault | Address | Associated vault address |
| reward_rate | i128 | Rewards per ledger, scaled by 1e9 |
Calculates and stores newly accrued rewards for user. Should be called before any balance change.
Claims all pending rewards for user. Transfers reward tokens and returns the amount claimed.
Requires user to authorize.
Events emitted: ("CLAIM", user) → amount_claimed
Read-only. Returns total pending rewards including unchecked accrual.
Updates the total share count tracked by the rewards engine. Only callable by the vault.
Updates the reward rate. Admin only.
Returns the total rewards paid out since genesis.
Path: contracts/strategy_router/src/lib.rs
Sets up the router with role addresses.
Registers a new strategy. Admin only. Weight is in basis points (100 bps = 1%).
Marks a strategy as inactive. Admin only. Does not currently pull funds.
Updates a strategy's allocation weight. Strategist only.
Records capital allocation to a strategy. Currently updates accounting only — no token movement.
Returns metadata for a registered strategy.
pub struct StrategyInfo {
pub address: Address,
pub weight_bps: u32,
pub active: bool,
pub allocated: i128,
}Returns all registered strategy addresses.
Returns sum of all strategy allocations.
Path: contracts/access_control/src/lib.rs
Sets the initial admin.
Returns current admin.
Returns current strategist, if assigned.
Transfers admin role. Current admin must authorize.
Assigns strategist role. Admin only.
Checks if an address is admin.
Checks if an address is strategist.
Panics if caller is not admin. Used internally by other contracts.
Panics if caller is not strategist.
Currently, errors are expressed as panics with string messages. This is intentionally naive.
Planned improvement: Define a unified FlowFiError enum and use it across all contracts. This is a great intermediate-level contribution.
Addresses will be updated after testnet deployment. See
scripts/deploy.shfor deployment steps.
| Contract | Address |
|---|---|
| Vault | TBD |
| Rewards | TBD |
| Strategy Router | TBD |
| Access Control | TBD |