feat(vault): track deployed vs idle assets via derived getters#338
Merged
Abidoyesimze merged 1 commit intoJun 28, 2026
Merged
Conversation
|
@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! 🚀 |
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
78bd438 to
f3389d6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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); returns0whenCurrentProtocolis"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
get_idle_balance/get_deployed_assets/get_asset_breakdown.tests/test_asset_split.rs(4 tests: idle == deposit & deployed == 0 before rebalance; idle → 0 & deployed == deposit after rebalancing into Blend;get_asset_breakdownmatches the individual getters).ARCHITECTURE.mdupdated with an "Idle vs Deployed Asset Tracking" section, including the relationship toTotalAssets.Generated artifacts
Regenerated
contract-spec.jsonandpackages/vault-client/src/generated/vault.ts, and registered the new functions inscripts/generate-spec.py(same pattern as the other query functions).Verification
cargo test test_asset_split→ 4 passed; 0 failed.lib.rs(no existing lines modified).scripts/check-no-bare-panic.shpasses.Note on pre-existing CI state
A few items are pre-existing on
mainand unrelated to this change:validate-spec.pyalready reports error-shape drift forVaultErrorcodes 28–48 (identical count with and without this PR — no new drift introduced), andtest_rebalance_cooldown/test_strategy_switch_low_liquidity/test_ttlalready fail locally. Happy to address those separately if wanted.Closes #321