Skip to content

feat: add treasury liquidity controls - #232

Merged
Obiajulu-gif merged 1 commit into
Chainmove:mainfrom
OkeyAmy:implement-treasury-control-service
Aug 30, 2026
Merged

feat: add treasury liquidity controls#232
Obiajulu-gif merged 1 commit into
Chainmove:mainfrom
OkeyAmy:implement-treasury-control-service

Conversation

@OkeyAmy

@OkeyAmy OkeyAmy commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Prevent payouts/refunds from consuming liquidity that is not immediately available by defining treasury buckets and deterministic solvency checks.
  • Ensure all treasury math is reproducible, auditable, and uses integer minor units to avoid rounding ambiguity.

Description

  • Add a lightweight treasury service with integer-minor-unit bucket definitions, liquidity/solvency calculation, and hold decision logic (lib/treasury/service.ts).
  • Extend ledger account categories to include settlement_in_transit, refunds_payable, platform_reserve, and suspense, and add snapshot/adjustment models (models/TreasurySnapshot.ts, models/TreasuryAdjustmentProposal.ts, models/LedgerAccount.ts).
  • Add admin-only APIs to compute on-demand treasury summaries and create reproducible daily snapshots (app/api/admin/treasury/summary/route.ts) and to propose audited treasury adjustments that never mutate user balances (app/api/admin/treasury/adjustments/route.ts).
  • Add focused tests and documentation covering bucket definitions, reserve/concentration holds, snapshot reproducibility, and adjustment safeguards (__tests__/lib/treasury/service.test.ts, docs/treasury-controls.md).

Testing

  • Ran npm run lint and it passed.
  • Ran npm run typecheck and npm run typecheck:gate and both passed.
  • Ran the new unit tests with npx vitest run __tests__/lib/treasury/service.test.ts and they passed.
  • Ran contract tests with npm run test:contracts and the suite passed.
  • npm run openapi:check failed due to an existing OpenAPI generation drift unrelated to the treasury changes (the generator flagged contract drift for pre-existing consent-related paths).
  • npm run build did not complete successfully in this environment (the next build --webpack process was CPU-bound and was terminated), so a full production build should be verified in CI or locally.

Close #69
Close #80
Close #84
Close #69

@Obiajulu-gif
Obiajulu-gif merged commit ccd61eb into Chainmove:main Aug 30, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants