feat(vault): add owner-only sweep_idle_balance with settlement/revenue_pool routing#610
Open
elijah4196 wants to merge 2 commits into
Open
feat(vault): add owner-only sweep_idle_balance with settlement/revenue_pool routing#610elijah4196 wants to merge 2 commits into
elijah4196 wants to merge 2 commits into
Conversation
|
@elijah4196 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! 🚀 |
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.
feat(vault): add owner-only sweep_idle_balance with settlement/revenue_pool routing
Summary
Operators occasionally need to move surplus USDC out of the vault into the
settlement contract or revenue pool without going through
deduct, which encodesper-call business logic. This PR adds a dedicated
sweep_idle_balanceflow withfull auth, pause, and balance guards plus event coverage.
Changes
contracts/vault/src/lib.rsSweepDestinationenum (#[contracttype]) —Settlement|RevenuePoolSweptEventDatastruct (#[contracttype]) —destination,amount,new_balancesweep_idle_balance(env, owner, to, amount)entrypoint:owner.require_auth()+ explicit owner check)require_not_paused)StorageKey::SettlementorStorageKey::RevenuePool; returnsVaultError::DestinationNotConfigured(code 37) if not setVaultError::DestinationNotConfigured = 37— new error codecontracts/vault/src/test_sweep_idle_balance.rs(new)13 tests covering all acceptance criteria:
sweep_rejects_non_ownerUnauthorizedsweep_requires_owner_authsweep_blocked_when_pausedsweep_settlement_not_configuredDestinationNotConfiguredfor settlementsweep_revenue_pool_not_configuredDestinationNotConfiguredfor revenue poolsweep_zero_amount_rejectedAmountNotPositivesweep_negative_amount_rejectedAmountNotPositivesweep_exceeds_balance_rejectedInsufficientBalancesweep_partial_to_settlementsweep_partial_to_revenue_poolsweep_full_balance_drainsweep_emits_eventsweptevent shape: destination, amount, new_balancesweep_balance_consistency_after_multiple_sweepscontracts/vault/src/events.rsevent_swept_bytessnapshot test asserting byte-level identity of"swept"topicEVENT_SCHEMA.mdsweptevent specification with field table, two JSON examples, and indexer notessweptrow to the indexer quick-reference tablecontracts/vault/STORAGE.mdsweep_idle_balanceto the TTL-bump entrypoints listsweep_idle_balancerow to the Core Vault Operations tableAcceptance criteria
sweep_rejects_non_owner,sweep_requires_owner_auth)sweptevent with(destination, amount, new_balance)payload (sweep_emits_event)meta.balanceconsistently with the on-ledger USDC move (sweep_balance_consistency_after_multiple_sweeps)Testing
cargo test -p callora-vault sweep_idle_balanceAll 13 tests in
test_sweep_idle_balance.rspass.closes #415