Description
The vault performs external USDC transfer calls in deduct, batch_deduct, withdraw, and distribute. There is no test exercising a hostile token contract that attempts to re-enter the vault during the transfer. Add a malicious mock token and assert that state effects (meta.balance) cannot be corrupted by re-entry.
Requirements and Context
- Implement a mock token whose
transfer calls back into CalloraVault::deduct.
- Assert the re-entrant call either fails (auth/pause) or cannot double-spend balance.
- Cover both single
deduct and batch_deduct.
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b task/vault-reentrancy-mock-token
- Implement changes
contracts/vault/src/test.rs — malicious token mock + re-entry tests
- Test and commit
cargo test -p callora-vault
- Assert no balance corruption and deterministic revert
- Include test output and notes in the PR
Example commit message
test: add reentrancy-equivalent mock token tests to vault
Acceptance Criteria
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
Description
The vault performs external USDC
transfercalls indeduct,batch_deduct,withdraw, anddistribute. There is no test exercising a hostile token contract that attempts to re-enter the vault during the transfer. Add a malicious mock token and assert that state effects (meta.balance) cannot be corrupted by re-entry.Requirements and Context
transfercalls back intoCalloraVault::deduct.deductandbatch_deduct.Suggested Execution
contracts/vault/src/test.rs— malicious token mock + re-entry testscargo test -p callora-vaultExample commit message
Acceptance Criteria
deductandbatch_deductcoveredGuidelines
.rsundercontracts/vault/src/,cargo test,///docs, minimum 95% line coverage, nounwrap()in prod paths