A member-owned lending DAO implemented as a single Soroban smart contract in Rust — about 4,800 lines across 14 focused modules, 210+ tests (unit, property and stateful), CI-gated on every push.
The execution model, storage layout, authorization, and value transfer are all Soroban-native. All DAO value flows through a single configurable token set at initialization (USDC, XLM via the Stellar Asset Contract, or any Stellar asset).
This repository is one of three that make up OurDAO:
| Repo | Role |
|---|---|
ourdao-contracts (this repo) |
The Soroban contract — the single source of truth for all DAO state |
ourdao-backend |
Off-chain indexer + read API, since Soroban keeps no queryable history |
ourdao-frontend |
Next.js web app members actually use |
- What the DAO does
- Additional feature modules
- Architecture & design decisions
- Layout
- Public interface (ABI)
- Event catalog
- Error codes
- Build & test
- Deploy to testnet
- Operator scripts
- Security notes
- Known limitations
- Roadmap
- Contributing
- License
- Resource costs
- Governance — a set of admins, a basis-points consensus threshold (default 51%), and a tunable loan policy. Admins can be added/removed (the last admin can never be removed, preventing a bricked DAO), the threshold and policy can be updated, and the whole contract can be paused/unpaused in an emergency.
- Membership — anyone can join by paying a membership fee in the DAO token; the fee becomes their pro-rata share in the treasury. A member who exits (and has no active loan) withdraws their share, their staked balance, and any pending yield in a single transaction. Rejoining after exit is handled correctly — it doesn't double-count a member's original contribution.
- Lending — members request loans that go through a fixed editable draft phase, then member voting weighted by stake-boosted voting power. On reaching the consensus threshold the loan is automatically approved and the principal disbursed from the treasury — no separate "execute" step. Interest is computed from a loan-size-relative-to-treasury curve, clamped to the policy's min/max rate. Repaying a loan returns the principal to the treasury and splits the interest across all active members as claimable yield.
- Loan defaults — an overdue loan (past
due_timeplus a configurable grace period) can be marked defaulted by anyone, not just an admin — an on-chain keeper pattern. Defaulting slashes a policy-defined share of the borrower's treasury claim and frees theirhas_active_loanflag, so they can still exit the DAO with their reduced share or borrow again after the normal cooldown. This closes what was previously the DAO's most notable functional gap: prior to this, an overdue loan had zero on-chain consequence. - Treasury — any member can propose a withdrawal to any destination; execution requires a higher (60%) consensus than loan approval, reflecting the larger blast radius of moving treasury funds arbitrarily.
- Safety — admins can pause and unpause the DAO, and can assign or revoke one emergency pauser. The pauser can only trigger a pause; only an admin can unpause unless the pauser is independently an admin. Pausing blocks ordinary state-changing operations except loan repayments, which remain available to prevent forcing borrowers into default. See Pause functionality for details.
- Yield is equal-split. Interest repaid on a loan is divided equally among active members at the time of repayment (one member, one share), via an O(1) accumulator. Contribution size does not change a member's yield.
- Exit share is contribution-weighted. On exit a member receives
treasury × their contribution ÷ total active contributions. Yield rewards participation; the exit share returns capital. - Defaulters. When a loan is marked defaulted, the borrower's contribution is slashed by
default_penalty_bpsand they forfeit any yield accrued but unclaimed at that moment (it stays in the treasury). They remain active members and earn an equal share of interest repaid afterwards, until they exit.
| How it ended | status |
phase |
Event |
|---|---|---|---|
| Voting window closed without quorum | Expired |
Expired |
loan_exp |
| Quorum became unreachable before the deadline | Rejected |
Expired |
loan_rej |
| Cancelled by the borrower during editing | Cancelled |
Expired |
prop_canc |
Every view that reads DAO configuration or the registry (get_token, get_admins, is_admin, get_loan_policy, get_consensus_threshold, get_treasury_balance, calculate_loan_terms, calculate_exit_share, resolve_name, name_of, get_document) returns Error::NotInitialized before initialize has run, instead of trapping or returning an ambiguous None. Call is_initialized() first to probe an unknown address. Per-record lookups such as get_member and get_loan still return None for a missing record.
Four Soroban-native features beyond the core lending/treasury flow, each fully implemented — not stubbed out:
| Feature | Description | Module |
|---|---|---|
| Name registry | On-chain name registry (name ⇄ address, 1:1) | registry.rs |
| Content-hash metadata | Anchor an IPFS CID / digest to a loan or treasury proposal | docs.rs |
| Commit-reveal voting | Commit-reveal voting for private treasury proposals (sha256(support ++ salt), revealed later, tallied through the same code path as public votes) |
privacy.rs |
| Staking | Staking for a capped voting-weight boost (1 base vote + up to 5 bonus, on a quadratic curve: the k-th bonus vote costs k² × 100 staked tokens), tracked separately so staked funds are never lent out or counted as treasury |
staking.rs |
-
Single-contract design. Every module (
admin,membership,loans,treasury,registry,docs,privacy,staking) lives inside one#[contract]struct (lib.rs) rather than being split into separate deployed contracts. This keeps cross-module invariants (e.g. a member'shas_active_loanflag, staked funds excluded from treasury balance) enforceable in normal Rust function calls instead of cross-contract calls. -
loan.id == proposal.id, always. A loan proposal that gets approved disburses exactly one loan, so the loan reuses the proposal's own id rather than drawing from a separate counter. This was a deliberate fix (see theKnown limitationshistory below) — two independent counters looked harmless but silently diverged the moment any proposal was rejected, breaking the off-chain indexer's ability to correlate a loan back to the request that created it. -
Permissionless keeper calls. Some entrypoints need no authorization from anyone, member or not, because they only carry out an outcome that is already fixed on-chain. The caller picks nothing but when:
Entrypoint Callable once Fixed on-chain, caller cannot change Repeat calls mark_loan_defaulteddue_time+ grace period has passedborrower, penalty rejected ( LoanNotActive)disburse_approved_loanthe loan vote passed and the treasury can cover it borrower, principal rejected ( NotInVotingPhase)execute_treasury_proposalthe withdrawal vote passed and the treasury can cover it destination, amount rejected ( NotInVotingPhase)expire_loan_proposalthe voting window closed without quorum — no-op The caller pays the transaction fee and receives nothing, so there is no incentive to grief; restricting these to admins would only add liveness risk, letting one absent party block an outcome the DAO already reached. Tests drive
disburse_approved_loanandexecute_treasury_proposalfrom a non-member with no auth at all, so adding arequire_authto either fails CI. Anyone running a keeper bot can watch forloan_wait/tre_waitevents and retry once the treasury is refilled. -
Commit-reveal privacy shares the public tally path. Rather than duplicating vote-counting logic for private proposals,
privacy::reveal_voterecomputes and checks the commitment, then hands off to the sametreasury::tallyfunction public votes use — one code path, no risk of the two diverging. -
TTL-aware storage. All persistent storage entries (members, loans, proposals, votes, stakes, documents) extend their time-to-live on every read/write (30-day bump for instance storage, 90-day for persistent), so active DAO data doesn't silently expire under Soroban's state archival model.
-
Stable, append-only error codes.
error.rs's numeric codes are documented as part of the contract's public ABI — new failure modes get a new number rather than renumbering existing ones, so client code that matches on error codes doesn't silently break across contract upgrades (see Known limitations — there is currently no upgrade path at all, which makes this moot today but is kept as forward-looking discipline).
contracts/dao/
src/
lib.rs # contract entrypoints (the public ABI) + views
admin.rs # init, admins, threshold, policy, pause
membership.rs # join, exit, claim yield, exit-share math
loans.rs # request -> edit -> vote -> disburse -> repay -> default -> interest
treasury.rs # propose -> vote -> execute (shared tally)
registry.rs # name registry
docs.rs # content-hash proposal metadata
privacy.rs # commit-reveal voting
staking.rs # voting-weight staking
storage.rs # typed storage keys + TTL management
types.rs # data model + constants
error.rs # contract error codes
migration.rs # admin-only state seeding for migrations, then lock_seeding
util.rs # token client, auth guards, vote math
tests/ # test suite, one module per contract module (`cargo test`)
scripts/
deploy-testnet.sh # builds, deploys AND initializes; --dry-run, guarded against non-testnet
export-state.sh # dumps a deployed DAO's live state to JSON via read-only views
keeper.sh # permissionless keeper: marks overdue loans defaulted, expires stale proposals
All public entrypoints and views on OurDao are listed below in source order, generated from the pub fn declarations in lib.rs. Run scripts/generate-abi.sh --markdown to print the table. Errors are the numeric Error codes below.
The generated source of truth for the full interface (every argument, return type, #[contracttype] and error code, extracted from the compiled wasm) is contract/contract-interface.json, with a readable Rust-signature form in contract/interface-summary.txt. Both are regenerated by ./scripts/generate-abi.sh and CI fails if they drift from the source. A TypeScript client generated from the same wasm lives in bindings/ts/.
| Method |
|---|
initialize |
add_admin |
remove_admin |
set_pauser |
revoke_pauser |
set_consensus_threshold |
propose_policy_update |
execute_policy_update |
cancel_policy_update |
set_loan_policy |
pause |
unpause |
register_member |
exit_dao |
claim_rewards |
claim_rewards_in_asset |
delegate_vote |
request_loan |
request_loan_in_asset |
edit_loan_proposal |
cancel_loan_proposal |
vote_on_loan_proposal |
vote_batch |
disburse_approved_loan |
repay_loan |
repay_loan_in_asset |
repay_loan_partial |
mark_loan_defaulted |
expire_loan_proposal |
request_loan_extension |
vote_on_loan_extension |
propose_treasury_withdrawal |
propose_withdrawal_in_asset |
vote_on_treasury_proposal |
cancel_treasury_proposal |
expire_treasury_proposal |
execute_treasury_proposal |
bump_dao_ttl |
stake |
unstake |
register_name |
release_name |
resolve_name |
name_of |
commit_treasury_vote |
reveal_treasury_vote |
verify_commitment |
get_commit_reveal_window |
attach_document |
get_document |
get_member |
get_member_loan_stats |
get_member_overview |
get_loan |
get_loan_extension |
get_loan_proposal |
get_treasury_proposal |
get_loan_proposal_count |
get_treasury_proposal_count |
get_loan_policy |
get_pending_policy_update |
get_admins |
is_admin |
is_member |
is_eligible_for_loan |
get_treasury_balance |
get_treasury_balance_in_asset |
get_treasury_accounting |
get_total_members |
get_active_members |
get_consensus_threshold |
get_token |
is_initialized |
get_dao_summary |
propose_token_addition |
execute_token_addition |
remove_token |
is_token_whitelisted |
get_whitelisted_tokens |
get_pending_token_addition |
get_pending_token_additions |
is_paused |
get_version |
get_stake |
get_voting_weight |
get_stake_weight_unit |
get_max_stake_bonus |
get_pending_yield |
get_pending_yield_in_asset |
get_delegate |
has_voted |
calculate_loan_terms |
calculate_exit_share |
list_members |
list_treasury_proposals |
list_loans |
seed_members |
seed_stakes |
seed_pending_yield |
seed_loans |
seed_names |
seed_docs |
lock_seeding |
is_seeding_locked |
Each published topic and its event payload are listed below. ourdao-backend indexes these events because Soroban does not keep queryable history.
| Topic | Payload | Emitted by |
|---|---|---|
init |
(admins, consensus_threshold, membership_fee, token) |
initialize |
admin_add |
admin |
add_admin |
admin_rem |
admin |
remove_admin |
pset |
(old_pauser, new_pauser) |
set_pauser |
prev |
(old_pauser, caller) |
revoke_pauser |
threshold |
(old_threshold, new_threshold) |
set_consensus_threshold |
pol_prop |
(caller, execution_time) |
propose_policy_update |
policy |
(old_policy, new_policy) |
execute_policy_update |
pol_canc |
caller |
cancel_policy_update |
paused |
caller |
pause |
unpaused |
caller |
unpause |
tok_prop |
(caller, token, execution_time) |
propose_token_addition |
tok_add |
(caller, token) |
execute_token_addition |
tok_rem |
(caller, token) |
remove_token |
joined |
(member, fee) |
register_member |
name_rel |
(old_name, owner) |
register_name when replacing a name; release_name; exit_dao |
exited |
(member, share, pending_base_yield) |
exit_dao |
exit_a |
(member, asset, amount) |
exit_dao when paying non-base yield |
claimed |
StakingRewardClaimed { member, amount, timestamp } (the topics also include member and pending) |
claim_rewards for the base token |
clm_ast |
(member, asset, pending) |
claim_rewards_in_asset for a non-base asset |
delegate |
(delegator, delegatee) |
delegate_vote |
loan_asst |
(id, asset) |
request_loan_in_asset when the asset is not the base token |
loan_req |
(id, borrower, amount, total_repayment, asset) |
request_loan / request_loan_in_asset |
loan_edit |
(proposal_id, borrower, new_amount, total_repayment) |
edit_loan_proposal |
loan_vote |
(proposal_id, voter, support) |
vote_on_loan_proposal / vote_batch |
loan_wait |
(proposal_id, amount) |
vote_on_loan_proposal / vote_batch when an approved loan cannot be disbursed immediately |
loan_rej |
(proposal_id, for_votes, against_votes) |
vote_on_loan_proposal / vote_batch when approval becomes unreachable |
loan_appr |
(id, borrower, amount, due_time, asset) |
Loan disbursement after approval; id is also the proposal ID |
loan_rpy |
(loan_id, borrower, remaining, asset) |
repay_loan / repay_loan_partial / repay_loan_in_asset |
interest |
(interest, active_members, asset) |
Interest distribution during loan repayment |
loan_dflt |
(loan_id, borrower, penalty) |
mark_loan_defaulted |
loan_exp |
(proposal_id, borrower) |
expire_loan_proposal |
ext_req |
(loan_id, borrower, extra_time, fee) |
request_loan_extension |
ext_vote |
(loan_id, voter, support) |
vote_on_loan_extension |
ext_appr |
(loan_id, new_due_time, new_total_repayment) |
vote_on_loan_extension when the request is approved |
ext_rej |
(loan_id, for_votes, against_votes) |
vote_on_loan_extension when approval becomes unreachable |
prop_canc |
(proposal_id, timestamp) |
cancel_loan_proposal / cancel_treasury_proposal (proposal-cancelled event) |
tre_asset |
(id, asset) |
propose_withdrawal_in_asset when the asset is not the base token |
tre_prop |
(id, amount, destination, private) |
propose_treasury_withdrawal / propose_withdrawal_in_asset |
tre_vote |
(id, voter, support) |
vote_on_treasury_proposal / reveal_treasury_vote |
tre_wait |
(proposal_id, amount) |
Treasury vote when an approved withdrawal cannot execute immediately |
tre_rej |
(proposal_id, for_votes, against_votes) |
Treasury vote when approval becomes unreachable |
tre_exec |
(id, amount, destination) |
Treasury proposal execution |
tre_exp |
(proposal_id, proposer) |
expire_treasury_proposal |
name_reg |
(name, owner) |
register_name |
committed |
(proposal_id, voter) |
commit_treasury_vote |
revealed |
(proposal_id, voter, support) |
reveal_treasury_vote |
staked |
(member, amount, new_stake, voting_weight) |
stake |
unstaked |
(member, amount, new_stake, voting_weight) |
unstake |
doc_attn |
(kind, proposal_id, caller) |
attach_document |
TtlBumped |
() |
bump_dao_ttl |
Numeric codes are stable and part of the ABI — new variants get appended rather than renumbering existing ones.
| Code | Variant |
|---|---|
| 1 | AlreadyInitialized |
| 2 | NotInitialized |
| 3 | InvalidThreshold |
| 4 | InvalidAmount |
| 5 | InvalidLoanPolicy |
| 6 | Paused |
| 7 | NotPaused |
| 10 | NotAuthorized |
| 11 | NotAdmin |
| 12 | NotMember |
| 13 | AlreadyAdmin |
| 14 | AlreadyMember |
| 15 | CannotRemoveLastAdmin |
| 20 | MemberNotActive |
| 21 | HasActiveLoan |
| 30 | ProposalNotFound |
| 31 | NotBorrower |
| 32 | NotInEditingPhase |
| 33 | NotInVotingPhase |
| 34 | VotingEnded |
| 35 | AlreadyVoted |
| 36 | NotEligibleForLoan |
| 37 | CooldownActive |
| 38 | LoanNotFound |
| 39 | LoanNotActive |
| 40 | ExceedsTreasuryRatio |
| 41 | InsufficientTreasury |
| 42 | LoanNotOverdue |
| 50 | TreasuryProposalNotFound |
| 60 | NameTaken |
| 61 | NameNotFound |
| 62 | NoStake |
| 63 | InsufficientStake |
| 64 | NoCommitment |
| 65 | CommitmentMismatch |
| 66 | AlreadyRevealed |
| 67 | NothingToClaim |
| 70 | ProposalNotExpired |
| 71 | InvalidName |
| 72 | NotYetRevealed |
| 73 | NotProposalOwner |
| 74 | DocumentTooLarge |
| 75 | InvalidToken |
| 76 | TimelockNotExpired |
| 77 | NoPendingPolicy |
| 78 | InvalidMetadataCid |
| 79 | InvalidDelegation |
| 80 | InvalidProposal |
| 81 | AlreadyPauser |
| 82 | NotPauser |
| 83 | TokenNotWhitelisted |
| 84 | TokenAlreadyWhitelisted |
| 85 | NoPendingTokenAddition |
| 86 | AssetMismatch |
| 87 | CannotRemoveBaseToken |
| 88 | SeedingLocked |
| 89 | SeedingAlreadyLocked |
| 90 | TooManyOpenProposals |
| 91 | BorrowerCannotVote |
| 92 | TokenHasBalance |
| 93 | TokenHasActiveLoans |
| 94 | DefaultedLoanOutstanding |
| 95 | WhitelistFull |
| 96 | TransferAmountMismatch |
| 97 | JoinedAfterProposal |
| 98 | TooManyAdmins |
| 99 | TooManyVotesInBatch |
| 100 | ArithmeticOverflow |
| 101 | SeedLoanMemberMismatch |
| 102 | ExtensionAlreadyRequested |
| 103 | ExtensionWindowClosed |
| 104 | InvalidExtension |
| 105 | ExtensionNotFound |
Requires the Rust wasm32v1-none target (Rust 1.84+) and the stellar CLI.
# Native unit tests — including loan defaults, commit-reveal privacy,
# staking-boosted voting, and property tests over the exit-share, interest,
# and staking-weight math
cargo test
# Formatting check (matches CI)
cargo fmt --check
# Lint (matches CI — warnings fail the build)
cargo clippy --all-targets -- -D warnings
# Dependency advisories (matches CI, informational — see the audit job note below)
cargo install cargo-audit --locked # one-time
cargo audit
# Release wasm
cargo build --target wasm32v1-none --release
# Optimized, deployment-ready wasm
stellar contract build --optimizeCI (.github/workflows/ci.yml) first runs a fast check job (cargo check --locked --all-targets) that the other build jobs depend on, then runs cargo fmt --check, cargo clippy -- -D warnings, cargo test, and the wasm build in one job on every push and PR. A separate audit job runs cargo audit on the same triggers — it's split out so a newly published advisory (which can land against a pin we already know about and can't move, like the one below) surfaces visibly without blocking merges on unrelated PRs.
Note on dependencies:
Cargo.lockpinsed25519-dalekto2.2.0. A newer transitive release (3.0.0) is incompatible with the pinnedrand_coreused bysoroban-env-hostand breaks the test build if allowed to float. The lockfile is committed to keep builds reproducible.
The quickest path is the helper script. It creates and funds a deployer
identity (via friendbot), builds the optimized wasm, prints the wasm SHA-256,
asks for confirmation, deploys, and then runs initialize in the same
invocation so a contract is never left deployed-but-uninitialized (which would
let anyone front-run initialize):
./scripts/deploy-testnet.sh --dry-run # print every command, change nothing
./scripts/deploy-testnet.sh # the real thing (asks for confirmation)By default the DAO uses the native XLM Stellar Asset Contract, with the deployer as the only admin. Override the defaults with environment variables:
IDENTITY=my-key ALIAS=ourdao-dao TOKEN=<token-contract-id> \
ADMINS_JSON='["G...","G..."]' CONSENSUS_THRESHOLD=5100 MEMBERSHIP_FEE=10000000 \
./scripts/deploy-testnet.shOn testnet the script also deploys a second test asset (SECOND_ASSET_CODE, default
OURTESTB) issued by the deployer, and proposes it for the treasury whitelist. Whitelisting
is timelocked for 48 hours, so the script ends by printing the execute_token_addition
command to run once that has passed.
POLICY_JSON overrides the default loan policy; see ./scripts/deploy-testnet.sh --help
for every option. If initialize fails after the deploy, the script says so
loudly and exits non-zero: initialize that contract immediately or discard it.
The script refuses any network other than testnet unless you pass
--allow-non-testnet (an exported NETWORK=mainnet alone does nothing). For
another network it is deliberately stricter:
- it never generates or funds keys: the deployer identity must already exist,
TOKENmust be set explicitly (there is no default asset),- it needs an interactive terminal and you must type the network name to
confirm;
--yesdoes not skip this.
./scripts/deploy-testnet.sh --dry-run --allow-non-testnet --network mainnet # review first
TOKEN=<usdc-contract-id> IDENTITY=<existing-key> \
./scripts/deploy-testnet.sh --allow-non-testnet --network mainnetThe contract cannot be upgraded after deployment, so review the dry run, check
the printed wasm SHA-256 against a release (see DEPLOYMENTS.md), and get the
audit items in docs/AUDIT_PREPARATION.md closed before deploying real funds.
Or deploy manually:
stellar contract deploy \
--wasm target/wasm32v1-none/release/ourdao_dao.optimized.wasm \
--network testnet \
--source <your-identity> \
--alias ourdao-daoAfter deploying, initialize the DAO with your admin set, consensus threshold
(bps), membership fee, DAO token contract id, and loan policy. The script
prints a filled-in example; the token id can be the testnet USDC contract or
the native XLM Stellar Asset Contract (stellar contract id asset --asset native --network testnet).
Both scripts take a contract id and default to testnet (--network <name> to change it). They need the stellar CLI and jq.
Exporting state. scripts/export-state.sh <contract-id> --out state.json reads the DAO's state through read-only views and writes it as one JSON document. It submits nothing. It warns when some members can't be read because their storage has expired. This is step 3 of the migration procedure.
Keeper. scripts/keeper.sh runs the time-based transitions that anyone may trigger:
mark_loan_defaultedfor each active loan pastdue_time + default_grace_period;expire_loan_proposalandexpire_treasury_proposalfor proposals whose voting window has closed.
It does nothing while the contract is paused, and exits non-zero if any call fails so cron or monitoring can alert on it. Run it with --dry-run first to see what it would submit. The identity that pays the fees must already exist:
stellar keys generate ourdao-keeper --network testnet --fund
./scripts/keeper.sh --dry-run --network testnet <contract-id>To run it every 15 minutes from cron:
*/15 * * * * IDENTITY=ourdao-keeper /path/to/ourdao-contracts/scripts/keeper.sh --network testnet <contract-id> >> ~/ourdao-keeper.log 2>&1Found a vulnerability? See SECURITY.md for scope and how to report it privately.
- No reentrancy surface. Soroban's execution model has no arbitrary external calls back into the contract mid-execution from an untrusted token, but all balance-changing operations still follow check-effects-interactions ordering (state updated before/alongside the token transfer, not after).
- Auth is enforced per-call, not assumed. Every state-changing entrypoint that moves a specific member's funds or represents their vote calls
require_auth()on that member's own address — a caller cannot act on behalf of another address. mark_loan_defaultedis intentionally unauthenticated. This is a deliberate design choice, not an oversight: the action is purely a function of on-chain time and existing loan state, so there is nothing to authorize — restricting it to admins would just add unnecessary liveness risk (an admin going offline shouldn't block defaults from being recorded).- This contract has not been externally audited. It is a testnet-stage prototype. Do not deploy to mainnet with real value without an independent security review first.
- No upgrade path. The contract is immutable once deployed — a deliberate trust-minimization tradeoff, not an oversight. Migrating to a new version requires a fresh deployment; see
docs/MIGRATION.mdfor the procedure, what state can and can't be carried over, and the trust assumption a migration necessarily introduces. - Testnet-only deploy tooling, consistent with this project's current testnet-stage positioning.
Loan defaults had zero on-chain consequence— fixed; see What the DAO does.— fixed by removing the separate loan-id counter; a loan now always reuses its proposal's id, with a regression test locking in the invariant.loan.idcould silently diverge from its originatingproposal.idInterest distribution was O(n) over every member— fixed with a pull-based yield accumulator: O(1) on repay, each member settles lazily on claim/exit.
- External security audit before any mainnet consideration.
- Implement the
seed_statemigration entrypoint designed indocs/MIGRATION.md(the doc itself is done; the contract-side entrypoint is a follow-up). - Deeper integration testing against
ourdao-backend's indexer (event schema drift detection). TheIntegration Testworkflow is a placeholder for this and is disabled (it runs only when triggered by hand, never on push or PR) until the scripts it calls exist:scripts/start-local-network.sh,scripts/run-test-actions.sh,scripts/start-backend-indexer.shandscripts/assert-db-rows.sh(#444).
Contributions are welcome — see CONTRIBUTING.md for local setup, the checks CI enforces, and the contract-specific rules (append-only error codes, events on every state change, TTL discipline). Stellar Wave contributors should follow the Stellar Wave workflow. Please claim an issue before opening a pull request.
Found a security vulnerability? See SECURITY.md — don't open a public issue.
MIT
Measured against the optimized release wasm (58,457 bytes) with the SDK's
invocation metering, in a 10-member DAO. Regenerate with make costs
(source: tests/costs.rs).
| Entrypoint | CPU instructions | Memory (KiB) | Entries read | Entries written | Bytes written | Event bytes | Est. fee (stroops) |
|---|---|---|---|---|---|---|---|
register_member |
1,737,105 | 1,372 | 9 | 6 | 2,676 | 376 | 7,291,448 |
stake |
1,567,392 | 1,363 | 10 | 6 | 2,348 | 396 | 2,821,539 |
register_name |
1,148,775 | 1,313 | 6 | 3 | 348 | 136 | 3,742,731 |
add_admin |
984,100 | 1,305 | 4 | 2 | 1,656 | 112 | 1,443,823 |
propose_policy_update |
1,000,164 | 1,306 | 4 | 2 | 2,304 | 132 | 3,202,621 |
request_loan |
1,888,826 | 1,362 | 8 | 3 | 3,032 | 168 | 7,416,978 |
attach_document |
1,491,392 | 1,320 | 7 | 2 | 224 | 152 | 2,642,299 |
edit_loan_proposal |
1,567,566 | 1,330 | 9 | 2 | 764 | 172 | 1,396,598 |
vote_on_loan_proposal |
2,386,168 | 1,417 | 19 | 3 | 908 | 140 | 2,593,677 |
vote_on_loan_proposal (deciding vote, disburses) |
3,291,980 | 1,480 | 25 | 7 | 2,304 | 540 | 6,492,906 |
repay_loan_partial |
1,793,716 | 1,394 | 10 | 6 | 3,404 | 504 | 1,579,588 |
repay_loan |
1,761,672 | 1,369 | 10 | 5 | 1,468 | 384 | 1,370,815 |
claim_rewards |
1,513,351 | 1,350 | 9 | 4 | 676 | 500 | 1,352,370 |
mark_loan_defaulted |
1,594,180 | 1,348 | 4 | 3 | 3,344 | 152 | 293,969 |
propose_treasury_withdrawal |
2,034,857 | 1,394 | 10 | 3 | 3,108 | 156 | 6,689,526 |
vote_on_treasury_proposal |
2,098,089 | 1,363 | 19 | 3 | 820 | 136 | 2,627,282 |
vote_on_treasury_proposal (deciding vote, pays out) |
2,671,416 | 1,461 | 24 | 5 | 1,268 | 520 | 3,330,146 |
unstake |
1,968,115 | 1,406 | 11 | 5 | 3,100 | 396 | 1,377,027 |
exit_dao |
3,646,895 | 1,500 | 20 | 6 | 3,616 | 376 | 1,399,042 |
get_member |
853,651 | 1,276 | 3 | 0 | 0 | 0 | 2,135 |
get_member_loan_stats |
830,372 | 1,275 | 3 | 0 | 0 | 0 | 2,076 |
get_voting_weight |
1,376,242 | 1,291 | 14 | 0 | 0 | 0 | 3,441 |
calculate_exit_share |
2,325,631 | 1,332 | 15 | 0 | 0 | 0 | 5,815 |
is_eligible_for_loan |
956,945 | 1,283 | 3 | 0 | 0 | 0 | 2,393 |
get_treasury_balance |
986,734 | 1,299 | 4 | 0 | 0 | 0 | 2,467 |
/// Owner of the proposal, or None if it does not exist. One storage read. fn proposal_owner_opt(env: &Env, kind: &ProposalKind, id: u64) -> Option
{ match kind { ProposalKind::Loan => storage::get_loan_proposal(env, id).map(|p| p.owner), ProposalKind::Treasury => storage::get_treasury_proposal(env, id).map(|p| p.owner), } }How to read it:
- Fees use the pubnet fee snapshot built into
soroban-sdk26 (1 XLM = 10,000,000 stroops) and include rent, which is why calls that create persistent entries (register_member,request_loan,propose_treasury_withdrawal) cost the most: each new entry is prepaid for its 90-day TTL. Treat them as estimates; simulate the transaction against the live network for an exact quote. - Memory is dominated by instantiating the wasm module (about 1.25 MiB for any call) and does not affect the fee.
- Views cost nothing on-chain when called through simulation; their row is what they would cost inside a transaction.
- Not measured:
delegate_votecurrently traps (it callsrequire_authtwice on the delegator), commit/reveal voting (the reveal path fails its own tests onmain), and the*_in_assetvariants (#354).
The member list lives in instance storage, so every call loads it, but only
a few entrypoints visit each member. Cells are CPU instructions / ledger entries touched at exactly that many members (make costs prints this
table too):
| Members | get_total_members |
register_member |
vote_on_loan_proposal |
vote_on_treasury_proposal |
exit_dao |
|---|---|---|---|---|---|
| 10 | 766,963 / 2 | 1,722,482 / 15 | 2,215,574 / 21 | 1,950,623 / 21 | 3,286,408 / 25 |
| 25 | 777,325 / 2 | 1,921,613 / 15 | 3,670,987 / 36 | 2,800,960 / 36 | 5,265,285 / 40 |
| 50 | 792,756 / 2 | 2,253,660 / 15 | 7,295,789 / 61 | 4,349,551 / 61 | 8,659,901 / 65 |
| 85 | 814,438 / 2 | 2,703,817 / 15 | 14,873,074 / 96 | 6,761,284 / 96 | 13,786,173 / 100 |
| 86 | 815,964 / 2 | 2,716,112 / 15 | 15,131,987 / 97 | 6,843,860 / 97 | 13,944,993 / 101 (over) |
| 89 | 816,942 / 2 | 2,753,297 / 15 | 15,927,542 / 100 | 7,067,432 / 100 | 14,380,177 / 104 (over) |
| 90 | 818,468 / 2 | 2,765,692 / 15 | 16,198,117 / 101 (over) | 7,143,798 / 101 (over) | 14,513,552 / 105 (over) |
| 100 | 823,828 / 2 | 2,885,388 / 15 | 19,014,001 / 111 (over) | 7,885,264 / 111 (over) | 16,041,560 / 115 (over) |
CPU stays far below the per-transaction instruction limit; ledger entries
are the binding constraint. A vote touches members + 11 entries because
voting_weight reads every member's delegation record, and exit_dao
touches members + 15 because the exit share sums every member's
contribution. Against the per-transaction footprint of 100 entries in the
SDK's mainnet snapshot (marked "over"), exit_dao fails from 86 members
and voting from 90 members. Testnet allowed 400 entries when this was
measured (protocol 29, October 2026), which moves the ceilings to 386 and
390; check current values with stellar network settings --network <name>.
Raising the ceiling needs those scans replaced with running totals kept up
to date on join, exit, default and delegation.
For a fast CI run:
cargo test -p ourdao-dao stateful_actions_preserve_invariants
cargo test -p ourdao-dao distribute_interest_preserves_tokens
cargo test -p ourdao-dao member_counters_match_member_records_across_join_exit_rejoin
