Skip to content

feat(solvency): simulate agent_vault check_invariants and add public solvency page (#891) - #897

Closed
huangji6693-max wants to merge 1 commit into
ExcelDsigN-tech:mainfrom
huangji6693-max:feat/public-solvency-simulation-891
Closed

huangji6693-max wants to merge 1 commit into
ExcelDsigN-tech:mainfrom
huangji6693-max:feat/public-solvency-simulation-891

Conversation

@huangji6693-max

Copy link
Copy Markdown

Closes #891

Summary

Follow-up to #777 / #781:

  1. Backend Contract Simulation (GET /api/agents/solvency):
    • Added sorobanService.simulateAgentVaultInvariants(agentAddresses) to simulate check_invariants on agent_vault for all active agents and decode per-agent (agent, holds, float, max_allowed) tuples in stroops.
    • Updated getPublicSolvency in backend/src/controllers/agentMvpController.ts to combine indexed collateral_balance with on-chain check_invariants simulation results (holds, float, maxAllowed), compute network-wide totals, and remove the unused haircut_bps read path from getPublicSolvency.
    • Added publicSolvencyRateLimiter (60 req/min per identity) and brief cacheService caching (agents:solvency:public, 30s TTL).
  2. Public Frontend Page (/solvency):
    • Added usePublicSolvency hook in frontend/src/app/hooks/useApi.ts and public /[locale]/solvency page (no wallet connection required).
    • Displays network-wide solvency invariant status (Invariant Holds vs Invariant Violated), prominent violation alert banner when any invariant is violated, network totals, and a per-agent table with collateral, float, max allowed float, invariant status badge, and Stellar Explorer link.
  3. Tests:
    • Backend unit tests in backend/src/__tests__/agentMvp.test.ts covering no agents, holds, and violated.
    • Frontend unit tests in frontend/src/app/[locale]/solvency/page.test.tsx covering empty state, holds state with explorer link, and violated invariant alert.

Verification

  • cd backend && npm test -- src/__tests__/agentMvp.test.ts && npm run typecheck — 7/7 tests passing
  • cd frontend && npm test -- solvency/page.test.tsx && npm run i18n:validate && npm run typecheck — 3/3 tests passing

@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: b4a3caeb-707d-4193-a892-3e63a62ef8f0
  • 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.

@ExcelDsigN-tech

Copy link
Copy Markdown
Owner

Hi @huangji6693-max, please merge the latest main into this branch.

main now requires the Security Gates checks to pass before merge: Trivy filesystem scan, cargo audit, and npm audit for backend, frontend, scripts and sdk (#901, #904, #905, #906). Your branch is 5 commits behind, so these checks have not run against the current rules yet.

git fetch upstream
git merge upstream/main
git push

Please merge rather than rebase or force-push, so review history stays intact. Thanks!

@ExcelDsigN-tech

Copy link
Copy Markdown
Owner

Thanks for the work here, @huangji6693-max, and apologies for the earlier note asking you to merge main: I should have checked eligibility first.

DukaPay Wave issues are worked only after applying on the issue through the Wave and being assigned. #891 was never assigned to you, and other contributors applied first, so I'm closing this PR.

If you'd like to contribute, please apply on an open Wave issue and wait for assignment before starting. Thanks for understanding.

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] Public solvency: contract simulation, public page and tests (follow-up to #777)

2 participants