Some checks failed
Deploy to Production / test (push) Failing after 33s
- Rewrite AGENTS and README files to match the current app layout - Document API routes, trivia UI, and the active panel design language
37 lines
1.3 KiB
Markdown
37 lines
1.3 KiB
Markdown
# Economy module
|
|
|
|
This area is split across three services:
|
|
|
|
- `economy.service.ts`
|
|
- `exam.service.ts`
|
|
- `lootdrop.service.ts`
|
|
|
|
## Core rules
|
|
|
|
- Currency values are `bigint`
|
|
- `modifyUserBalance()` is the canonical balance mutator for most features because it logs a transaction and emits `BALANCE_CHANGED`
|
|
- direct balance updates still exist in a few flows where the service owns the full transaction, such as trivia entry/win and exam payout
|
|
|
|
## Daily rewards
|
|
|
|
- `claimDaily()` uses a UTC-midnight cooldown, not a rolling 24-hour timer
|
|
- streak bonus is linear from `config.economy.daily.streakBonus`
|
|
- weekly bonus applies every seventh claim
|
|
- total daily reward is capped at `500n`
|
|
- missing more than 24 hours after the cooldown expired resets the streak
|
|
|
|
## Weekly exam
|
|
|
|
- stored in `user_timers` with type `EXAM_SYSTEM`
|
|
- registration locks the user to the current weekday
|
|
- payout is based on XP gained since the previous exam snapshot
|
|
- missing the assigned weekday rolls the timer forward and pays nothing
|
|
|
|
## Lootdrops
|
|
|
|
- channel activity and cooldowns are kept in memory
|
|
- spawned drops are persisted in the `lootdrops` table
|
|
- claiming uses an atomic update where `claimedBy IS NULL`
|
|
- expired drops and stale activity are cleaned every 60 seconds
|
|
- spawned drops expire after 10 minutes
|