Description
Once DataKey::AccumulatedProtocolFees is populated by milestone releases, there is no entrypoint to withdraw collected protocol fees. Add an admin-gated withdraw_protocol_fees that zeroes the accumulator and emits an auditable event, completing the fee lifecycle referenced in docs/escrow/FUNDING_ACCOUNTING.md.
Requirements and context
- Scoped to TalentTrust
escrow Soroban contract (contracts/escrow).
- Implement
withdraw_protocol_fees(admin, recipient) requiring require_admin and admin.require_auth(); reject when the accumulator is zero.
- Reset
DataKey::AccumulatedProtocolFees to 0 atomically and publish a fee_wd event with (recipient, amount, timestamp).
- Invariant: total withdrawn over the contract lifetime equals total fees accrued; no withdrawal possible while paused/emergency.
- Must be secure, tested, and documented.
Suggested execution
- Fork the repo and create a branch:
git checkout -b feature/fee-treasury-withdrawal
- Implement changes:
contracts/escrow/src/protocol_fees.rs
- Tests:
contracts/escrow/src/test/protocol_fees.rs
- Docs:
docs/escrow/FUNDING_ACCOUNTING.md
- Include rustdoc/NatSpec-style doc comments on public functions
- Validate security assumptions (auth, overflow, fail-closed state machine, storage TTL, fee accounting)
Test and commit
- Run tests:
cargo test
- Cover edge cases (unauthorized callers, double release/refund, expired approvals, fee rounding, paused state)
- Include test output and security notes in the PR
Example commit message
feat(escrow): add admin protocol fee withdrawal
Guidelines
- Minimum 95% test coverage on new/changed code
- Clear documentation
- Timeframe: 96 hours from assignment
Description
Once
DataKey::AccumulatedProtocolFeesis populated by milestone releases, there is no entrypoint to withdraw collected protocol fees. Add an admin-gatedwithdraw_protocol_feesthat zeroes the accumulator and emits an auditable event, completing the fee lifecycle referenced indocs/escrow/FUNDING_ACCOUNTING.md.Requirements and context
escrowSoroban contract (contracts/escrow).withdraw_protocol_fees(admin, recipient)requiringrequire_adminandadmin.require_auth(); reject when the accumulator is zero.DataKey::AccumulatedProtocolFeesto 0 atomically and publish afee_wdevent with(recipient, amount, timestamp).Suggested execution
git checkout -b feature/fee-treasury-withdrawalcontracts/escrow/src/protocol_fees.rscontracts/escrow/src/test/protocol_fees.rsdocs/escrow/FUNDING_ACCOUNTING.mdTest and commit
cargo testExample commit message
Guidelines