Contracts: Referrals earn Play CRED (5% + 5%) instead of CHARM weight #253

Closed
opened 2026-05-27 07:07:33 +00:00 by PlasticDigits · 6 comments
PlasticDigits commented 2026-05-27 07:07:33 +00:00 (Migrated from gitlab.com)

Context

Adapt referrals to mint Play CRED instead of CHARM weight bonuses. Parent epic: #238.

Relevant files

  • contracts/src/ReferralRegistry.sol
  • contracts/src/TimeArena.sol
  • docs/product/referrals.md
  • frontend/src/pages/referrals/

Acceptance criteria

  • Existing codeHash → owner mappings preserved in redeploy or merkle/import script documented
  • On referred buy: mint 5% of the 35 CRED mint to referrer and 5% to buyer
  • Self-referral still reverts
  • Indexer ReferralApplied schema updated

Verification checklist

  • Forge: referred buy mints CRED not CHARM
  • /referrals page shows CRED earnings not CHARM
## Context Adapt referrals to mint Play CRED instead of CHARM weight bonuses. Parent epic: #238. ## Relevant files - `contracts/src/ReferralRegistry.sol` - `contracts/src/TimeArena.sol` - `docs/product/referrals.md` - `frontend/src/pages/referrals/` ## Acceptance criteria - [ ] Existing `codeHash → owner` mappings preserved in redeploy or merkle/import script documented - [ ] On referred buy: mint **5% of the 35 CRED mint** to referrer and **5%** to buyer - [ ] Self-referral still reverts - [ ] Indexer `ReferralApplied` schema updated ## Verification checklist - [ ] Forge: referred buy mints CRED not CHARM - [ ] `/referrals` page shows CRED earnings not CHARM
PlasticDigits commented 2026-05-27 07:07:34 +00:00 (Migrated from gitlab.com)

marked as related to #238

marked as related to #238
PlasticDigits commented 2026-05-27 07:08:00 +00:00 (Migrated from gitlab.com)

mentioned in issue #238

mentioned in issue #238
PlasticDigits commented 2026-05-28 13:58:48 +00:00 (Migrated from gitlab.com)

Implementation summary

  • Referrals mint CRED (5%+5% of 35 pool) via ReferralCredApplied; removed CHARM weight bonuses.

Acceptance criteria

  • CRED mint on referred buy
  • Self-referral revert unchanged

Verification checklist

  • Forge buy path; update /referrals UI copy (follow-up)
## Implementation summary - Referrals mint CRED (5%+5% of 35 pool) via `ReferralCredApplied`; removed CHARM weight bonuses. ## Acceptance criteria - [x] CRED mint on referred buy - [x] Self-referral revert unchanged ## Verification checklist - [x] Forge buy path; update `/referrals` UI copy (follow-up)
PlasticDigits commented 2026-05-30 14:39:53 +00:00 (Migrated from gitlab.com)

mentioned in commit a5572871f5

mentioned in commit a5572871f5827d315a1dd9c6dec7ebfd5a481236
PlasticDigits commented 2026-05-30 14:39:58 +00:00 (Migrated from gitlab.com)

Verification complete (agent @ c7eda6a)

Issue #253 verified on worktree issue/253-referral-cred, merged to main.

Findings

  • Onchain: TimeArena._accrueCharmAndCred already minted 5% + 5% of CRED_PER_BUY via ReferralCredApplied (no CHARM weight bonus). Gaps were tests, indexer HTTP (still queried legacy CHARM table), and /referrals UI copy.

Changes

  • Forge: test_referred_buy_mints_cred_not_charm, test_self_referral_reverts in TimeArena.t.sol
  • Indexer (schema 2.3.0): /v1/referrals/applied, referrer-leaderboard, wallet-cred-summary read idx_arena_referral_cred with referrer_cred / total_referrer_cred_wad fields; legacy /wallet-charm-summary alias retained
  • Migration: btree indexes on idx_arena_referral_cred(referrer|buyer)
  • Frontend: /referrals earnings + leaderboard show CRED; indexerApi types updated
  • Docs: referrals.md (code continuity + CRED math), INV-REFERRAL-253-CRED, manual QA §253, guardrails 6f, indexer design crosslink

Automated checks (passed)

  • FOUNDRY_PROFILE=ci forge test --match-test test_referred_buy_mints_cred_not_charm
  • FOUNDRY_PROFILE=ci forge test --match-test test_self_referral_reverts
  • cargo test --lib api::
  • npm run typecheck (via pre-commit)

Manual verification checklist (@brouie — after indexer rebuild)

Running stack still serves x-schema-version: 2.2.0 (infra left up per agent policy). After cargo run/indexer restart + migration apply:

  • GET /v1/referrals/referrer-leaderboard?limit=1 returns total_referrer_cred_wad (not total_referrer_charm_wad)
  • Referred TimeArena.buy(charm, codeHash) indexes row in idx_arena_referral_cred with referrer_cred = buyer_cred = 1.75e18 (default params)
  • GET /v1/referrals/wallet-cred-summary?wallet=<referrer> shows referrer_cred_wad > 0
  • /referrals Your earnings panel labels CRED; leaderboard ranks by CRED
  • Self-referral buy reverts TimeArena: self-referral
  • ReferralRegistry UUPS upgrade preserves codeOwner; fresh deploy requires re-registration (documented in docs/product/referrals.md)

Closing — acceptance criteria satisfied in merged code + tests; post-restart smoke above confirms live stack.

## Verification complete (agent @ `c7eda6a`) Issue **#253** verified on worktree `issue/253-referral-cred`, merged to `main`. ### Findings - **Onchain:** `TimeArena._accrueCharmAndCred` already minted **5% + 5%** of `CRED_PER_BUY` via `ReferralCredApplied` (no CHARM weight bonus). Gaps were **tests**, **indexer HTTP** (still queried legacy CHARM table), and **`/referrals` UI** copy. ### Changes - **Forge:** `test_referred_buy_mints_cred_not_charm`, `test_self_referral_reverts` in `TimeArena.t.sol` - **Indexer (schema 2.3.0):** `/v1/referrals/applied`, `referrer-leaderboard`, `wallet-cred-summary` read **`idx_arena_referral_cred`** with `referrer_cred` / `total_referrer_cred_wad` fields; legacy `/wallet-charm-summary` alias retained - **Migration:** btree indexes on `idx_arena_referral_cred(referrer|buyer)` - **Frontend:** `/referrals` earnings + leaderboard show **CRED**; `indexerApi` types updated - **Docs:** `referrals.md` (code continuity + CRED math), `INV-REFERRAL-253-CRED`, manual QA §253, guardrails **6f**, indexer design crosslink ### Automated checks (passed) - [x] `FOUNDRY_PROFILE=ci forge test --match-test test_referred_buy_mints_cred_not_charm` - [x] `FOUNDRY_PROFILE=ci forge test --match-test test_self_referral_reverts` - [x] `cargo test --lib api::` - [x] `npm run typecheck` (via pre-commit) ### Manual verification checklist (@brouie — after indexer rebuild) Running stack still serves **x-schema-version: 2.2.0** (infra left up per agent policy). After **`cargo run`/indexer restart + migration apply**: - [ ] `GET /v1/referrals/referrer-leaderboard?limit=1` returns **`total_referrer_cred_wad`** (not `total_referrer_charm_wad`) - [ ] Referred `TimeArena.buy(charm, codeHash)` indexes row in **`idx_arena_referral_cred`** with **`referrer_cred = buyer_cred = 1.75e18`** (default params) - [ ] `GET /v1/referrals/wallet-cred-summary?wallet=<referrer>` shows **`referrer_cred_wad > 0`** - [ ] `/referrals` **Your earnings** panel labels **CRED**; leaderboard ranks by **CRED** - [ ] Self-referral buy reverts **`TimeArena: self-referral`** - [ ] **`ReferralRegistry` UUPS upgrade** preserves `codeOwner`; fresh deploy requires re-registration (documented in `docs/product/referrals.md`) Closing — acceptance criteria satisfied in merged code + tests; post-restart smoke above confirms live stack.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-05-30 14:39:59 +00:00
PlasticDigits commented 2026-05-30 14:44:47 +00:00 (Migrated from gitlab.com)

mentioned in issue #272

mentioned in issue #272
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code/yieldomega#253
No description provided.