Fix buyWithCred to contribute 35 CRED to epoch pool per buy (#311) #460
No reviewers
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!460
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/311-cred-buy-epoch-pool"
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
Fixes #311:
buyWithCrednow mirrors DOUB buys for epoch CRED economics by calling_accrueCharmAndCred(withcodeHash = 0, so no referral mint). Each CRED buy still burns player CRED and skips DOUB podium routing, but addsCRED_PER_BUY(35e18) toepochCredPool[lastBuyEpoch].INV-TIME-ARENA-CRED-NO-POOLwithINV-TIME-ARENA-CRED-POOL-PARITYverify-cred-buy-anvil.sh(pool assertion + onboarding level expectation aligned with #299)Acceptance checklist
buyWithCredadds 35 CRED toepochCredPool[epoch]cd contracts && forge test --match-test "cred_accrue_on_cred_buy|test_buy_with_cred"forge test --match-test test_xp_buy_with_cred_same_as_doubclaimCredpro-rata fair for mixed DOUB/CRED buyersforge test --match-test test_cred_pro_rata_mixed_doub_and_cred_buyersCRED-NO-POOLreviseddocs/testing/invariants-and-business-logic.md§311verify-cred-buy-anvil.shbash scripts/verify-cred-buy-anvil.shforge test --match-test test_cred_accrue_on_doub_buyforge test --match-test test_cred_accrue_buyWithCred_at_epoch_boundaryforge test --match-test test_claimCred_cannot_double_claimcd indexer && cargo testconfig::database_pool_max_tests::rejects_zerofailure on mainThird-party verification
Confirm onchain after a CRED buy:
Docs: invariants §311 · play skill
changed the description
changed the description
Security review — MR !460
Commit reviewed:
52b75ff0d9fac20e1d6858bdaee00647e9bd68c5Scope: On-chain change in
TimeArena._buyCred(swap_accrueCharmOnly→_accrueCharmAndCredwithcodeHash = bytes32(0)); supporting Forge tests, docs/invariants, frontend CRED copy, andverify-cred-buy-anvil.shpool assertion.Outcome:
FINDINGS: 0medium+Inline threads: None (no medium+ findings to anchor).
Analysis summary
Reviewed attacker-controlled paths for
buyWithCred→_accrueCharmAndCred→claimCred:buyWithCred/claimCredarenonReentrant;PlayCredmint/burn has no external callbacks — no new reentrancy surface.bytes32(0)skips thecodeHash != 0referral branch in_accrueCharmAndCred— intentional; CRED path still has no referral mint (matches DOUB referral semantics).claimCredzeros per-epoch weight before mint; pro-ratamulDivrounds down; unchanged claim path — no new inflation or double-claim vector.charmWad × CRED_PER_CHARM_WAD / WAD(≥99 CRED at min CHARM) while adding onlyCRED_PER_BUY(35) toepochCredPool; solo-epoch max claim is 35 < burn. Mixed-epoch pro-rata tested intest_cred_pro_rata_mixed_doub_and_cred_buyers._prepareBuyBeforeTimermay incrementlastBuyEpochbefore accrual; boundary test confirms pool credits post-reset epoch — consistent with DOUB path._finishBuy— accrual cannot proceed without successful burn.This MR closes the pre-existing free-rider gap where CRED buyers accrued epoch CHARM weight without contributing to
epochCredPool, diluting DOUB-funded pool claims. The change aligns CRED economics with DOUB without widening auth or external-call surfaces.Security review: no medium+ findings on this diff.
mentioned in commit
621957a6ec