Skip to content

[Soroban] Add timelock for platform fee withdrawal#114

Open
Calebux wants to merge 2 commits intoANYTECHS:mainfrom
Calebux:feat/timelock-platform-fees-51
Open

[Soroban] Add timelock for platform fee withdrawal#114
Calebux wants to merge 2 commits intoANYTECHS:mainfrom
Calebux:feat/timelock-platform-fees-51

Conversation

@Calebux
Copy link
Copy Markdown

@Calebux Calebux commented Apr 26, 2026

Closes #51


PR closes issue #51

Summary

  • add 48-hour timelock flow for platform fee withdrawal
  • store and expose withdrawal unlock timestamp and last withdrawal timestamp
  • add request/claim flows with new errors and events
  • align backend simulation tests with escrow + timelock behavior

Testing

  • cargo test -p clips_nft

Caleb Peterson added 2 commits April 25, 2026 14:29
- Add WITHDRAWAL_TIMELOCK_SECS constant (172_800 seconds = 48 hours)
- Add three new error codes: WithdrawalLocked (13), NoFeesAccumulated (14),
  WithdrawalNotRequested (15)
- Add three new DataKey variants: AccumulatedFees(Address),
  WithdrawUnlocksAt, LastWithdrawalTs
- Add FeeWithdrawalRequestedEvent and FeeClaimedEvent structs
- Modify pay_royalty: platform recipient share is now held in contract
  escrow (AccumulatedFees storage) instead of transferred immediately
- Add request_fee_withdrawal(admin) -> starts 48-hour timelock, returns
  unlock timestamp
- Add claim_platform_fees(admin, asset_address) -> transfers escrowed
  balance to platform recipient after timelock expires, stores
  LastWithdrawalTs
- Add get_platform_fees(asset_address) -> view accumulated balance
- Add withdraw_unlocks_at() -> view pending unlock timestamp
- Add last_withdrawal_ts() -> view timestamp of last completed withdrawal
- Add 9 unit tests covering: timestamp calculation, error cases
  (WithdrawalNotRequested, WithdrawalLocked, NoFeesAccumulated),
  timer reset behaviour, admin-only auth, and event emission
@Eniola3321 Eniola3321 closed this Apr 26, 2026
@Eniola3321 Eniola3321 reopened this Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Soroban] Add timelock for platform fee withdrawal

2 participants