Fix buyWithCred to contribute 35 CRED to epoch pool per buy #475
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!475
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
buyWithCredthrough_accrueCharmAndCredso each CRED buy adds 35 CRED (CRED_PER_BUY) toepochCredPool[lastBuyEpoch], mirroring DOUB buys._accrueCharmOnly; add Forge tests for pool accrual, mixed DOUB/CRED pro-rata, epoch boundary, and fair CRED-only claims.INV-TIME-ARENA-CRED-NO-POOLwithINV-TIME-ARENA-CRED-POOL-ACCRUE; update product docs and guardrails.verify-cred-buy-anvil.shwith on-chainepochCredPoolassertion; fix stale starter-buy level expectation (#304 max-band XP → level 2).Verification checklist
buyWithCredadds 35 CRED toepochCredPool[epoch]forge test --match-test test_buy_with_cred·test_buyWithCred_accrues_epoch_cred_poolforge 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_credCRED-NO-POOLreviseddocs/testing/invariants-and-business-logic.md→INV-TIME-ARENA-CRED-POOL-ACCRUEcd contracts && forge test --match-contract TimeArenaverify-cred-buy-anvil.shbash scripts/verify-cred-buy-anvil.shforge test --match-test test_cred_accrue_on_doub_buyforge test --match-test test_buyWithCred_only_fair_pro_rata_claimforge test --match-test test_buyWithCred_epoch_boundary_credits_correct_poolforge test --match-test test_claimCred_cannot_double_claimepochCredPoolindexer decode in scopechanged the description
changed the description
Security review — MR !475
Commit reviewed:
68ddfb0c9a839fd47e4dee8a7b11b2810bd854c8Scope:
TimeArena.solchange routingbuyWithCredthrough_accrueCharmAndCred(epoch pool +35 CRED per buy); removed_accrueCharmOnly; Forge tests, docs/invariants,verify-cred-buy-anvil.sh.Prior review threads: None on this MR (re-checked discussions).
Outcome:
FINDINGS: 0medium+ — NONEAnalysis summary
Traced attacker-controlled inputs (
charmWad,msg.sender) through_buyCred→playCred.burn→_accrueCharmAndCred(buyer, charmWad, bytes32(0))→_finishBuy→claimCred.nonReentrantonbuyWithCred/claimCred;PlayCredhas no transfer hooks; burn still precedes accrual/finish (unchanged order).buyWithCredremains self-serve with existing cooldown + CHARM bounds.codeHash = bytes32(0)skips referral mint branch in_accrueCharmAndCred(same as DOUB path without code).CRED_PER_BUY(35e18) per buy; claims use existing pro-ratamulDivwith epoch weight zeroing. Sole/mixed-buyer tests show claim ≤ pool and burn (≥99 CRED at min CHARM) exceeds pro-rata return — no CRED mint arbitrage.charmWadCRED buys dilute others' CHARM weight; MR adds matching pool contribution (same model as DOUB buys) — does not open a new drain path.lastBuyEpochbefore_finishBuyhard-reset; covered bytest_buyWithCred_epoch_boundary_credits_correct_pool.Inline threads: None (no medium+ findings).
Label:
block:securitynot applied.added 31 commits
mainf68da432- Merge origin/main into fix/311-cred-buy-epoch-poolCompare with previous version
Resolved merge conflicts with
origin/main:_applyBuyWarBowBpstreak-break signature (5-arg); CRED pool accrual unchanged.test_cred_pro_rata_mixed_doub_and_cred_buyersand hard-reset boundary test.INV-TIME-ARENA-CRED-POOL-PARITYwith combined test evidence from both branches.epochCredPool +35delta assertion (removed duplicate block from MR).Sanity:
forge test --match-contract TimeArenaPASS.changed the description
Security review — MR !475
Commit reviewed:
f68da432b949c07905d0162dd87020c4e991b9faScope: Current MR diff vs
main(8dd57052): additional Forge tests (TimeArena.t.sol), product/invariant docs, guardrails. Contract routing (buyWithCred→_accrueCharmAndCred) andverify-cred-buy-anvil.shpool assertion are already onmainat merge-base; re-traced full on-chain path for regression after main merge.Prior review threads: Reviewed prior note on
68ddfb0c— no medium+ findings there; re-validated against post-merge head.Outcome:
FINDINGS: 0medium+ — NONEAnalysis summary
Traced attacker-controlled inputs (
charmWad,msg.sender) through_buyCred→playCred.burn→_accrueCharmAndCred(buyer, charmWad, bytes32(0))→_finishBuy→claimCred.nonReentrantonbuyWithCred/claimCred;PlayCredonly allows mint/burn (no transfer hooks); burn precedes accrual/finish.buyWithCredremains self-serve with existing cooldown + CHARM bounds.codeHash = bytes32(0)skips referral mint branch in_accrueCharmAndCred.CRED_PER_BUY(35e18) accrual;claimCredusesmulDivpro-rata with per-user weight zeroing. CRED burn (≥99e18 at min CHARM) exceeds solo or equal-split pro-rata return — no mint arbitrage.charmWadCRED buys dilute others' CHARM weight with matching pool contribution (parity with DOUB buys) — no new drain path._prepareBuyBeforeTimerre-anchorslastBuyEpochbefore accrual on hard reset; soft roll credits current epoch — covered bytest_buyWithCred_epoch_boundary_credits_correct_poolandtest_cred_accrue_buyWithCred_at_epoch_boundary.Inline threads: None (no medium+ findings).
Label:
block:securitynot applied.added 23 commits
main9d384bf7- Merge origin/main into fix/311-cred-buy-epoch-poolCompare with previous version
Resolved merge conflicts with
origin/main(2 files):.cursor/skills/yieldomega-guardrails/SKILL.md— kept #311 epoch pool accrual onbuyWithCredand updated first-buy bonus toFIRST_BUY_CRED_BONUS = 1100e18from main (#299).docs/product/arena-v2.md— same: 35 CRED pool accrual per CRED buy +1100e18first-buy bonus wording from main.Sanity:
forge test --match-contract TimeArena --match-test cred|buy_with_cred|buyWithCred— 24 passed.changed the description
mentioned in commit
03a43d4a6eSecurity review — MR !475
Commit reviewed:
9d384bf7f1cfdf16a14b695e65f36fa6d1115a6fScope: MR diff vs
main(2f53f814): additional Forge tests (TimeArena.t.sol), product/invariant docs, guardrails. On-chain routing (buyWithCred→_accrueCharmAndCred,epochCredPool += CRED_PER_BUY) is already present onmainat merge-base; re-traced full attacker path for regression after latest merge.Prior review threads: Two prior top-level reviews (
68ddfb0c,f68da432) reportedFINDINGS: 0; no inline security threads. Re-validated against current head — conclusions unchanged.Outcome:
FINDINGS: 0medium+ — NONEAnalysis summary
Traced attacker-controlled inputs (
charmWad,msg.sender) through_buyCred→playCred.burn→_accrueCharmAndCred(buyer, charmWad, bytes32(0))→_finishBuy→claimCred.nonReentrantonbuyWithCred/claimCred;PlayCredis non-transferable with no external hooks; burn precedes accrual/finish.buyWithCredremains self-serve with existing cooldown + CHARM bounds.codeHash = bytes32(0)skips referral mint branch in_accrueCharmAndCred.CRED_PER_BUY(35e18) accrual;claimCredusesmulDivpro-rata with per-user weight zeroing. CRED burn (≥99e18 at min CHARM) exceeds solo or equal-split pro-rata return — no mint arbitrage.charmWadCRED buys dilute others' CHARM weight with matching pool contribution (parity with DOUB buys) — no new drain path._prepareBuyBeforeTimerre-anchorslastBuyEpochbefore accrual on hard reset; soft roll credits current epoch — covered bytest_buyWithCred_epoch_boundary_credits_correct_poolandtest_cred_accrue_buyWithCred_at_epoch_boundary.Inline threads: None (no medium+ findings).
Label:
block:securitynot applied.