Skip to content

feat(agent): add vault headroom, operator cash-in, and stroops end-to-end (#890) - #898

Open
huangji6693-max wants to merge 1 commit into
ExcelDsigN-tech:mainfrom
huangji6693-max:feat/agent-vault-screen-headroom-890
Open

huangji6693-max wants to merge 1 commit into
ExcelDsigN-tech:mainfrom
huangji6693-max:feat/agent-vault-screen-headroom-890

Conversation

@huangji6693-max

Copy link
Copy Markdown

Closes #890

Summary

Completes the follow-up items to #776 for the agent vault screen and backend routes:

  1. Stroops End-to-End (frontend/lib/money/format.ts & backend/src/controllers/agentMvpController.ts):
    • Parses user input to exact stroops (parseAmount) and displays collateral, float, max float, and remaining headroom formatted from stroops (formatStroops).
    • Accepts exact stroop strings (amountStroops) or decimal amounts in POST /api/agents/vault/:action and invalidates the cached agent dashboard snapshot on POST /api/agents/submit.
  2. Vault Headroom & Balances (backend/src/controllers/agentDashboardController.ts & frontend/src/app/components/agent/AgentVaultActions.tsx):
    • Returns collateralStroops, floatStroops, maxFloatStroops, and headroomStroops (max_float - float_balance) from GET /api/agents/dashboard.
    • Renders collateral, float, max float, and remaining headroom cards on the agent vault screen.
  3. Operator Cash-In (mint-float) Flow (AgentVaultActions & admin/settlement/page.tsx):
    • Adds mode="operator" on AgentVaultActions and mounts it on the admin settlement page so the operator can record a cash-in (mint_float) for a chosen agent signed with the admin wallet.
  4. Contract Error Mapping (backend/src/services/sorobanService.ts & AgentVaultActions.tsx):
    • Maps SolvencyViolated (Error(Contract, #8)) and InsufficientFloat (Error(Contract, #7)) (as well as InsufficientCollateral #6 and MinCollateralViolated #11) from Soroban simulation/submission to clear HTTP 400 error responses and user-facing alerts without relying on a frontend-only pre-check.
  5. Post-Action & SSE Event Refresh (frontend/src/app/[locale]/agent/dashboard/page.tsx):
    • Refreshes the agent dashboard after each submitted vault action and when CollateralDeposited, CollateralWithdrawn, FloatMinted, FloatBurned, FloatTransferred, VaultSettled, or HaircutUpdated events arrive on /api/events/stream.

Verification

  • Backend unit tests: cd backend && npm test -- src/__tests__/agentMvp.test.ts (17/17 passing)
  • Backend typecheck: cd backend && npm run typecheck (0 errors)
  • Frontend unit tests: cd frontend && npm test -- AgentVaultActions.test.tsx (5/5 passing)
  • Frontend i18n check & typecheck: cd frontend && npm run i18n:validate && npm run typecheck (0 errors)

@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c8185ba4-da34-4dab-8b4f-626bc30c2cb9
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

[backend, frontend] Agent vault screen: headroom, operator cash-in and tests (follow-up to #776)

1 participant