Add buy-energy charges for burst play #332
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#332
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
Replace the flat per-wallet Arena buy cooldown with a buy-energy charge model that preserves the current long-run pacing budget while allowing short burst sessions.
Proposed mechanic:
This is intended to support GitLab #331's goal of fun, clear UX that can be played in short bursts throughout the day without turning Arena buys into unrestricted spam.
Current Codebase
Arena v2 currently uses a flat per-wallet buy cooldown:
docs/product/primitives.mddocumentsbuyCooldownSecwith production default 300 seconds andnextBuyAllowedAt[buyer] = block.timestamp + buyCooldownSec.contracts/src/arena/TimeArena.solenforces buy pacing during buy flows.contracts/script/DeployDevBuyCooldown.sol,contracts/script/DeployDev.s.sol, andcontracts/script/DeployProduction.s.solconfigure dev and production cooldown behavior.frontend/src/lib/indexerApi.tsand Arena timer/session hooks expose cooldown-adjacent sale-head data to the play UI.frontend/src/pages/arena/ArenaSimplePage.tsxowns the main play route and buy panel UX.indexer/src/api_arena.rs,indexer/src/chain_timer.rs, and related API structs expose Arena timer and sale-head fields.simulations/timecurve_sim/model.pyandsimulations/tests/test_ecostrategy.pymodel cooldown effects and already test that longer cooldowns reduce buys.Why This Is Needed
The flat 5-minute cooldown is useful anti-spam, but it conflicts with short-session play:
This should improve the primary play loop without discarding the original pacing intent.
Constraints And Guardrails
TimeArena, not only in the frontend or indexer.Relevant Files
Contracts and deploy:
contracts/src/arena/TimeArena.solcontracts/test/TimeArena.t.solcontracts/script/DeployDev.s.solcontracts/script/DeployProduction.s.solcontracts/script/DeployDevBuyCooldown.solcontracts/PARAMETERS.mdDocs and invariants:
docs/product/primitives.mddocs/product/arena-v2.mddocs/testing/invariants-and-business-logic.mddocs/testing/manual-qa-checklists.mddocs/testing/e2e-anvil.mdIndexer/API:
indexer/src/api_arena.rsindexer/src/chain_timer.rsindexer/src/chain_timer_poll.rsindexer/tests/integration_stage2.rsFrontend:
frontend/src/lib/indexerApi.tsfrontend/src/pages/arena/ArenaSimplePage.tsxfrontend/src/pages/arena/useArenaSaleSession.tsfrontend/src/pages/arena/useArenaHeroTimer.tsfrontend/src/pages/arena/Simulation and bots:
simulations/timecurve_sim/model.pysimulations/tests/test_ecostrategy.pybots/timearena/README.mdRecommended Direction
Implement a
BuyEnergyor equivalent onchain state model:Suggested parameters:
buyChargeIntervalSec = 300maxBuyCharges = 5burstBuyCooldownSec = 15On each buy:
lastRefillAt.maxBuyCharges.block.timestamp >= lastBuyAt + burstBuyCooldownSec.Expose enough read data for UX:
Prefer a dedicated view function on
TimeArenafor wallet buy-energy state so frontend/indexer logic does not duplicate refill math incorrectly.Frontend direction:
Indexer direction:
VITE_INDEXER_URLis set per #301.Simulation direction:
Acceptance Criteria
Test Plan: Normal And Edge Paths
Contracts:
TimeArenabuy tests continue to pass.Indexer/API:
Frontend:
Simulation:
Attack, Hack, And Abuse Test Plan
Verification Criteria
Minimum merge verification should include:
cd contracts && forge testcd indexer && cargo clippy --all-targets -- -D warnings && cargo testcd frontend && npm run typecheck && npm run lint && npm testbash scripts/verify-podium-live-anvil.shor a new focusedverify-buy-energy-anvil.shMR checklist must include one row per touched layer: item, command, PASS/FAIL.
mentioned in merge request !505
Verify — GitLab #332 (buy-energy charges for burst play)
Result: All issue acceptance criteria PASS on
main@35c938ca(mergedfix/332-buy-energy-charges). No repo/MR changes required.Contracts
bash scripts/verify-buy-energy-anvil.shTimeArena+DeployDevBuyCooldownsuiteforge test --match-contract 'TimeArena|DeployDevBuyCooldown'forge testcd contracts && forge testDoubAirdropMegaethFork(gitignoredairdrop/doub.csv, documented) · FAIL 2×TimeArenaWarbowBenchmark(timer not armed/level— pre-existing gas benchmark, unrelated to buy-energy)test_constants_match_documented_defaults,test_readBuyEnergyParams_env_resolution_matrixtest_buy_energy_*,test_buy_spends_one_buy_charge,test_buy_reverts_inside_burst_cooldown, etc.maxBuyCharges + level - 1)test_buy_energy_cap_includes_level_bonusTimeArena.t.soltestsIndexer
cd indexer && cargo clippy --all-targets -- -D warnings && cargo testintegration_stage2.rs(buy_charge_interval_sec,max_buy_charges,burst_buy_cooldown_sec)bash scripts/verify-podium-live-anvil.shFrontend
cd frontend && npm run typecheck && npm run lint && npm testArenaSimplePage.test.tsx(aria-label="Buy CHARM — 5 of 5 moves available")arenaSaleSessionBuyPreflight.test.ts(TimeArena: burst cooldown)arenaV2SaleSessionBridge.test.ts(charge interval/cap/burst fields)ANVIL_E2E=1 npx playwright test e2e/anvil-arena-01-mount.spec.tsanvil-arena-02/03on ad-hoc:8547previewscripts/e2e-anvil.shorchestration). Issue-specific UX is covered by unit tests + onchain cast below.e2e/buy-energy.spec.tsin a follow-up.Simulation
cd simulations && python3 -m unittest tests.test_ecostrategy.TestEcoScenarios.test_simulate_sale_buy_energy_burst_beats_flat_single_charge_sessionOnchain spot-check (Anvil
:8547, production-like params)Cast against deployed
TimeArenaproxy:TimeArena: burst cooldown(PASS)anvil_increaseTime(15): second buy succeeds (PASS)Docs / invariants
docs/product/primitives.md,docs/product/arena-v2.md,docs/testing/invariants-and-business-logic.md(INV-TIME-ARENA-BUY-ENERGY-332),docs/testing/e2e-anvil.md— buy-energy language present and cross-linked (PASS).Follow-ups (optional)
frontend/e2e/buy-energy.spec.tsfor burst-blocked and out-of-charges UI paths under fullscripts/e2e-anvil.shorchestration.TimeArenaWarbowBenchmark.t.solsetup (arm timers / level prerequisites) so fullforge testis green outside gitignored fork fixtures.