Skip to content

Deploy and fund the reserve from the admin panel - #225

Merged
luchobonatti merged 4 commits into
mainfrom
feat/193-treasury
Oct 13, 2026
Merged

luchobonatti merged 4 commits into
mainfrom
feat/193-treasury

Conversation

@luchobonatti

Copy link
Copy Markdown
Member

Summary

Part of #193

The treasury deploys reserve to the custodian, and any Cycle role funds the reserve, from the Cycle card on /admin.

Changes

  • useDeployToCustodian and useFund call the vault through useContractTransaction; fund refreshes the funder's balance
  • toCycleActions checks deploy against wind-down, the custodian and the free reserve, and fund against the wallet balance
  • The Reserve group ends with both actions: amount field ("Use max" fills the exact free reserve), conditions, resulting state, button
  • TransactionModal gains the deploy and fund actions with the vault's errors mapped; a token refusal on fund names the wallet

Acceptance criteria

  • Deploy to custodian is shown to the treasury only; fund to every Cycle role
  • Each button is enabled only when every listed condition is met
  • The resulting reserve is shown before signing, with exact amounts
  • Refusals name the reason in the modal

Test plan

Automated tests

npm run test — 906 passing.

Manual verification

  1. On a local network, open /admin as the treasury: the Reserve group shows Deploy to custodian and Fund the reserve.
  2. Type an amount above the free reserve: "Within the free reserve" shows the free amount and the button is disabled.

Breaking changes

None.

Checklist

  • Self-reviewed my own diff
  • Tests added or updated
  • Docs updated (if applicable)
  • No unrelated changes bundled in

Screenshots

None.

@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
strata-vault-kit-app Ready Ready Preview Oct 13, 2026 12:25pm UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It adds five write hooks that move real on-chain value plus a new admin surface, so despite strong tests and verified contract-error mappings it warrants final human review.

1 open finding
What changed in this PR

This PR extends the /admin Cycle surface (part of #193) so the treasury can deploy reserve assets to the custodian and any Cycle role can fund the reserve, directly from the Cycle card. It adds the two write hooks, the action-model logic that gates each button on live contract state, and the modal flows that map contract errors to human-readable refusals. It builds on the existing useContractTransaction/TransactionModal/CycleSurface infrastructure and the generated clients, moving real on-chain value (classic-asset transfers into the vault and out to the custodian).

Changes:

  • New useDeployToCustodian and useFund hooks call the vault via useContractTransaction; fund additionally refreshes the funder's deposit balance.
  • toCycleActions/toDeployAction/toFundAction in cycle.ts gate deploy (wind-down, custodian set, free reserve) and fund (wallet balance), each with a "Use max", conditions, and pre-sign resulting reserve state.
  • TransactionModal gains deploy/fund actions with vault error codes mapped; a token refusal on fund points the funder at their wallet balance/trustline.
File Description
app/​src/​pages/​cycle.ts Core action/condition/outcome model + deploy/fund builders and reserve display rows.
app/​src/​hooks/​useDeployToCustodian.ts New treasury hook wrapping deploy_to_custodian via useContractTransaction.
app/​src/​hooks/​useFund.ts New fund hook; refreshes funder deposit balance on confirm.
app/​src/​hooks/​useCloseEpoch.ts /​ useFulfillEpoch.ts /​ useAttest.ts Cycle write hooks reused by the surface.
app/​src/​hooks/​useCycleState.ts Composes cycle state (reserve, oracle, wind-down) incl. custodian balance read; defines cycleWriteKeys.
app/​src/​hooks/​useContractTransaction.ts Adds extraKeys invalidation parameter.
app/​src/​components/​vault/​TransactionModal.tsx Adds deploy/fund (+ close/fulfill/attest) flows with contract-error messages.
app/​src/​components/​admin/​CycleSurface.tsx /​ CycleSection.tsx UI wiring: amount fields, conditions, resulting state, buttons per group.
app/​src/​components/​vault/​MetricsStrip.tsx (+ .module.css) Widened to Metric[] with optional note; grid flow tweak.
app-lib/​readContract.ts New readEpochs, readLedgerTime, readEvents + ChainEvent types.
app-lib/​contracts.ts connectNavOracle gains optional signer for the write client.
*.test.ts(x) Comprehensive tests for all new hooks, logic, reads, and modal flows.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/src/hooks/useDeployToCustodian.ts Outdated
return useContractTransaction<Amount, bigint, Record<never, never>>(
call,
toConfirmed,
cycleWriteKeys,
@luchobonatti
luchobonatti merged commit ccb8a4a into main Oct 13, 2026
3 checks passed

This branch was successfully deployed

1 active deployment
Preview — 4faf7d77 Deployed Oct 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants