feat: vault-balance-sync — closes #SC-085 - #387
Merged
PeterOche merged 1 commit intoSep 4, 2026
Conversation
Add sync_vault_balance(call_id) pulling vault_balance from call_registry via cross-contract CallRegistryClient::get_call and caching in Map<u64, i128> (SyncedVaultBalance) for analytics, with get_synced_vault(call_id) view. Handles missing call revert, permissionless sync, TTL bumps on persistent writes, and VaultBalanceSynced event with redundant vault_balance. Co-authored-by: Muse Spark <muse-spark@meta.com>
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.
Closes #SC-085 — Vault Balance Sync via Treasury Callback (#366)
Summary
Implements
sync_vault_balance(call_id)pullingvault_balancefromcall_registryvia cross-contractCallRegistryClient::get_calland caching inMap<u64, i128>(SyncedVaultBalance) for analytics, withget_synced_vault(call_id)view.Changes
packages/contracts-stellar/treasury/src/treasury.rs: addDataKey::SyncedVaultBalance(u64),call_registry_ifacewith fullCallmirror (13 fields) for cross-contract deserialization,sync_vault_balance(permissionless, TTL bump,VaultBalanceSyncedevent),get_synced_vaultviewpackages/contracts-stellar/treasury/src/test.rs:MockCallRegistrywith fullMockCallmirror, 6 tests (sync matches registry, missing reverts, cached view correct, permissionless, idempotent, zero, updated registry)Acceptance Criteria
Call does not exist)get_synced_vaultChecks
Notes
cargo clippy --workspace -- -D warningsfails on pre-existingcall_registrywarnings (unnecessary_cast, manual_range_contains) — not introduced by this PR;treasuryalone passes cleangovernance::errors::ContractErrorhas 50 variants (at limit for#[contracterror]macro); missing-call case propagates registry'sCall does not existpanic rather than adding a new error code