Route buy prize remainder to Last Buy category #313

Closed
opened 2026-06-13 07:34:19 +00:00 by PlasticDigits · 18 comments
PlasticDigits commented 2026-06-13 07:34:19 +00:00 (Migrated from gitlab.com)

Parent

Gap analysis follow-up from #309.

Current codebase

  • ArenaBuyRouting.splitBuyAmount assigns cross-category remainder amount % 4 to category 3 (WarBow) (contracts/src/arena/libraries/ArenaBuyRouting.sol L23–35).
  • Within-category remainder goes to epoch+2 tranche.
  • Tests in ArenaPrizeRouting.t.sol and TimeArena.t.sol assert current WarBow remainder behavior.
  • Product spec incorrectly said remainder → Time Booster (cat 1); approved decision: remainder → Last Buy.

Why needed

Approved: Prize-routing remainder target should go to Last Buy (category 0), not WarBow. Spec was wrong; code must align with approved economics.

Constraints / guardrails

  • 100% podium routing invariant (#300) unchanged — only remainder bucket moves.
  • Update contracts/PARAMETERS.md, docs/product/time-arena.md, and arena-v2.md consistently.
  • Fuzz tests must be updated, not deleted.

Relevant files

  • contracts/src/arena/libraries/ArenaBuyRouting.sol
  • contracts/src/arena/libraries/ArenaPodiumSettlement.sol
  • contracts/test/ArenaPrizeRouting.t.sol
  • contracts/test/TimeArena.t.sol
  • contracts/PARAMETERS.md
  1. Change splitBuyAmount remainder assignment from cat 3 to cat 0 (Last Buy).
  2. Update fuzz and integration tests for new split.
  3. Document 4-way split with Last Buy receiving remainder wei.

Acceptance criteria

  • amount % 4 wei routes to Last Buy vault/tranche.
  • All Forge routing tests updated and pass.
  • Product docs reflect Last Buy remainder rule.

Test plan

  • cd contracts && forge test --match-contract ArenaPrizeRouting.
  • cd contracts && forge test --match-test buy_routes.

Attack / abuse test plan

  • Fuzz all amount values; sum of four category shares equals amount exactly.
  • No wei dust stranded on TimeArena.

Verification criteria

  • Fuzz test proves remainder lands on cat 0.
  • PARAMETERS.md matches code.
## Parent Gap analysis follow-up from [#309](https://gitlab.com/PlasticDigits/yieldomega/-/issues/309). ## Current codebase - `ArenaBuyRouting.splitBuyAmount` assigns cross-category remainder `amount % 4` to **category 3 (WarBow)** (`contracts/src/arena/libraries/ArenaBuyRouting.sol` L23–35). - Within-category remainder goes to epoch+2 tranche. - Tests in `ArenaPrizeRouting.t.sol` and `TimeArena.t.sol` assert current WarBow remainder behavior. - Product spec incorrectly said remainder → Time Booster (cat 1); **approved decision: remainder → Last Buy**. ## Why needed Approved: Prize-routing remainder target should go to Last Buy (category 0), not WarBow. Spec was wrong; code must align with approved economics. ## Constraints / guardrails - 100% podium routing invariant (#300) unchanged — only remainder bucket moves. - Update `contracts/PARAMETERS.md`, `docs/product/time-arena.md`, and `arena-v2.md` consistently. - Fuzz tests must be updated, not deleted. ## Relevant files - `contracts/src/arena/libraries/ArenaBuyRouting.sol` - `contracts/src/arena/libraries/ArenaPodiumSettlement.sol` - `contracts/test/ArenaPrizeRouting.t.sol` - `contracts/test/TimeArena.t.sol` - `contracts/PARAMETERS.md` ## Recommended direction 1. Change `splitBuyAmount` remainder assignment from cat 3 to cat 0 (Last Buy). 2. Update fuzz and integration tests for new split. 3. Document 4-way split with Last Buy receiving remainder wei. ## Acceptance criteria - [ ] `amount % 4` wei routes to Last Buy vault/tranche. - [ ] All Forge routing tests updated and pass. - [ ] Product docs reflect Last Buy remainder rule. ## Test plan - `cd contracts && forge test --match-contract ArenaPrizeRouting`. - `cd contracts && forge test --match-test buy_routes`. ## Attack / abuse test plan - Fuzz all `amount` values; sum of four category shares equals `amount` exactly. - No wei dust stranded on `TimeArena`. ## Verification criteria - Fuzz test proves remainder lands on cat 0. - `PARAMETERS.md` matches code.
PlasticDigits commented 2026-06-13 07:34:43 +00:00 (Migrated from gitlab.com)

mentioned in issue #309

mentioned in issue #309
PlasticDigits commented 2026-06-13 07:59:34 +00:00 (Migrated from gitlab.com)

mentioned in merge request !458

mentioned in merge request !458
PlasticDigits commented 2026-06-13 09:27:30 +00:00 (Migrated from gitlab.com)

mentioned in commit 729570edf4

mentioned in commit 729570edf4be55afe9565278e752a735e645508b
PlasticDigits commented 2026-06-13 09:39:19 +00:00 (Migrated from gitlab.com)

mentioned in commit 868a79120c

mentioned in commit 868a79120ca63a288fcd1fa53af72eede7897295
PlasticDigits commented 2026-06-13 09:39:24 +00:00 (Migrated from gitlab.com)

mentioned in merge request !464

mentioned in merge request !464
PlasticDigits commented 2026-06-13 13:23:23 +00:00 (Migrated from gitlab.com)

mentioned in commit 6ac3906724

mentioned in commit 6ac39067246979ae786013eb0cc1c7f081f7d30a
PlasticDigits commented 2026-06-13 13:23:49 +00:00 (Migrated from gitlab.com)

mentioned in merge request !473

mentioned in merge request !473
PlasticDigits commented 2026-06-13 14:12:28 +00:00 (Migrated from gitlab.com)

mentioned in commit bc74435db9

mentioned in commit bc74435db9558298f2bd32140f3ed74867a9dcc5
PlasticDigits commented 2026-06-13 14:12:32 +00:00 (Migrated from gitlab.com)

mentioned in merge request !466

mentioned in merge request !466
PlasticDigits commented 2026-06-13 14:13:32 +00:00 (Migrated from gitlab.com)

mentioned in commit 15e2998f9b

mentioned in commit 15e2998f9bfa213471e487979c64e3cd99856499
PlasticDigits commented 2026-06-14 02:37:39 +00:00 (Migrated from gitlab.com)

mentioned in commit fdcb558991

mentioned in commit fdcb5589917894976be9e637eec5a8ece7bdcb55
PlasticDigits commented 2026-06-14 02:53:35 +00:00 (Migrated from gitlab.com)

mentioned in commit ac639db066

mentioned in commit ac639db066fab289e33d02b0b95b1322a3cd0b85
PlasticDigits commented 2026-06-14 02:53:38 +00:00 (Migrated from gitlab.com)

mentioned in merge request !476

mentioned in merge request !476
PlasticDigits commented 2026-06-14 05:36:37 +00:00 (Migrated from gitlab.com)

mentioned in merge request !485

mentioned in merge request !485
PlasticDigits commented 2026-06-14 06:54:17 +00:00 (Migrated from gitlab.com)

mentioned in commit 24dca3ef0b

mentioned in commit 24dca3ef0b06cf7a028fb83bf435282a4e6f722a
PlasticDigits commented 2026-06-14 06:56:15 +00:00 (Migrated from gitlab.com)

mentioned in commit 8ee5e455ac

mentioned in commit 8ee5e455ac7e096c3532a1b2c2eb273e4eebefa7
PlasticDigits commented 2026-06-14 06:56:31 +00:00 (Migrated from gitlab.com)

mentioned in merge request !486

mentioned in merge request !486
PlasticDigits commented 2026-06-14 14:03:28 +00:00 (Migrated from gitlab.com)

Verification complete — GitLab #313

Verified on main (clean working tree, no MR required).

Acceptance criteria

Criterion Result How verified
amount % 4 wei routes to Last Buy vault/tranche PASS ArenaBuyRouting.splitBuyAmount assigns catRem = amount % 4 to category 0 (i == 0 ? catRem : 0). Unit test test_split_remainder_to_last_buy_and_t10_tranche (1003 → cat 0 share 253, cat 3 share 250).
All Forge routing tests updated and pass PASS cd contracts && forge test --match-contract ArenaPrizeRouting — 7/7 passed. cd contracts && forge test --match-test buy_routes — 2/2 passed (test_buy_routes_doub_split, test_buy_routes_epoch_tranches_worked_example).
Product docs reflect Last Buy remainder rule PASS contracts/PARAMETERS.md L19; docs/product/time-arena.md L51; docs/product/arena-v2.md L48; docs/testing/invariants-and-business-logic.md INV-ARENA-PRIZE-ROUTING-300-25PCT all state remainder → Last Buy (cat 0).

Verification criteria (attack / fuzz)

Criterion Result How verified
Fuzz: sum of four category shares equals amount exactly PASS testFuzz_splitBuy_no_dust (256 runs)
Fuzz: remainder lands on cat 0 PASS testFuzz_split_remainder_on_cat0 (256 runs) + testFuzz_epoch_split_per_category_bps asserts cat 0 gets baseShare + catRem when catRem > 0
PARAMETERS.md matches code PASS Table row "remainder → Last Buy" aligns with ArenaBuyRouting.sol L10–34
100% podium routing invariant (#300) unchanged PASS test_buy_routes_doub_split — 0% admin, 100% to vaults, 12 PodiumEpochFunded events

Manual / infra

Item Result Notes
Anvil / indexer / frontend E2E SKIP Issue scope is pure routing math + Forge/docs; no indexer or UI behavior change.

Commands run

export PATH="$HOME/.foundry/bin:$PATH"
cd contracts && forge test --match-contract ArenaPrizeRouting -vv   # 7 passed
cd contracts && forge test --match-test buy_routes -vv              # 2 passed

Closing — implementation already on main.

## Verification complete — GitLab #313 Verified on `main` (clean working tree, no MR required). ### Acceptance criteria | Criterion | Result | How verified | |-----------|--------|--------------| | `amount % 4` wei routes to Last Buy vault/tranche | **PASS** | `ArenaBuyRouting.splitBuyAmount` assigns `catRem = amount % 4` to category 0 (`i == 0 ? catRem : 0`). Unit test `test_split_remainder_to_last_buy_and_t10_tranche` (1003 → cat 0 share 253, cat 3 share 250). | | All Forge routing tests updated and pass | **PASS** | `cd contracts && forge test --match-contract ArenaPrizeRouting` — 7/7 passed. `cd contracts && forge test --match-test buy_routes` — 2/2 passed (`test_buy_routes_doub_split`, `test_buy_routes_epoch_tranches_worked_example`). | | Product docs reflect Last Buy remainder rule | **PASS** | `contracts/PARAMETERS.md` L19; `docs/product/time-arena.md` L51; `docs/product/arena-v2.md` L48; `docs/testing/invariants-and-business-logic.md` `INV-ARENA-PRIZE-ROUTING-300-25PCT` all state remainder → Last Buy (cat 0). | ### Verification criteria (attack / fuzz) | Criterion | Result | How verified | |-----------|--------|--------------| | Fuzz: sum of four category shares equals `amount` exactly | **PASS** | `testFuzz_splitBuy_no_dust` (256 runs) | | Fuzz: remainder lands on cat 0 | **PASS** | `testFuzz_split_remainder_on_cat0` (256 runs) + `testFuzz_epoch_split_per_category_bps` asserts cat 0 gets `baseShare + catRem` when `catRem > 0` | | `PARAMETERS.md` matches code | **PASS** | Table row "remainder → Last Buy" aligns with `ArenaBuyRouting.sol` L10–34 | | 100% podium routing invariant (#300) unchanged | **PASS** | `test_buy_routes_doub_split` — 0% admin, 100% to vaults, 12 `PodiumEpochFunded` events | ### Manual / infra | Item | Result | Notes | |------|--------|-------| | Anvil / indexer / frontend E2E | **SKIP** | Issue scope is pure routing math + Forge/docs; no indexer or UI behavior change. | ### Commands run ``` export PATH="$HOME/.foundry/bin:$PATH" cd contracts && forge test --match-contract ArenaPrizeRouting -vv # 7 passed cd contracts && forge test --match-test buy_routes -vv # 2 passed ``` Closing — implementation already on `main`.
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-06-14 14:03:29 +00:00
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#313
No description provided.