Stage8 ewallet UI Fix Sprint Report (2026-05-06)
Background and Trigger
User ok1000 (id=25) screen showed: deposits 281.51 USDT / withdrawals 0 / available 197.51 = arithmetic mismatch.
Root cause: API queried only ewallet_commission_histories (positive) and ewallet_purchase_histories (mostly empty),
missing transfer in/out, BSC deposits, stage purchase deductions, and payout requests.
Precision Audit Findings
Data source mapping discovered
| Source |
Affects cash_point |
API used (BEFORE) |
API uses (AFTER) |
| 1127_deposit_transactions (BSC/TRON confirmed) |
YES |
NO |
YES |
| 1127_ewallet_commission_histories amount > 0 |
YES |
YES |
YES |
| 1127_cashpoint_wallet_transfer_histories type=credit |
YES |
NO |
YES |
| 1127_cashpoint_wallet_transfer_histories type=debit |
YES |
NO |
YES |
| 1127_payout_release_requests amount + fee |
YES |
NO |
YES |
| 1127_purchased_membership_details |
YES |
NO |
YES |
Key insight: original API used legacy ewallet_transfer_histories which is NOT the source of cash_point ledger.
After P4 (2026-05-05) cash_point became single wallet, all real movement is in cashpoint_wallet_* tables.
Reconciliation across 13 users
| user_id |
username |
actual cash_point |
totalIncome |
totalExpenses |
gap |
| 25 |
ok1000 |
198.71 |
1129.71 |
931.00 |
0.00 PASS |
| 272 |
ok2949 |
30.00 |
60.00 |
30.00 |
0.00 PASS |
| 514 |
ok6137 |
30.00 |
30.00 |
0.00 |
0.00 PASS |
| 5 |
master |
448.56 |
1378.56 |
930.00 |
0.00 PASS |
| 4 |
stage8 |
1239.36 |
2169.36 |
930.00 |
0.00 PASS |
| 288 |
yj7717 |
37.50 |
67.50 |
30.00 |
0.00 PASS |
| 243 |
bjs5887 |
3.00 |
93.00 |
90.00 |
0.00 PASS |
| 43 |
star365 |
121.29 |
976.29 |
872.00 |
-17.00 |
| 10 |
ljm5177 |
41.39 |
327.39 |
316.00 |
-30.00 |
| 45 |
kstone0675 |
10.80 |
220.80 |
264.00 |
-54.00 |
| 12 |
lst6485 |
108.60 |
258.60 |
210.00 |
-60.00 |
| 6 |
garnet |
133.80 |
253.80 |
210.00 |
-90.00 |
| 3 |
a01071540697 |
25.22 |
830.67 |
978.85 |
-173.40 |
Result: 8 of 13 users PASS (gap = 0). Remaining 5 users have non-zero gap from invisible admin-side cash_point
adjustments (initial credit at signup or admin debits not recorded in any observable table).
Cards still show accurate sums of all observable transactions.
Empty / unused tables verified (no signal source)
- ewallet_purchase_histories: 0 rows for all queried users
- cashpoint_wallet_purchase_histories: 0 rows
- cashpoint_wallet_payment_details: 0 rows
Files Modified
A. API: /home/stage8-user/src/app/api/user/ewallet/route.ts (8828 -> 11754 bytes)
- Added 5 new aggregates: depositSummary, transferCreditSummary, transferDebitSummary, payoutAllSummary, stagePurchaseSummary
- transferHistories findMany/count switched: ewallet_transfer_histories -> cashpoint_wallet_transfer_histories
- totalIncome = depositTotal + commissionInTotal + transferCreditTotal
- totalExpenses = payoutTotal (amount + fee, all status) + transferDebitTotal (abs) + stagePurchaseTotal
- New balance.incomeBreakdown / expenseBreakdown for transparency
- formattedTransfers now exposes note field (transaction_note)
B. UI: /home/stage8-user/src/app/(user)/ewallet/page.tsx (cash tab labels only)
- t(credit) -> t(totalIncomeCash)
- t(debit) -> t(totalExpensesCash)
- tron tab unchanged
- 3-card layout preserved (mobile UI safe)
C. 8 locale files: /home/stage8-user/src/messages/{ko,en,zh,ja,vi,th,ru,hi}.json
- Added new keys totalIncomeCash and totalExpensesCash to each ewallet block
- Existing keys credit/debit retained for tron tab and other usages
Build and Restart
- npm run build: PASS (Next.js 14.2.35)
- pm2 restart stage8-user: PASS
- pm2 restart stage8-admin: PASS
- pm2 save: PASS
- 5 of 5 PM2 processes online
Health Check
Backup Files
All in /home/stage8-user/ with suffix .bak-uifix-20260506:
- src/app/api/user/ewallet/route.ts.bak-uifix-20260506
- src/app/(user)/ewallet/page.tsx.bak-uifix-20260506
- src/messages/ko.json.bak-uifix-20260506 (and 7 others)
Live Impact
- Downtime: 0 (PM2 graceful restart)
- Trading services untouched (gunja-pair-hedge / gate-pair-hedge / multi-tenant unaffected)
- UFW / iptables / SSH unchanged
- DB schema unchanged (SELECT only)
- cash_point business logic untouched (stage payment, transfer handling)
PENDING (next sprint candidates)
- Resolve admin-credit residual gap for 5 users by introducing admin_cashpoint_adjustment_log table or routing all admin manual credits through ewallet_commission_histories (amount_type = admin_manual_credit) consistently.
- Surface incomeBreakdown / expenseBreakdown on UI: clicking a card expands to 6 sub-cards.
- Tron wallet transaction history: currently shows No transactions; needs separate source wiring.