Skip to content

Vault: add withdraw_to recipient validation and pause-policy documentation #359

@greatest0fallt1me

Description

@greatest0fallt1me

Description

CalloraVault::withdraw_to lets the owner send tracked USDC to an arbitrary to address and is intentionally allowed while paused (emergency recovery), but it performs no recipient validation and the pause-allowed behavior is undocumented at the function level. Add recipient guards and explicit /// documentation of the emergency-withdrawal policy.

Requirements and Context

  • Reject to == env.current_contract_address() (sending back into the vault) and optionally to == usdc_token.
  • Document at the function level that withdraw/withdraw_to are permitted while paused for recovery, matching the module-level note.
  • Confirm CEI ordering relative to the token transfer.
  • Must be secure, tested, and documented
  • Should be efficient and easy to review

Suggested Execution

  1. Fork the repo and create a branch
    git checkout -b bug/vault-withdraw-to-validation
  2. Implement changes
    • contracts/vault/src/lib.rs — recipient guard + /// pause policy
    • VAULT_WITHDRAW_COMPLIANCE.md — align documented behavior
  3. Test and commit
    • cargo test -p callora-vault
    • Test withdraw_to-while-paused succeeds; self-address rejected
    • Include test output and notes in the PR

Example commit message

fix: validate withdraw_to recipient and document pause policy

Acceptance Criteria

  • Self-address (and token-address) recipient rejected
  • Pause-allowed behavior documented at function level
  • CEI ordering confirmed
  • Tests cover paused and invalid-recipient cases

Guidelines

  • .rs under contracts/vault/src/, cargo test, /// docs, minimum 95% line coverage, no unwrap() in prod paths
  • Clear documentation and inline comments
  • Timeframe: 96 hours

Metadata

Metadata

Labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions