Add rescue funds admin entrypoint#608
Merged
greatest0fallt1me merged 2 commits intoJun 29, 2026
Merged
Conversation
feat(vault): add admin `rescue_funds` entrypoint and helper
Contributor
Author
|
Done with this issue. |
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.
Motivation
Provide an admin-gated recovery mechanism to rescue tokens accidentally sent to the vault while protecting tracked USDC balances.
Ensure the rescue operation can be executed by the campaign multisig/timelock (admin) and is audit-friendly via an event.
Description
Added a focused helper module contracts/vault/src/rescue.rs implementing rescue_funds(env, token_address, to, amount, protected_balance) which enforces positive amounts, available/on-ledger checks, and performs the transfer.
Exposed an admin entrypoint rescue_funds in contracts/vault/src/lib.rs that requires the configured admin, reserves tracked USDC when applicable, calls the helper, and emits an rescue_funds event.
Reworked distribute to use the rescue helper for safe surplus transfers and added the canonical event constructor event_rescue_funds in contracts/vault/src/events.rs.
Added focused unit tests in contracts/vault/src/test.rs covering non-USDC rescue, USDC-surplus protection, auth/amount rejection, and event shape, and updated the public interface docs in docs/interfaces/vault.json.
Testing
Ran rustfmt on modified files which completed successfully.
Ran cargo check -p callora-vault which failed to build due to pre-existing compilation blockers in the vault project (duplicate exported function definitions and contract macro parameter issues surfaced during the build), so the new tests were not executed.
Attempted cargo test -p callora-vault rescue_funds which could not run because the build failed for the same compile errors; the rescue tests are present and will run once the underlying build issues are resolved.
Closes #563