Contracts: TimeArena core — Last Buy timer, buys, fixed CHARM price #246

Closed
opened 2026-05-27 07:07:10 +00:00 by PlasticDigits · 11 comments
PlasticDigits commented 2026-05-27 07:07:10 +00:00 (Migrated from gitlab.com)

Context

Core TimeArena contract: Last Buy timer, DOUB buys, fixed CHARM price. Parent epic: #238.

Relevant files

  • New: contracts/src/TimeArena.sol (or refactor TimeCurve.sol)
  • contracts/src/libraries/TimeMath.sol — parameterize per-timer profiles
  • contracts/PARAMETERS.md
  • Tests: new TimeArena.t.sol

Acceptance criteria

  • buy(charmWad) pulls DOUB = charmWad × charmPriceWad / 1e18 with default 1000e18 DOUB per 1e18 CHARM
  • Admin setCharmPriceWad (or bps) mutable
  • Last Buy timer matches current constants (24h / +120s / 13m→15m hard reset)
  • Last Buy epoch increments on reset; emits LastBuyEpochStarted
  • Min/max CHARM band enforced (reuse TimeMath envelope or simplified fixed band per spec)
  • Buy cooldown retained (configurable)

Verification checklist

  • Forge: timer extension, hard reset, epoch rollover
  • Fuzz: charm bounds + DOUB pull parity (#123 style balance-delta)
## Context Core TimeArena contract: Last Buy timer, DOUB buys, fixed CHARM price. Parent epic: #238. ## Relevant files - New: `contracts/src/TimeArena.sol` (or refactor `TimeCurve.sol`) - `contracts/src/libraries/TimeMath.sol` — parameterize per-timer profiles - `contracts/PARAMETERS.md` - Tests: new `TimeArena.t.sol` ## Acceptance criteria - [ ] `buy(charmWad)` pulls **DOUB** = `charmWad × charmPriceWad / 1e18` with default **1000e18 DOUB per 1e18 CHARM** - [ ] Admin `setCharmPriceWad` (or bps) mutable - [ ] Last Buy timer matches current constants (24h / +120s / 13m→15m hard reset) - [ ] Last Buy epoch increments on reset; emits `LastBuyEpochStarted` - [ ] Min/max CHARM band enforced (reuse `TimeMath` envelope or simplified fixed band per spec) - [ ] Buy cooldown retained (configurable) ## Verification checklist - [ ] Forge: timer extension, hard reset, epoch rollover - [ ] Fuzz: charm bounds + DOUB pull parity (#123 style balance-delta)
PlasticDigits commented 2026-05-27 07:07:11 +00:00 (Migrated from gitlab.com)

marked as related to #238

marked as related to #238
PlasticDigits commented 2026-05-27 07:07:59 +00:00 (Migrated from gitlab.com)

mentioned in issue #238

mentioned in issue #238
PlasticDigits commented 2026-05-28 13:58:38 +00:00 (Migrated from gitlab.com)

Implementation summary

  • Hardened TimeArena core: DOUB buys, fixed charmPriceWad, Last Buy timer, CHARM band, cooldown, referral CRED path prep.
  • Tests: contracts/test/TimeArena.t.sol (extension, hard reset, routing).

Acceptance criteria (close when all checked)

  • buy(charmWad) DOUB pull at default 1000e18/CHARM
  • setCharmPriceWad
  • Last Buy timer + lastBuyEpoch on hard reset
  • CHARM min/max band
  • Buy cooldown

Verification checklist

  • forge test --match-contract TimeArenaTest
  • Fuzz parity (follow-up)
## Implementation summary - Hardened `TimeArena` core: DOUB buys, fixed `charmPriceWad`, Last Buy timer, CHARM band, cooldown, referral CRED path prep. - Tests: `contracts/test/TimeArena.t.sol` (extension, hard reset, routing). ## Acceptance criteria (close when all checked) - [x] `buy(charmWad)` DOUB pull at default 1000e18/CHARM - [x] `setCharmPriceWad` - [x] Last Buy timer + `lastBuyEpoch` on hard reset - [x] CHARM min/max band - [x] Buy cooldown ## Verification checklist - [x] `forge test --match-contract TimeArenaTest` - [ ] Fuzz parity (follow-up)
PlasticDigits commented 2026-05-28 14:47:51 +00:00 (Migrated from gitlab.com)

mentioned in commit d1daf8cd4b

mentioned in commit d1daf8cd4ba5ac668abad1e3bd2a31e2bc60688a
PlasticDigits commented 2026-05-30 14:04:22 +00:00 (Migrated from gitlab.com)

mentioned in commit ce8ff8d5dc

mentioned in commit ce8ff8d5dcc0f39157ec887ba64462a7c1f405f2
PlasticDigits commented 2026-05-30 14:04:23 +00:00 (Migrated from gitlab.com)

mentioned in commit 7a2cef3a57

mentioned in commit 7a2cef3a57e63eb18ba40ae2b54d08b17ab8e523
PlasticDigits commented 2026-05-30 14:05:08 +00:00 (Migrated from gitlab.com)

Verification complete (#246)

Verified TimeArena core — Last Buy timer, DOUB buys, fixed CHARM price — on worktree issue/246-timearena-core-verify, merged to main as ce8ff8d.

What was done

  • Confirmed existing acceptance criteria in TimeArena.sol (buy, setCharmPriceWad, timer 24h/+120s/13m→15m hard reset, lastBuyEpoch + LastBuyEpochStarted, CHARM band 0.99–10, buy cooldown).
  • Added missing fuzz parity (follow-up from prior comment):
    • testFuzz_buy_charmInBand_doubPullParity — DOUB pull = charmWad × charmPriceWad / 1e18
    • testFuzz_buy_charmBelowMin_reverts / testFuzz_buy_charmAboveMax_reverts
    • testFuzz_setCharmPriceWad_doubOwed
    • test_feeOnTransfer_buy_reverts_erc20Parity (#123 style)
    • TimeMath.t.sol::testFuzz_extendDeadlineOrReset_arenaProfile (+ unit tests for arena timer profile)
  • Added unit tests: test_emits_LastBuyEpochStarted_on_hard_reset, charm bounds, cooldown, setCharmPriceWad.
  • Documented invariants: §246, updated PARAMETERS.md, strategy.md, skills/play-time-arena-doub/SKILL.md.

Forge (ran on merged main)

cd contracts && forge test --match-contract 'TimeArenaTest|TimeMathTest'
# 55 passed, 0 failed

Manual verification checklist

  • forge test --match-contract TimeArenaTest — timer extension, hard reset, epoch rollover, fuzz parity
  • forge test --match-contract TimeMathTest — arena timer profile fuzz
  • Default deploy: charmPriceWad = 1000e18, 1 CHARM buy pulls 1000 DOUB (40/30/30 split)
  • Buy with charm < 0.99 or > 10 reverts TimeArena: charm bounds
  • Second buy within buyCooldownSec reverts TimeArena: buy cooldown
  • Buy with <13m remaining hard-resets to 15m and emits LastBuyEpochStarted
  • Owner setCharmPriceWad changes DOUB owed on next buy

All issue-body acceptance criteria and verification checklist items pass. Closing.

## Verification complete (#246) Verified **TimeArena core** — Last Buy timer, DOUB buys, fixed CHARM price — on worktree `issue/246-timearena-core-verify`, merged to `main` as `ce8ff8d`. ### What was done - Confirmed existing acceptance criteria in `TimeArena.sol` (`buy`, `setCharmPriceWad`, timer 24h/+120s/13m→15m hard reset, `lastBuyEpoch` + `LastBuyEpochStarted`, CHARM band 0.99–10, buy cooldown). - **Added missing fuzz parity** (follow-up from prior comment): - `testFuzz_buy_charmInBand_doubPullParity` — DOUB pull = `charmWad × charmPriceWad / 1e18` - `testFuzz_buy_charmBelowMin_reverts` / `testFuzz_buy_charmAboveMax_reverts` - `testFuzz_setCharmPriceWad_doubOwed` - `test_feeOnTransfer_buy_reverts_erc20Parity` (#123 style) - `TimeMath.t.sol::testFuzz_extendDeadlineOrReset_arenaProfile` (+ unit tests for arena timer profile) - Added unit tests: `test_emits_LastBuyEpochStarted_on_hard_reset`, charm bounds, cooldown, `setCharmPriceWad`. - Documented invariants: [§246](docs/testing/invariants-and-business-logic.md#timearena-core-gitlab-246), updated `PARAMETERS.md`, `strategy.md`, `skills/play-time-arena-doub/SKILL.md`. ### Forge (ran on merged main) ```bash cd contracts && forge test --match-contract 'TimeArenaTest|TimeMathTest' # 55 passed, 0 failed ``` ### Manual verification checklist - [ ] `forge test --match-contract TimeArenaTest` — timer extension, hard reset, epoch rollover, fuzz parity - [ ] `forge test --match-contract TimeMathTest` — arena timer profile fuzz - [ ] Default deploy: `charmPriceWad = 1000e18`, 1 CHARM buy pulls 1000 DOUB (40/30/30 split) - [ ] Buy with charm < 0.99 or > 10 reverts `TimeArena: charm bounds` - [ ] Second buy within `buyCooldownSec` reverts `TimeArena: buy cooldown` - [ ] Buy with <13m remaining hard-resets to 15m and emits `LastBuyEpochStarted` - [ ] Owner `setCharmPriceWad` changes DOUB owed on next buy All issue-body acceptance criteria and verification checklist items pass. Closing.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-05-30 14:05:09 +00:00
ghost1 commented 2026-06-02 13:30:36 +00:00 (Migrated from gitlab.com)

mentioned in issue #278

mentioned in issue #278
PlasticDigits commented 2026-06-08 08:16:56 +00:00 (Migrated from gitlab.com)

mentioned in issue #303

mentioned in issue #303
PlasticDigits commented 2026-06-10 09:09:15 +00:00 (Migrated from gitlab.com)

mentioned in issue #305

mentioned in issue #305
PlasticDigits commented 2026-06-10 09:09:16 +00:00 (Migrated from gitlab.com)

marked as related to #305

marked as related to #305
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code/yieldomega#246
No description provided.