Contracts: XP accrual and uncapped level progression #250

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

Context

Onchain XP and uncapped level progression. Parent epic: #238.

Relevant files

  • contracts/src/TimeArena.sol or contracts/src/PlayerXp.sol
  • Frontend mirror: new arenaXpMath.ts

Acceptance criteria

  • XP per buy = linear map min CHARM→1, max CHARM→10 (integer rounding documented)
  • Level thresholds: L1=20 XP; for level L→L+1 need min(20 + (L-1)*5, 100) XP
  • Uncapped level; expose xp, level, xpToNextLevel views
  • Emit XpGained(buyer, amount, newLevel?)

Verification checklist

  • Forge: table-test levels 1–10 and level 50+ (100 XP/level flat)
  • TS unit tests mirror onchain formula
## Context Onchain XP and uncapped level progression. Parent epic: #238. ## Relevant files - `contracts/src/TimeArena.sol` or `contracts/src/PlayerXp.sol` - Frontend mirror: new `arenaXpMath.ts` ## Acceptance criteria - [ ] XP per buy = linear map min CHARM→1, max CHARM→10 (integer rounding documented) - [ ] Level thresholds: L1=20 XP; for level L→L+1 need `min(20 + (L-1)*5, 100)` XP - [ ] Uncapped level; expose `xp`, `level`, `xpToNextLevel` views - [ ] Emit `XpGained(buyer, amount, newLevel?)` ## Verification checklist - [ ] Forge: table-test levels 1–10 and level 50+ (100 XP/level flat) - [ ] TS unit tests mirror onchain formula
PlasticDigits commented 2026-05-27 07:07:25 +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:43 +00:00 (Migrated from gitlab.com)

Implementation summary

  • ArenaXp library + onchain xp/level/XpGained; mirror frontend/src/lib/arenaXpMath.ts.

Acceptance criteria

  • XP 1–10 per buy from CHARM
  • Level thresholds + uncapped level views

Verification checklist

  • Forge + Vitest arenaXpMath.test.ts
## Implementation summary - `ArenaXp` library + onchain `xp`/`level`/`XpGained`; mirror `frontend/src/lib/arenaXpMath.ts`. ## Acceptance criteria - [x] XP 1–10 per buy from CHARM - [x] Level thresholds + uncapped level views ## Verification checklist - [x] Forge + Vitest `arenaXpMath.test.ts`
PlasticDigits commented 2026-05-29 08:07:58 +00:00 (Migrated from gitlab.com)

mentioned in issue #265

mentioned in issue #265
PlasticDigits commented 2026-05-29 08:07:58 +00:00 (Migrated from gitlab.com)

marked as related to #265

marked as related to #265
PlasticDigits commented 2026-05-30 14:02:52 +00:00 (Migrated from gitlab.com)

mentioned in commit 776ba693e5

mentioned in commit 776ba693e505693a7084ff2ab2dcc04c4271712c
PlasticDigits commented 2026-05-30 14:02:56 +00:00 (Migrated from gitlab.com)

Verification complete (agent)

Verified GitLab #250 on branch issue/250-xp-accrual-verify (worktree) against acceptance criteria and the verification checklist. Implementation was already present; added explicit table-test coverage and doc cross-links, merged to main (776ba69).

Acceptance criteria

  • XP per buy — linear map min CHARM→1, max CHARM→10 (integer floor via mulDiv); documented in ArenaXp.sol, arena-v2.md, time-arena.md
  • Level thresholds — L1→L2 = 20 XP; L→L+1 = min(20 + (L-1)*5, 100); table-tested L1–L10 and flat 100 XP at L17+
  • Uncapped level views — xp, level, xpTowardNext, xpToNextLevel on TimeArena
  • XpGained(buyer, amount, newLevel) — emitted in _finishBuy; new Forge test test_xp_emits_XpGained

Verification checklist (automated)

  • Forge — ArenaXp.t.sol::test_level_thresholds_table_levels_1_through_10, test_level_50_plus_flat_100_xp_per_level, test_xpForCharm_linear_band; TimeArena.t.sol::test_xp_* (8 tests)
  • Vitest — frontend/src/lib/arenaXpMath.test.ts mirrors onchain formulas (6 tests)

Docs / invariants / play skills

Manual re-check (optional)

  • cd contracts && forge test --match-contract ArenaXp
  • cd frontend && npx vitest run src/lib/arenaXpMath.test.ts
  • On Anvil: one buy(10e18) → xp +10, level 1, XpGained in receipt

All issue-body and comment criteria pass — closing.

## Verification complete (agent) Verified GitLab **#250** on branch `issue/250-xp-accrual-verify` (worktree) against acceptance criteria and the verification checklist. Implementation was already present; added explicit table-test coverage and doc cross-links, merged to `main` (`776ba69`). ### Acceptance criteria - [x] **XP per buy** — linear map min CHARM→1, max CHARM→10 (integer floor via `mulDiv`); documented in [`ArenaXp.sol`](contracts/src/arena/libraries/ArenaXp.sol), [`arena-v2.md`](docs/product/arena-v2.md), [`time-arena.md`](docs/product/time-arena.md) - [x] **Level thresholds** — L1→L2 = 20 XP; L→L+1 = `min(20 + (L-1)*5, 100)`; table-tested L1–L10 and flat 100 XP at L17+ - [x] **Uncapped level views** — `xp`, `level`, `xpTowardNext`, `xpToNextLevel` on `TimeArena` - [x] **`XpGained(buyer, amount, newLevel)`** — emitted in `_finishBuy`; new Forge test `test_xp_emits_XpGained` ### Verification checklist (automated) - [x] **Forge** — `ArenaXp.t.sol::test_level_thresholds_table_levels_1_through_10`, `test_level_50_plus_flat_100_xp_per_level`, `test_xpForCharm_linear_band`; `TimeArena.t.sol::test_xp_*` (8 tests) - [x] **Vitest** — `frontend/src/lib/arenaXpMath.test.ts` mirrors onchain formulas (6 tests) ### Docs / invariants / play skills - **`INV-TIME-ARENA-XP`** updated with #250 evidence mapping - Cross-links: [`skills/README.md`](skills/README.md), [`play-time-arena-doub/SKILL.md`](skills/play-time-arena-doub/SKILL.md), guardrails skill, product specs ### Manual re-check (optional) - [ ] `cd contracts && forge test --match-contract ArenaXp` - [ ] `cd frontend && npx vitest run src/lib/arenaXpMath.test.ts` - [ ] On Anvil: one `buy(10e18)` → `xp` +10, `level` 1, `XpGained` in receipt All issue-body and comment criteria pass — closing.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-05-30 14:02:57 +00:00
PlasticDigits commented 2026-06-07 07:50:09 +00:00 (Migrated from gitlab.com)

mentioned in issue #299

mentioned in issue #299
PlasticDigits commented 2026-06-08 08:16:57 +00:00 (Migrated from gitlab.com)

mentioned in issue #303

mentioned in issue #303
PlasticDigits commented 2026-06-10 03:30:11 +00:00 (Migrated from gitlab.com)

mentioned in issue #304

mentioned in issue #304
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#250
No description provided.