Skip to content

feat(vault): track deployed vs idle assets via derived getters#338

Merged
Abidoyesimze merged 1 commit into
Neurowealth:mainfrom
davidmaronio:feat/issue-321-deployed-idle-assets
Jun 28, 2026
Merged

feat(vault): track deployed vs idle assets via derived getters#338
Abidoyesimze merged 1 commit into
Neurowealth:mainfrom
davidmaronio:feat/issue-321-deployed-idle-assets

Conversation

@davidmaronio

Copy link
Copy Markdown
Contributor

Summary

Adds read-only getters that split the vault's value into idle (held directly by the contract) vs deployed (supplied to an external protocol), so liquidity management and audits no longer have to infer the split from TotalDeposits/TotalAssets.

  • get_idle_balance() — USDC held directly by the vault contract.
  • get_deployed_assets() — USDC currently supplied to the active protocol (Blend/DEX); returns 0 when CurrentProtocol is "none".
  • get_asset_breakdown() — returns (idle, deployed) in a single call for dashboards/agents.

All three are derived read-only getters (no new storage), guarded by require_initialized, and follow the existing getter + doc-comment conventions.

Acceptance criteria

  • Derived getter(s) for deployed vs idle — get_idle_balance / get_deployed_assets / get_asset_breakdown.
  • Tests after rebalance show the correct split — tests/test_asset_split.rs (4 tests: idle == deposit & deployed == 0 before rebalance; idle → 0 & deployed == deposit after rebalancing into Blend; get_asset_breakdown matches the individual getters).
  • ARCHITECTURE.md updated with an "Idle vs Deployed Asset Tracking" section, including the relationship to TotalAssets.

Generated artifacts

Regenerated contract-spec.json and packages/vault-client/src/generated/vault.ts, and registered the new functions in scripts/generate-spec.py (same pattern as the other query functions).

Verification

  • cargo test test_asset_split4 passed; 0 failed.
  • Change is purely additive to lib.rs (no existing lines modified).
  • scripts/check-no-bare-panic.sh passes.

Note on pre-existing CI state

A few items are pre-existing on main and unrelated to this change: validate-spec.py already reports error-shape drift for VaultError codes 28–48 (identical count with and without this PR — no new drift introduced), and test_rebalance_cooldown / test_strategy_switch_low_liquidity / test_ttl already fail locally. Happy to address those separately if wanted.

Closes #321

@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@davidmaronio 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

Distinguish funds held directly by the vault from funds deployed to an
external protocol, so liquidity and audits no longer have to infer the
split from TotalDeposits/TotalAssets.

- get_idle_balance(): USDC held directly by the vault contract.
- get_deployed_assets(): USDC currently supplied to the active protocol
  (Blend/DEX), 0 when CurrentProtocol is "none".
- get_asset_breakdown(): returns (idle, deployed) in one call.

All three are derived read-only getters (no new storage), guarded by
require_initialized. Adds tests/test_asset_split.rs proving the split is
correct before and after a rebalance into Blend, documents the model in
ARCHITECTURE.md, and regenerates contract-spec.json and the TS client.

Closes Neurowealth#321
@davidmaronio davidmaronio force-pushed the feat/issue-321-deployed-idle-assets branch from 78bd438 to f3389d6 Compare June 28, 2026 08:38
@Abidoyesimze Abidoyesimze merged commit 0a6bc1b into Neurowealth:main Jun 28, 2026
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.

Track deployed_assets separately from idle vault balance

2 participants