Skip to content

feat(contracts): deploy-time genesis buyback activation + venue select (#1084) - #1086

Merged
alpergundogdu merged 9 commits into
mainfrom
feat/genesis-buyback-activation
Jul 9, 2026
Merged

alpergundogdu merged 9 commits into
mainfrom
feat/genesis-buyback-activation

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1084.

What

Adds an OFF-by-default, venue-selectable path to activate the FeeRouter buyback bucket at genesis, in-script, before the governance handoff. DeployProtocol still ships the buyback bucket dormant (buybackBurner == address(0), split [9000, 0, 1000]) by default; the new ACTIVATE_BUYBACK=true flag opts into a coherent in-script activation bundle.

Normal activation is a governance FeeRouter.setSharesAndDestinations(...) through the 48h Timelock. At genesis that is unbootstrappable — served-bytes voting weight is zero (ADR 036) and the deploy leaves the deployer with no privileged role on exit — so activation runs while the deployer still holds GOVERNANCE_ROLE. This is genesis config, not new contract surface: no fallback logic, no sunset role, the same setSharesAndDestinations call, run pre-handoff.

How

  • BaseProtocolDeploy — new _runFullDeploy(cfg, act) overload taking a BuybackActivation struct. The legacy single-arg entry point delegates with activation off, so the dormant launch is byte-for-byte unchanged (existing suites untouched). When ON, after cross-contract wiring and before the handoff: seed the venue pool → deploy the concrete burner (admin = deployer) → grant PAUSER_ROLE to the emergency multisig → setKeeper → flip FeeRouter to [6000, 3000, 1000] → hand the burner to the Timelock alongside every other governed target. Symmetric back-door / wiring asserts extended to the burner.
    • Guards: keeper required (MissingBuybackKeeper); Uniswap pool must be seeded before wiring (PoolNotSeeded); deployer must hold the seed TOKEN+USDC (InsufficientSeedBalance).
  • Venue select (BUYBACK_VENUE):
    • Uniswap — creates + seeds a TOKEN/USDC V3 pool in-script (SwapRouter02 + NonfungiblePositionManager, full-range POL custodied by the Timelock). The only runnable venue on Arbitrum Sepolia.
    • Balancer — wires an already-seeded 80/20 pool (POL seeding is a treasury/Permit2 act per ADR 018 § POL mechanics, not reproduced by the genesis script).
  • DeployProtocol — ACTIVATE_BUYBACK / BUYBACK_VENUE + guard-param env plumbing (defaults from ADR 018 § Parameter Table); manifest records the wired burner + live split.
  • ActivateBuyback runbook generalized to dispatch on venue (Balancer path unchanged; Uniswap added).
  • ADRs — 018 (venue-neutral selection + deploy-time genesis activation, distinct from production Activation Criteria; Uniswap TWAP warmup note) and 016 (optional deploy-time activation step, dormant-by-default, venue-select).

Guardrails

Deploy-time genesis activation is a testnet/genesis convenience, documented as such in the ADRs and script comments. Mainnet leaves the flag OFF and keeps the ADR 018 governance-gated activation. The Uniswap burner's TWAP accumulator is fail-closed until it spans twapMinWindow (~1800s), so early buybacks revert TwapNotReady until the window matures.

Testing

  • test/GenesisBuybackActivation.t.sol (in-process, runs in default CI): OFF-path parity with the dormant launch, full ON Uniswap bundle (split/burner/keeper/pauser/seeded-pool/handoff), and the guard reverts.
  • test/GenesisBuybackActivation.fork.t.sol (gated on ARBITRUM_SEPOLIA_RPC_URL, self-skips offline): the real acceptance path against live Arbitrum Sepolia Uniswap V3 — pool created via the live factory + seeded, split flipped to [6000,3000,1000], burner wired, keeper set, roles handed to the Timelock, and the burner reads a real ~$0.01-anchor TWAP spot off the seeded pool. Verified passing against a public Arb Sepolia endpoint.

CI mirror run locally: forge fmt --check, FOUNDRY_PROFILE=ci forge build --sizes --deny warnings, forge test (709 passed / 9 fork-skipped) all green. slither/aderyn are unaffected — their scopes exclude script/+test/ and no src/ contract changed.

Notes / design decisions

  • Balancer deploy-flag path wires a pre-seeded pool rather than seeding it in-script — Balancer V3 isn't on Arbitrum Sepolia and POL seeding is a governance/treasury (Permit2) act per ADR 018, so pulling that flow into the production deploy script was avoided. The runnable, fork-tested genesis venue is Uniswap; the Balancer deploy-flag branch has its guard covered but no full-bundle fork test (the Balancer burner itself is covered by its existing suites, and the ActivateBuyback Balancer runbook is unchanged). Flag if you'd prefer full in-script Balancer seeding + an Ethereum-Sepolia fork test. [your call]

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added optional deploy-time “genesis buyback activation” (off by default) with deploy-time venue selection (Balancer V3 or Uniswap V3).
    • FeeRouter defaults to dormant buyback configuration; activation deploys and wires the correct guarded buyback burner and steady-state split.
  • Documentation
    • Updated ADRs and contract docs describing venue-neutral burner behavior and activation timing relative to initialization.
  • Bug Fixes
    • Improved manifest output to reflect the live buyback burner address and effective fee routing shares.
  • Tests
    • Added unit and fork acceptance coverage for both venues, including TWAP warmup/accuracy checks.
  • Chores
    • Refreshed gas snapshots and added Arbitrum Sepolia RPC support.

#1084)

Add an OFF-by-default, venue-selectable path to activate the FeeRouter buyback
bucket at genesis, in-script, before the governance handoff. At genesis the
normal governance activation is unbootstrappable — served-bytes voting weight is
zero (ADR 036) and the deploy leaves the deployer with no privileged role — so
activation has to run while the deployer still holds GOVERNANCE_ROLE. This is
genesis config, not new contract surface: the same setSharesAndDestinations call,
run pre-handoff.

- BaseProtocolDeploy: `_runFullDeploy(cfg, act)` overload with a BuybackActivation
  struct (OFF by default; the single-arg entry point delegates with activation
  off, so the dormant launch is byte-for-byte unchanged). When ON, seed the venue
  pool, deploy the concrete burner (admin=deployer), grant PAUSER to the multisig,
  setKeeper, flip FeeRouter to [6000,3000,1000], then hand the burner to the
  Timelock alongside every other target. Guards: keeper required; Uniswap pool
  must be seeded before wiring.
- Venue select via BUYBACK_VENUE. Uniswap creates + seeds a TOKEN/USDC V3 pool
  in-script (SwapRouter02 + NonfungiblePositionManager, full-range POL custodied
  by the Timelock) — the only runnable venue on Arbitrum Sepolia. Balancer wires
  an already-seeded 80/20 pool (POL seeding is a treasury/Permit2 act per ADR 018).
- DeployProtocol: ACTIVATE_BUYBACK / BUYBACK_VENUE env plumbing; manifest records
  the burner + live split.
- ActivateBuyback runbook generalized to dispatch on venue (balancer unchanged).
- Tests: in-process mock activation suite (OFF-path parity, full ON bundle, guard
  reverts) + gated Arbitrum Sepolia fork suite validating the real Uniswap path
  (pool created/seeded, split flipped, keeper set, roles handed off, TWAP prices).
- ADR 018 (venue-neutral selection + deploy-time genesis activation vs production
  criteria) and ADR 016 (optional deploy-time activation step, dormant-by-default).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 12:16
@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR documents and wires an off-by-default genesis buyback activation path, adds venue selection for Balancer V3 or Uniswap V3, updates deploy-time manifests and tests, and refreshes gas snapshots.

Changes

Genesis buyback activation

Layer / File(s) Summary
Docs and contract table
adr/016-contract-interactions.md, adr/018-liquidity-strategy.md, contracts/README.md, contracts/script/interfaces/IBalancerV3PoolCreation.sol
Documents dormant defaults, venue-neutral burner selection, optional genesis activation ordering, and off-chain pool-creation surface usage.
Fork RPC configuration
contracts/foundry.toml
Adds an arbitrum_sepolia RPC endpoint entry and matching comment block.
Venue-neutral activation script
contracts/script/ActivateBuyback.s.sol
Generalizes buyback deployment to select Balancer or Uniswap via BUYBACK_VENUE and emit the corresponding governance calldata.
Uniswap pool creation interface
contracts/script/interfaces/IUniswapV3PoolCreation.sol
Adds deploy-script interfaces for Uniswap factory lookup and position-manager pool creation/seeding.
Genesis activation orchestration
contracts/script/BaseProtocolDeploy.s.sol, contracts/script/DeployProtocol.s.sol
Adds activation types, venue-specific seeding/deployment, governance handoff coverage, activation parsing, and live burner/share manifest output.
Fork acceptance tests
contracts/test/GenesisBuybackActivation.fork.t.sol, contracts/test/GenesisBuybackActivationBalancer.fork.t.sol, contracts/test/BuybackBurnerBalancerV3.swapburn.fork.t.sol
Runs live fork flows for Uniswap and Balancer activation, checks role handoff and TWAP behavior, and updates the Balancer interface import path.
In-process activation tests
contracts/test/GenesisBuybackActivation.t.sol
Covers dormant and activated paths with mocks, plus guard reverts for missing setup conditions.
Gas snapshot refresh
contracts/.gas-snapshot
Updates gas records for existing suites and adds entries for the new fork and activation tests.

Estimated code review effort: 5 (Critical) | ~90 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DeployProtocol
  participant BaseProtocolDeploy
  participant Burner
  participant FeeRouter
  DeployProtocol->>BaseProtocolDeploy: _runFullDeploy(cfg, act)
  BaseProtocolDeploy->>Burner: create and seed venue pool
  BaseProtocolDeploy->>Burner: deploy guarded burner and set keeper
  BaseProtocolDeploy->>FeeRouter: setSharesAndDestinations(...)
Loading

Possibly related PRs

  • decdn/decdn#1003: Introduces the venue-neutral buyback burner architecture that this PR’s deploy-time activation flow wires and exercises.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: deploy-time buyback activation with venue selection.
Linked Issues check ✅ Passed The PR implements the off-by-default deploy-time activation flow, venue selection, ADR updates, and required tests described in #1084.
Out of Scope Changes check ✅ Passed The changes stay within the buyback activation and deployment plumbing scope; the snapshot, tests, and interfaces support the same feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/genesis-buyback-activation

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 88.71% (2452/2764 lines)
▼ -2.75pp vs base (91.47% → 88.71%)
Run: 29026615131

New GenesisBuybackActivation entries plus deterministic gas movement on the
deploy-invoking suites (Deployment struct gained a buybackBurner field and
_runFullDeploy gained the activation branch).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an optional deploy-time genesis activation mechanism for the buyback bucket, allowing testnets and genesis networks to seed a Uniswap V3 or Balancer V3 pool, deploy the concrete BuybackBurner, and configure the FeeRouter split before handing over governance to the Timelock. The feedback highlights an inconsistency in the default value of the BUYBACK_VENUE environment variable across different scripts, and recommends validating the computed sqrtPriceX96 against Uniswap V3's MIN_SQRT_RATIO and MAX_SQRT_RATIO boundaries to avoid opaque reverts during pool initialization.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread contracts/script/ActivateBuyback.s.sol Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an off-by-default, deploy-time “genesis buyback activation” path to the contracts deployment flow, allowing a new deployment to come up with the FeeRouter buyback bucket live before the governance handoff, with venue selection (Uniswap V3 or Balancer V3). It keeps the default behavior unchanged (buyback dormant) while enabling a coherent in-script activation bundle for testnet/genesis deployments, and documents the behavior in ADRs.

Changes:

  • Extend the deployment pipeline to optionally seed a venue pool, deploy the concrete buyback burner, set keeper/pauser, flip FeeRouter shares to [6000, 3000, 1000], and hand burner governance to the Timelock.
  • Add venue selection plumbing for deploy-time activation and generalize the ActivateBuyback runbook to support both venues.
  • Add in-process + fork-based tests for the Uniswap genesis activation path and update ADR/README/docs accordingly.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
contracts/test/GenesisBuybackActivation.t.sol Adds in-process tests (mock Uniswap pool/position manager) for OFF-path parity + ON-path activation bundle + guard reverts.
contracts/test/GenesisBuybackActivation.fork.t.sol Adds gated Arbitrum Sepolia fork acceptance tests against live Uniswap V3.
contracts/script/interfaces/IUniswapV3PoolCreation.sol Adds deploy-script-only Uniswap V3 pool creation + mint interfaces used for in-script seeding.
contracts/script/DeployProtocol.s.sol Reads ACTIVATE_BUYBACK / BUYBACK_VENUE env configuration, passes activation struct into deploy, and records live burner/split in the manifest.
contracts/script/BaseProtocolDeploy.s.sol Implements activation-aware deploy pipeline and the optional genesis buyback activation bundle (Uniswap pool create/seed or Balancer wire).
contracts/script/ActivateBuyback.s.sol Generalizes the post-deploy activation runbook to dispatch on BUYBACK_VENUE (Balancer or Uniswap).
contracts/README.md Updates BuybackBurner description to reflect venue-neutral design and ADR references.
contracts/foundry.toml Adds arbitrum_sepolia RPC endpoint entry for fork tests.
adr/018-liquidity-strategy.md Documents venue-neutral burner selection and deploy-time genesis activation option + TWAP warmup note.
adr/016-contract-interactions.md Documents dormant-by-default launch and optional deploy-time genesis activation in deployment/init sections.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
contracts/script/DeployProtocol.s.sol (1)

243-248: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Validate the Uniswap fee tier at read time for true fail-fast.

PoolFeeOutOfRange only rejects values above uint24; an in-range but unsupported tier (e.g. 2500) passes here and only reverts later via UnsupportedFeeTier inside _tickSpacing, mid-broadcast after Ed25519Verifier and all targets are already deployed. Since _readBuybackActivation runs before vm.startBroadcast, validating the supported set here aborts before any gas is spent, consistent with the fail-fast intent for the other activation inputs.

♻️ Validate supported tiers pre-broadcast
             uint256 fee = vm.envOr("UNISWAP_POOL_FEE", uint256(10_000));
-            if (fee > type(uint24).max) revert PoolFeeOutOfRange(fee);
+            if (fee != 100 && fee != 500 && fee != 3000 && fee != 10_000) {
+                revert PoolFeeOutOfRange(fee);
+            }
             act.uniPoolFee = uint24(fee);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/script/DeployProtocol.s.sol` around lines 243 - 248, The Uniswap
fee tier validation in _readBuybackActivation only checks uint24 bounds, so
unsupported in-range tiers can slip through and fail later during broadcast.
Update the UNISWAP branch in DeployProtocol.s.sol to validate the fee against
the supported Uniswap tiers before assigning act.uniPoolFee, using the existing
PoolFeeOutOfRange or a similar early-revert path so invalid values are rejected
before vm.startBroadcast and before any deployment work begins.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@adr/018-liquidity-strategy.md`:
- Around line 173-187: The deploy-time genesis activation flow currently mixes
Uniswap V3 and Balancer V3 into one “coherent bundle,” which obscures the actual
steps. Split the logic in this section so the deploy path clearly branches by
venue: describe Uniswap V3 as creating and seeding the pool in-script, and
Balancer V3 as requiring the pool to be seeded off-script before the deploy
script wires it. Update the numbered activation steps and surrounding prose in
the liquidity strategy doc to keep the venue-specific sequence explicit and
consistent.

In `@contracts/test/GenesisBuybackActivation.fork.t.sol`:
- Around line 30-34: The GenesisBuybackActivation.fork.t.sol test is using the
wrong USDC deployment for the fork environment. Update the USDC constant in
GenesisBuybackActivationTest to the Arbitrum Sepolia USDC address so the forked
CI test targets the correct token contract. Keep the other
router/factory/position manager constants unchanged.

---

Nitpick comments:
In `@contracts/script/DeployProtocol.s.sol`:
- Around line 243-248: The Uniswap fee tier validation in _readBuybackActivation
only checks uint24 bounds, so unsupported in-range tiers can slip through and
fail later during broadcast. Update the UNISWAP branch in DeployProtocol.s.sol
to validate the fee against the supported Uniswap tiers before assigning
act.uniPoolFee, using the existing PoolFeeOutOfRange or a similar early-revert
path so invalid values are rejected before vm.startBroadcast and before any
deployment work begins.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9669a7ea-4d1f-4658-b9d0-47db7fd4c1b7

📥 Commits

Reviewing files that changed from the base of the PR and between 5301864 and 43e9d9e.

📒 Files selected for processing (10)
  • adr/016-contract-interactions.md
  • adr/018-liquidity-strategy.md
  • contracts/README.md
  • contracts/foundry.toml
  • contracts/script/ActivateBuyback.s.sol
  • contracts/script/BaseProtocolDeploy.s.sol
  • contracts/script/DeployProtocol.s.sol
  • contracts/script/interfaces/IUniswapV3PoolCreation.sol
  • contracts/test/GenesisBuybackActivation.fork.t.sol
  • contracts/test/GenesisBuybackActivation.t.sol

Comment thread adr/018-liquidity-strategy.md Resolved
alpergundogdu and others added 3 commits July 9, 2026 13:29
…+ Eth Sepolia fork test

Make the deploy-time genesis activation genuinely venue-symmetric: the Balancer
branch now creates + seeds its 80/20 TOKEN/USDC weighted pool in-script (live
WeightedPoolFactory + Router via Permit2), exactly as the Uniswap branch seeds its
V3 pool, instead of requiring a pre-seeded pool address.

- BaseProtocolDeploy: `_createAndSeedBalancerPool` + `_permit2Approve` mirror the
  swap+burn fork test's pool-creation flow (sorted legs, 80/20 weights, Router
  initialize). `_activateBalancer` now creates+seeds then constructs the burner
  (its constructor validates the live pool = the seed-before-wire guard for this
  venue). Seed amounts are shared struct fields (`usdcSeed`/`tokenSeed`); `balPool`
  input dropped, `balFactory`/`balSwapFee` added.
- DeployProtocol: read BALANCER_WEIGHTED_POOL_FACTORY / BALANCER_SWAP_FEE; seed
  defaults are venue-appropriate (Uniswap 10k/1M, Balancer 250k/100M — same $0.01
  anchor, different weights).
- Relocate the Balancer pool-creation interface from test/interfaces to
  script/interfaces so the deploy script and the fork tests share one copy.
- Tests: GenesisBuybackActivationBalancer.fork.t.sol (gated on SEPOLIA_RPC_URL,
  self-skips offline) validates the full Balancer bundle against live Balancer V3
  on Ethereum Sepolia — verified passing against a public endpoint. The in-process
  balancer guard test is dropped (factory/vault/permit2 stack is impractical to
  mock; the keeper guard is venue-agnostic).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Both venues now create + seed the pool in-script (Uniswap via NFPM full-range,
Balancer via WeightedPoolFactory + Router/Permit2); update the deploy-time
genesis-activation step to match.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
- BaseProtocolDeploy: fail-fast on a seed price outside Uniswap V3's valid
  [MIN_SQRT_RATIO, MAX_SQRT_RATIO] band (was only checking uint160), so a skewed
  seed reverts with a clear SqrtPriceOutOfRange instead of an opaque revert inside
  the NonfungiblePositionManager.
- DeployProtocol: validate UNISWAP_POOL_FEE against the supported tier set at read
  time (pre-broadcast) rather than only bounding to uint24 and reverting
  UnsupportedFeeTier mid-deploy.
- ActivateBuyback: default BUYBACK_VENUE to `uniswap`, consistent with
  DeployProtocol (was `balancer`), to avoid cross-script default confusion.
- Drop an unused IEd25519Verifier import from the in-process activation test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
contracts/test/GenesisBuybackActivation.t.sol (1)

260-278: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Tighten guard-revert assertions with expectPartialRevert instead of bare expectRevert().

Both test_revertsWhenPoolNotSeeded and test_revertsWhenDeployerLacksSeedBalance fall back to unqualified vm.expectRevert() because the custom error's argument is runtime-computed. Foundry's expectPartialRevert(bytes4) cheatcode matches only the selector and ignores the rest of the revert data, so it can assert the specific error without needing the runtime pool address/amount, per Foundry's docs: "Use expectPartialRevert when you only care about the error selector, not its arguments". As written, a bare expectRevert() would also pass if the call reverted for an unrelated reason, weakening the guard test's precision.

🧪 Proposed fix
     function test_revertsWhenPoolNotSeeded() public {
         MockPositionManager npm = new MockPositionManager(false);
         usdc.approve(address(npm), type(uint256).max);
         BuybackActivation memory act = _uniswapActivation(address(npm));
-        vm.expectRevert(); // PoolNotSeeded(pool) — pool address is runtime-computed
+        vm.expectPartialRevert(BaseProtocolDeploy.PoolNotSeeded.selector);
         this.externalRunFullDeploy(_config(), act);
     }
         cfg.initialTokenHolder = address(0xBEEF);
-        vm.expectRevert(); // InsufficientSeedBalance(token, 0, TOKEN_SEED)
+        vm.expectPartialRevert(BaseProtocolDeploy.InsufficientSeedBalance.selector);
         this.externalRunFullDeploy(cfg, _uniswapActivation(address(npm)));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/test/GenesisBuybackActivation.t.sol` around lines 260 - 278, The
two guard tests are using unqualified revert checks, which makes them too broad;
update test_revertsWhenPoolNotSeeded and
test_revertsWhenDeployerLacksSeedBalance in GenesisBuybackActivation.t.sol to
assert the specific custom error selector with Foundry’s expectPartialRevert
instead of bare expectRevert. Keep the existing runtime-computed arguments out
of the assertion, but target the PoolNotSeeded and InsufficientSeedBalance
selectors so externalRunFullDeploy only passes on the intended guard failure.
contracts/script/DeployProtocol.s.sol (1)

305-319: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Manifest derives "live" shares from a duplicated constant set instead of on-chain state.

liveShares hardcodes STEADY_OPERATOR_SHARE/STEADY_BUYBACK_SHARE/STEADY_TREASURY_SHARE for the activated branch rather than reading d.router.getShares(). In that branch bb != address(0), which only happens after a real _activateBuyback call against a real FeeRouter (the stub-deployment concern mentioned in the comment only applies to the dormant path, where cfg.feeRouterShares is already used as the fallback). If these constants ever drift from the actual values _activateBuyback applies, the manifest would silently misreport the on-chain split to downstream tooling.

♻️ Proposed fix
         address bb = address(d.buybackBurner);
-        uint256[3] memory liveShares = bb == address(0)
-            ? cfg.feeRouterShares
-            : [STEADY_OPERATOR_SHARE, STEADY_BUYBACK_SHARE, STEADY_TREASURY_SHARE];
+        uint256[3] memory liveShares = bb == address(0) ? cfg.feeRouterShares : d.router.getShares();

Also applies to: 345-347

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@contracts/script/DeployProtocol.s.sol` around lines 305 - 319, The manifest
writer in _writeManifest is using duplicated steady-share constants for the
activated path, which can diverge from the real router state. Update the
liveShares derivation so the non-dormant branch reads the actual shares from
d.router.getShares() (or the canonical source used by _activateBuyback), while
keeping cfg.feeRouterShares only for the dormant bb == address(0) fallback. Keep
the serialization logic in _writeManifest consistent with the real FeeRouter
values and apply the same fix anywhere else in the diff that mirrors this
shares-writing logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@contracts/script/DeployProtocol.s.sol`:
- Around line 305-319: The manifest writer in _writeManifest is using duplicated
steady-share constants for the activated path, which can diverge from the real
router state. Update the liveShares derivation so the non-dormant branch reads
the actual shares from d.router.getShares() (or the canonical source used by
_activateBuyback), while keeping cfg.feeRouterShares only for the dormant bb ==
address(0) fallback. Keep the serialization logic in _writeManifest consistent
with the real FeeRouter values and apply the same fix anywhere else in the diff
that mirrors this shares-writing logic.

In `@contracts/test/GenesisBuybackActivation.t.sol`:
- Around line 260-278: The two guard tests are using unqualified revert checks,
which makes them too broad; update test_revertsWhenPoolNotSeeded and
test_revertsWhenDeployerLacksSeedBalance in GenesisBuybackActivation.t.sol to
assert the specific custom error selector with Foundry’s expectPartialRevert
instead of bare expectRevert. Keep the existing runtime-computed arguments out
of the assertion, but target the PoolNotSeeded and InsufficientSeedBalance
selectors so externalRunFullDeploy only passes on the intended guard failure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ab88df7c-8df7-4759-9a96-656ecf60e7a5

📥 Commits

Reviewing files that changed from the base of the PR and between addf2d5 and e1854da.

📒 Files selected for processing (9)
  • adr/018-liquidity-strategy.md
  • contracts/.gas-snapshot
  • contracts/script/BaseProtocolDeploy.s.sol
  • contracts/script/DeployProtocol.s.sol
  • contracts/script/interfaces/IBalancerV3PoolCreation.sol
  • contracts/test/BuybackBurnerBalancerV3.swapburn.fork.t.sol
  • contracts/test/GenesisBuybackActivation.fork.t.sol
  • contracts/test/GenesisBuybackActivation.t.sol
  • contracts/test/GenesisBuybackActivationBalancer.fork.t.sol
✅ Files skipped from review due to trivial changes (1)
  • contracts/script/interfaces/IBalancerV3PoolCreation.sol
🚧 Files skipped from review as they are similar to previous changes (3)
  • adr/018-liquidity-strategy.md
  • contracts/test/GenesisBuybackActivation.fork.t.sol
  • contracts/script/BaseProtocolDeploy.s.sol

alpergundogdu and others added 4 commits July 9, 2026 13:41
…re source

- DeployProtocol: read the activated FeeRouter split straight from
  `d.router.getShares()` instead of duplicating the STEADY_* constants, so the
  manifest can't silently misreport a drifted split. The dormant branch (the only
  one the stub-deployment script tests exercise) still falls back to the launch
  config, keeping the writer stub-safe.
- GenesisBuybackActivation test: assert the specific error selector via
  `expectPartialRevert` (PoolNotSeeded / InsufficientSeedBalance) instead of a bare
  `expectRevert()`, so the guard tests can't pass on an unrelated revert.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
`forge fmt` treats `new T[](n)` as atomic and won't wrap the combined
declaration+allocation of the long `IBalancerV3WeightedPoolFactory.TokenConfig[]`
array, leaving it at 121 chars, which trips solhint's 120-char rule (the documented
fmt-vs-solhint ±1 disagreement). Split the declaration from the allocation into two
statements so both tools agree.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Replace the hand-computed BUYBACK_TOKEN_SEED with a BUYBACK_TARGET_PRICE knob so an
operator supplies only the USDC they hold and the intended TOKEN price; the paired
TOKEN seed is derived to initialize the pool at that price. USDC decimals cancel in
the derivation, so it only scales by TOKEN's 18 decimals and the venue value-weights
(1:1 constant-product for Uniswap, 4:1 for the 80/20 Balancer pool).

- BaseProtocolDeploy: add `_deriveTokenSeed(venue, usdcSeed, targetPrice)` (pure) +
  BAL_TOKEN_WEIGHT/BAL_USDC_WEIGHT constants (now the single source of truth for both
  the derivation and the Balancer pool weights); TargetPriceZero guard.
- DeployProtocol: read BUYBACK_USDC_SEED (default lowered to 100e6) + BUYBACK_TARGET_PRICE
  (default 10_000 = $0.01/TOKEN in USDC base units); derive the TOKEN seed. Drops the
  venue-specific token/usdc seed defaults.
- Tests: 5 unit tests for _deriveTokenSeed (both venues, price scaling, small seed,
  zero-price revert); in-process + both fork suites now derive the seed via the helper
  (values unchanged at the $0.01 anchor, so the live-fork TWAP assertions still hold).
- ADR 018: note the seed is sized by a USDC amount + target price.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…t the deployer

The Balancer venue of genesis buyback activation seeded the pool via
Router.initialize, which mints the pool BPT (protocol-owned liquidity) to the
broadcasting deployer and left standing max Permit2 ERC20 approvals. The
deployer therefore retained the entire POL position plus dangling approvals
after the governance handoff — unlike the Uniswap path, which mints the
position NFT to the Timelock and resets its approvals. Move the BPT to the
Timelock and clear the Permit2 approvals in _finalizeBalancerSeed; extend the
Balancer fork test to assert the deployer holds no BPT/approval and the
Timelock custodies the BPT.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu merged commit 15ec8a3 into main Jul 9, 2026
23 checks passed
@alpergundogdu
alpergundogdu deleted the feat/genesis-buyback-activation branch July 9, 2026 14:49
thiras added a commit that referenced this pull request Jul 30, 2026
… follow-ups (#1090, #1175)

Closes #1090, Closes #1175.

Implements the ADR 009 bootstrap-multisig phase and clears the #1086 review's
buyback follow-ups. Both land on `contracts/script/`; no production contract in
`contracts/src/` changes.

**#1175 — bootstrap-multisig phase.** `DeployProtocol` run with `BOOTSTRAP_MULTISIG`
seats that multisig as the Timelock's sole PROPOSER/CANCELLER and grants
`DecdnGovernor` neither, so no operator vote reaches execution while the set is thin
enough for a cheap fleet to capture. The Timelock keeps GOVERNANCE_ROLE on every
target in both modes, so ADR 009's "48-hour timelock on every parameter change" holds
for the multisig too — the phase confines who may *schedule*, not who acts instantly.
`script/TransitionToGovernor.s.sol` prints the one-way batch that ends it. Off by
default: an unchanged deploy is byte-for-byte the previous one.

**#1090 — buyback follow-ups.** `script/lib/BuybackVenueLib.sol` is now the single
home for venue dispatch, burner construction, and wiring validation — previously
duplicated three ways, letting the genesis path and the runbook wire different
burners from the same inputs. `BuybackActivation` regroups into venue-scoped
sub-structs with cross-wire, under-wire, and seed-derivation guards. CI passes
`ARBITRUM_SEPOLIA_RPC_URL` through and now reports how many fork suites actually ran.

Also carries `ruint` 1.20.0 for RUSTSEC-2026-0220, which was blocking every commit
in the repo (`main` had the same lockfile).

Two rounds of multi-agent review; findings and rationale are in the PR thread.
Follow-up filed as #1532 (slippage ceiling + zero-band rejection in
`GuardedBuybackBurner`, which needs ADR 018 parameter decisions).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(contracts): deploy-time buyback activation with venue-select (Balancer/Uniswap) + ADR updates

2 participants