Skip to content

feat: Clean Ledger — finalize_and_purge with cleanup bounty#257

Open
mgtmdccix-oss wants to merge 2 commits intoGrant-Stream:mainfrom
mgtmdccix-oss:feat/cleanup-bounty-finalize-and-purge
Open

feat: Clean Ledger — finalize_and_purge with cleanup bounty#257
mgtmdccix-oss wants to merge 2 commits intoGrant-Stream:mainfrom
mgtmdccix-oss:feat/cleanup-bounty-finalize-and-purge

Conversation

@mgtmdccix-oss
Copy link
Copy Markdown

@mgtmdccix-oss mgtmdccix-oss commented Mar 28, 2026

Closes #220


Summary

Implements the Clean Ledger / Social Cleanup bounty incentive to prevent zombie contracts and reduce Stellar state bloat.

What changed

  • New file: contracts/grant_contracts/src/cleanup_bounty.rs
  • Modified: contracts/grant_contracts/src/lib.rs — registered the new module and removed a duplicate pub mod temporal_guard

How it works

finalize_and_purge(env, grant_id, caller) — permissionless, any address can call it:

  1. Asserts status == Completed and remaining_balance == 0
  2. Computes bounty: total_amount × platform_fee_bps / 10_000 × 5 / 10_000 (0.05% of the platform fee)
  3. Transfers bounty from treasury to caller
  4. Calls env.storage().instance().remove() — frees the ledger entry
  5. Emits a purged event

Economics

Parameter Value
CLEANUP_BOUNTY_BPS 5 bps (0.05% of platform fee)
Bounty source Treasury
Who can call Anyone (permissionless)

Labels

optimization economics logic

…ant-Stream#102)

- oracle_heartbeat(): oracle signals liveness, records timestamp
- propose_safety_rate(): DAO member opens vote after 48h oracle silence
- vote_on_safety_rate(): weighted DAO vote with double-vote protection
- execute_safety_rate(): applies rate on 90% supermajority after voting ends
- get_exchange_rate(): returns manual rate or (1,1) fallback
- Added SafetyVoteProposal struct, SafetyVoteStatus enum, DataKey variants,
  error codes 304-309, and constants for timeouts/thresholds
- Tests: heartbeat blocks proposal, full flow, rejection below 90%,
  oracle recovery blocks execution
Implements the Clean Ledger / Social Cleanup bounty logic:
- Any caller can invoke finalize_and_purge() on a 100%-completed grant
- Removes the grant's storage entry to reduce Stellar state bloat
- Pays caller a small bounty (5 bps of the platform fee) from treasury
- Guards: status must be Completed and remaining_balance must be zero
- Emits a 'purged' event for off-chain indexers

Closes: optimization/economics label issue
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 28, 2026

@mgtmdccix-oss Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

141. Implement Gas_Refund_Incentive_for_State_Cleanup

1 participant