Skip to content

feat: Royalty pool system#3

Open
rawgroundbeef wants to merge 1 commit intomainfrom
feature/royalty-pool
Open

feat: Royalty pool system#3
rawgroundbeef wants to merge 1 commit intomainfrom
feature/royalty-pool

Conversation

@rawgroundbeef
Copy link
Owner

🏦 Royalty Pool

A shared pool funded by 15% of all tips. Artists earn based on plays and claim to their wallet.

How It Works

  1. Listener tips $5 → $0.75 goes to pool
  2. Weekly snapshot → calculates each artist's play share
  3. Artists claim → withdraw their earnings anytime

Database Schema

Table Purpose
royalty_pool Singleton balance tracker
pool_snapshots Weekly snapshots with merkle roots
pool_shares Per-artist shares per snapshot
pool_claims Claim records with tx hashes
pool_contributions Contribution log for transparency

API Endpoints

Endpoint Description
GET /api/pool Pool status + user's claimable amount
GET /api/pool/leaderboard Top artists by plays this period
GET /api/pool/history User's claim history
POST /api/pool/claim Claim available royalties
POST /api/pool/snapshot Trigger weekly snapshot (admin)

Integration

  • Tips automatically contribute 15% to pool
  • Contribution rate configurable in royalty_pool table
  • v1 is centralized claims; can add merkle proofs for on-chain verification later

Example Response

{
  "pool": {
    "balanceUsd": 127.50,
    "totalDistributedUsd": 1234.00,
    "contributionRate": 15,
    "artistsPaid": 18,
    "nextSnapshotAt": 1707523200
  },
  "user": {
    "claimableUsd": 4.25,
    "currentPlays": 312,
    "currentSharePercent": 8.5
  }
}

🥩 Built by RawGroundBeefBot

Database:
- royalty_pool: singleton balance tracker (15% default contribution rate)
- pool_snapshots: weekly snapshots with total plays
- pool_shares: per-artist shares per snapshot
- pool_claims: claim records
- pool_contributions: contribution log

API endpoints:
- GET /api/pool - pool status + user's claimable
- GET /api/pool/leaderboard - top artists by plays
- GET /api/pool/history - user's claim history
- POST /api/pool/claim - claim available royalties
- POST /api/pool/contribute - manual contribution
- POST /api/pool/snapshot - trigger weekly snapshot (admin)

Integration:
- Tips now contribute 15% to pool automatically
- Pool fills from tips, distributes weekly based on plays
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.

1 participant