Skip to content

Contracts: Add rewards points expiry — time-limited balances with TTL per user #322

@CelestinaBeing

Description

@CelestinaBeing

Summary

Unredeemed rewards accumulate indefinitely. For campaigns with promotional points (e.g. 'earn double points this month'), points should optionally expire after a configurable period. This is standard in loyalty programs and prevents indefinite liability for campaign operators.

Problem

  • No expiry mechanism exists; balances are permanent
  • Operators have no way to create time-limited promotional rewards
  • Dormant balances inflate total_credited stats

Acceptance Criteria

  • Add per-credit expiry: credit_with_expiry(env, from, user, amount, expires_at_ledger: u64) function
  • Store per-user expiry map: (EXPIRY, user) -> Vec<(amount, expires_at)>
  • balance(user) must filter expired credits before returning the sum
  • claim() must consume non-expired credits first (FIFO)
  • Add prune_expired(user) callable by anyone to clean up expired storage and free TTL (incentivize cleanup via no-op success)
  • Add credit_no_expiry() alias for the current credit() behavior (backward compatible)
  • Add unit tests: credit expires at correct ledger, balance returns 0 after expiry, claim uses non-expired first
  • Document expiry mechanics in contracts/rewards/README.md

References

  • contracts/rewards/src/lib.rs:180credit()
  • contracts/rewards/src/lib.rs:264claim()

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions