Frontend: CRED as buy payment option (balance, burn check, buyWithCred) #269
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:open_issues
agents
agent:security_audit
agent:verify
area
timecurve
arena
arena-v2
audit
block:feature_review
block:security
bug
contracts
design
devops
docs
documentation
enhancement
epic
feature
frontend
indexer
low priority
megaeth
operations
ops
performance
QA
qa checklist
referrals
removal
security
smart-contracts
tech-debt
testing
time-arena
timecurve
visual-qa
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/yieldomega#269
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add Play CRED as a payment option in the arena buy charm UI alongside CL8Y/ETH/USDM: read wallet CRED balance, compute required burn from selected CHARM, gate submit when insufficient, and call
TimeArena.buyWithCred(charmWad)on the correct chain.Bundled with onchain work in #268 (100 CRED per CHARM burn + first-buy bonus). This issue is frontend-only but must not ship burn math that disagrees with deployed
TimeArena.Parent: Arena v2 #238, arena mount #256, buy router #251 / #264.
Current codebase
PayWithAsset = "cl8y" | "eth" | "usdm"only (frontend/src/lib/kumbayaRoutes.ts).TimeCurveSimplePage/useTimeCurveSaleSession— token pickerSIMPLE_AMOUNT_PAY_TOKEN_OPTIONS(CL8Y, ETH, USDM).isArenaV2, onlypayWith === "cl8y"allowed; approves DOUB (acceptedAsset) and callsbuy().buyWithCredtimeArenaReadAbibut never called from frontend.ArenaCharmCredCard— epoch CHARM,pendingCred,claimCredonly (read/claim, not pay).frontend/src/lib/addresses.ts; available onchain asTimeArena.playCred().cred_claimedinWalletProfileModal; no live CRED balance.Relevant files
frontend/src/lib/kumbayaRoutes.ts— extend pay type or parallelpayModefrontend/src/pages/TimeCurveSimplePage.tsx— token picker options, labels, slider copyfrontend/src/pages/timecurve/useTimeCurveSaleSession.ts— submit path, gates, sizingfrontend/src/lib/abis.ts—buyWithCred, ERC20balanceOfon PlayCredfrontend/src/lib/addresses.ts— optionalplayCredfrom env or derived readfrontend/src/pages/arena/ArenaCharmCredCard.tsx— may share CRED balance hookfrontend/src/components/ChainMismatchWriteBarrier.tsx— wrap writesfrontend/e2e/arenaE2eHelpers.ts—selectPayWithhelperdocs/frontend/arena-views.md(if present) — UX specdocs/testing/manual-qa-checklists.md— Arena v2 QA sectionWhy this is needed
buyWithCredexists onchain but is unreachable for normal users without wallet/script calls.Constraints and guardrails
TimeArena(readCRED_PER_CHARM_WADconstant orcredBurnForCharm(charmWad)view if added onchain).ChainMismatchWriteBarrier/chainMismatchWriteMessage(#95).TimeArena/isArenaV2; do not break legacy TimeCurve paths if still mounted (#266).balanceOf+buyWithCred(no ERC20 allowance UX).nextBuyAllowedAt/ buy cooldown UX as DOUB buys.aria-labelincludes CRED.Recommended direction
useReadContracttimeArena.playCred()when env unset; cache in session context."cred"to pay union (orpayWith+payAssetsplit). Picker shows CRED with distinct label/logo.balanceOf(user)on PlayCred; poll/refetch after buy and on claim.requiredCred = charmWad * 100n / WAD(or read onchain helper post-deploy). Show in checkout summary and insufficient-CRED gate (mirror CL8Y insufficient pattern inTimeCurveSimplePage).writeContractbuyWithCred(charmWad)with gas buffer helper used elsewhere; no DOUB approve.Acceptance criteria
/arena(or unified simple buy surface).balance < requiredCredor CHARM out of band.buyWithCredwith correctcharmWad(fresh sizing read before tx).ArenaCharmCredCarddata refresh.Test plan — functional paths
buyWithCredtx succeedsplayCred == address(0)Test plan — attack vectors / UX failure modes
balanceOfimmediately before submit; show revert message on failurereadFreshTimeCurveBuySizingor arena equivalentcredBurnForCharmWad()util tested against Forge expectationsbuy()TimeArena.playCred()on configured arena proxyisPendingVerification criteria
npm test/vitestfor any new burn helper.npx playwright testarena spec with CRED path (5 workers per repo convention).VITE_PLAY_CRED_ADDRESSonly as override if read fails.Depends on
Out of scope
marked as related to #268
mentioned in commit
faa36f0b22Implementation summary (#269)
Merged to
mainatfaa36f0.What changed
/arenabuy panel:arena-paywith-cred, wallet balance + burn preview,buyWithCred(charmWad)submit (no DOUB approve).arenaCredBurn.ts+useArenaPlayCred(playCred(),CRED_BUY_BURN; ready forCRED_PER_CHARM_WADwhen #268 lands).e2e/anvil-arena-cred-buy.spec.ts; DeployDev mints 1000 CRED to Anvil account #0.INV-FRONTEND-269-CRED-BUY, arena-views, manual QA, guardrails,play-time-arena-doub.Verification checklist
/arenashows CRED in pay toggles (arena-paywith-cred).buyWithCred(explorer / receipt).npm test—arenaCredBurn.test.tsbash scripts/e2e-anvil.sh— includesanvil-arena-cred-buy.spec.ts@brouie — please verify on Anvil or staging when you have a moment. Leaving issue open until sign-off.
mentioned in commit
84ba60048aQA verification (#269) — issue/269-verify worktree @
9831bd6Verified the frontend CRED buy path already on
main. No code changes were required; verification loop completed green on first pass.Worktree & sync
../yieldomega-issue-269-verifybranchissue/269-verify(same HEAD asorigin/main).origin/main; no new commits to merge. Worktree had no local diffs → nothing to merge beyond existingmain.Automated verification (all pass)
npm test -- --run src/lib/arenaCredBurn.test.tsnpm test -- --run(full Vitest)bash scripts/e2e-anvil.she2e/anvil-arena-04-cred-buy.spec.ts(buyWithCredon/arena)Implementation cross-check (acceptance criteria)
/arena—payTokenOptionsForSimpleBuy,arena-paywith-cred, amount pickerarena-simple-rate-pay-option-cred.useArenaPlayCredreadsplayCred(),CRED_PER_CHARM_WAD,balanceOf; preview test idsarena-simple-buy-preview-cred/arena-simple-buy-preview-insufficient-cred.resolveCredCheckoutBoundsGate+ disabled buy button + copy.buyWithCred(charmWad)—useArenaSaleSession.submitBuywith freshbalanceOfre-read before tx; no DOUB approve on CRED path.ChainMismatchWriteBarrier+chainMismatchWriteMessageon buy panel.refetchCred()inrefetchAllafter successful buy.eth/usdm; CRED bypasses router.arenaCredBurn.credBurnForCharmWad+ onchainCRED_PER_CHARM_WADread (#268 constant present inTimeArena.sol).playCred == 0— auto-fallback to DOUB viauseEffectin session hook.INV-FRONTEND-269-CRED-BUY,arena-views.md,manual-qa-checklists.mdCRED pay row, guardrails §9b,play-time-arena-doubskill.Manual sign-off checklist (for staging / MegaETH)
/arena→ select CRED (arena-paywith-cred).buyWithCred; CRED balance drops by burn amount.buy()path works.ArenaCharmCredCardepoch data refresh.aria-labelincludes token name, e.g. CRED).Closing as verified — all issue-body acceptance + verification criteria satisfied on
main. Dependency #268 onchain constant is present; that issue may remain open for separate contract QA.mentioned in issue #268