Skip to content

Add protocol fee treasury withdrawal with admin authorization #314

@mikewheeleer

Description

@mikewheeleer

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

Metadata

Metadata

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions