Fix buyWithCred to contribute 35 CRED to epoch pool per buy #311
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#311
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?
Parent
Gap analysis follow-up from #309.
Current codebase
buycalls_accrueCharmAndCred→epochCredPool[ep] += CRED_PER_BUY(35e18) plus CHARM weight (TimeArena.solL690–694).buyWithCredcalls_accrueCharmOnly— addsepochCharmWadbut does not contribute toepochCredPool(TimeArena.solL553–563, L711–717).INV-TIME-ARENA-CRED-NO-POOLdocuments current behavior; tests inTimeArena.t.solassert pool unchanged afterbuyWithCred.Why needed
Approved: CRED buys should add 35 CRED to the epoch pool and generate CHARM (claimable by charm holders). Buys purchase CHARM; CHARM utility is claiming CRED. Current dilution lets CRED-only buyers claim pro-rata from DOUB-funded pools.
Constraints / guardrails
CRED_PER_BUY = 35e18constant unchanged unless spec explicitly revises.buyWithCredstill burns/spends player CRED; only pool accrual changes.INV-TIME-ARENA-CRED-NO-POOLsemantics inversion — update invariant doc after fix.Relevant files
contracts/src/arena/TimeArena.sol—buyWithCred,_accrueCharmOnly,_accrueCharmAndCred,epochCredPoolcontracts/test/TimeArena.t.sol—test_buy_with_cred,test_cred_accrue_on_doub_buydocs/testing/invariants-and-business-logic.md— CRED pool invariantsbash scripts/verify-cred-buy-anvil.shRecommended direction
buyWithCred, accrue both CHARM weight andCRED_PER_BUYintoepochCredPoolfor the active epoch (mirror DOUB buy pool contribution).buyWithCred,epochCredPoolincreases by 35e18 and CRED claim pro-rata is fair.Acceptance criteria
buyWithCredadds 35 CRED toepochCredPool[epoch].claimCredpro-rata math fair for mixed DOUB/CRED buyers.CRED-NO-POOLremoved or revised.Test plan
cd contracts && forge test --match-test cred/buy_with_cred.bash scripts/verify-cred-buy-anvil.sh.cd indexer && cargo testif indexer decodes pool-related fields.Attack / abuse test plan
buyWithCredat roll boundary credits correct epoch pool.claimCredstill one-shot per epoch per wallet.Verification criteria
epochCredPooldelta afterbuyWithCred.verify-cred-buy-anvil.shPASS.test_cred_accrue_on_doub_buymixed scenarios.mentioned in issue #309
mentioned in merge request !460
mentioned in commit
621957a6ecmentioned in commit
28fbbba370mentioned in merge request !465
mentioned in merge request !475
mentioned in commit
bc74435db9mentioned in merge request !466
mentioned in commit
f68da432b9mentioned in commit
9d384bf7f1mentioned in commit
7d862aafa1mentioned in merge request !479
mentioned in commit
ac639db066mentioned in merge request !476
mentioned in commit
08492fd892mentioned in merge request !491
mentioned in commit
8ee5e455acmentioned in merge request !486
mentioned in commit
7fffda6109mentioned in commit
1b4f62603aVerification — #311 (PASS)
Verified
buyWithCredcontributes 35 CRED (CRED_PER_BUY) toepochCredPoolper buy, matching DOUB buy pool economics.Acceptance criteria
buyWithCredadds 35 CRED toepochCredPool[epoch]TimeArena._buyCredcalls_accrueCharmAndCred(L566); pool +=CRED_PER_BUY(L700). Forge:test_buy_with_cred,test_buyWithCred_accrues_epoch_cred_pool. Anvil:verify-cred-buy-anvil.shassertspool_delta == 35e18._accrueCharmAndCredpath as DOUB buys (codeHash = 0, no referral).test_xp_buy_with_cred_same_as_doubPASS.claimCredpro-rata fair for mixed DOUB/CRED buyerstest_buyWithCred_mixed_pro_rata_with_doub,test_cred_only_buyer_fair_share,test_cred_pro_rata_mixed_doub_and_cred_buyersPASS.CRED-NO-POOLsupersededINV-TIME-ARENA-CRED-POOL-ACCRUE/INV-TIME-ARENA-CRED-POOL-PARITYindocs/testing/invariants-and-business-logic.md;skills/play-time-arena-doub/SKILL.mdupdated.Test plan
cd contracts && forge test --match-test credcd contracts && forge test --match-test buy_with_credbash scripts/verify-cred-buy-anvil.sh=== verify-cred-buy-anvil: OK ===cd indexer && cargo testAttack / abuse
test_cred_only_buyer_fair_sharetest_buyWithCred_epoch_boundary_credits_correct_pool,test_cred_accrue_buyWithCred_at_epoch_boundarytest_claim_cred_*suite (no regression)test_cred_accrue_on_doub_buyNo repo changes required; closing as verified on
main.