Skip to content

Treasury rebalance with human approval + manager-withdraw denial proof (#358) - #443

Open
IVANLI2412 wants to merge 1 commit into
nirium-protocol:mainfrom
IVANLI2412:chain-hunter/nirium-358
Open

IVANLI2412 wants to merge 1 commit into
nirium-protocol:mainfrom
IVANLI2412:chain-hunter/nirium-358

Conversation

@IVANLI2412

Copy link
Copy Markdown
Contributor

Closes #358

What

Adds a self-contained examples/treasury-rebalance-approval/ example demonstrating a testnet treasury rebalance with explicit human approval, plus a reproducible local proof that the rebalance manager key cannot withdraw or transfer funds out of the vault.

Security properties (verified locally)

  • Manager key cannot withdraw or transfer: VaultRoles.authorize rejects WITHDRAW / TRANSFER / SET_REBALANCE_MANAGER unless the caller is the owner; deny_operation() runs before any XDR is built or any network call happens. Tests assert signed == False, submitted == False, no state change and no agent events.
  • Human approval is not bypassable: the rebalance is proposed by the agent, signed and submitted only after explicit human approval. Declining produces aprobado=False ejecutado=False, zero manager signatures and zero rebalance submissions.
  • No secret leakage: redaction covers secret keys and API keys; HTTP submit bodies contain only {'xdr': ...}; keys are never logged.

Verification

  • pytest -q → 23 passed
  • Directed security tests → 2 passed
  • cargo test (host-side model) → 8 passed
  • main.py --demo and main.py --demo --decline → exit 0
  • git diff --cached --check → clean

Scope / limitations

Stellar testnet only. Offline demos by default. No real funds, no real transaction signing, no deployment, no mainnet. No on-chain tx hashes are claimed (marked PENDING / N/A); soroban / stellar CLIs are not available in this environment, so the Rust contract was validated host-side only. Testnet hashes and Stellar Expert links must be added by a maintainer with testnet credentials.

Reviewer note: this is an example plus tests, not a change to production contract code.

Closes nirium-protocol#358

- owner sets a dedicated rebalance manager; agent proposes; human y/N gates execution
- fail-closed role guard proves the manager key cannot withdraw or transfer funds
- offline demo, no-network tests, local secret redaction, testnet-only commands
- Rust host-side role model verified with cargo test; no Soroban CLI available

Co-Authored-By: Big Pickle <noreply@anthropic.com>
@drips-wave

drips-wave Bot commented Nov 22, 2026

Copy link
Copy Markdown

@IVANLI2412 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Eras256 Eras256 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AI-assisted comment (Claude)

Thanks @IVANLI2412, the structure and the offline tests look good. Two things from #358's "Done when" are still missing before we can merge:

  1. A real testnet run with one command, with the transaction hashes on Stellar Expert (testnet) listed in the README. The PR says they're PENDING right now.
  2. The negative test on testnet: the manager key tries to withdraw or transfer funds out of a real vault and is refused, with the output pasted in the README. The local VaultRoles model shows the idea, but the point of the issue is that the vault contract itself refuses it on-chain.

Use your own testnet keys (Friendbot + a DeFindex vault you deploy, like in your #371 run). Once both are in, we'll review again.

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.

Treasury on testnet: a rebalance with human approval, and proof the manager key can't move funds out

2 participants