Skip to content

fix(contracts): give Uniswap genesis-seed mint a deadline buffer - #1099

Merged
alpergundogdu merged 2 commits into
mainfrom
claude/interesting-pascal-ee98a4
Jul 11, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
claude/interesting-pascal-ee98a4

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The genesis buyback activation (#1084) seeds the Uniswap V3 TOKEN/USDC pool via NonfungiblePositionManager.mint, whose deadline was block.timestamp — zero margin. The NPM enforces block.timestamp <= deadline, so under forge script the deadline is encoded during the execution phase, but the tx mines a later block (on-chain simulation, then the real broadcast) whose timestamp is already past it → reverts Transaction too old.

On Arbitrum's sub-second blocks this is deterministic, so the #1083 Arbitrum Sepolia v0.1.0 deploy fails outright (and would waste gas on a live broadcast), not merely flake.

Fix

Use block.timestamp + 1 hours. The genesis seed has no slippage to guard — amount0Min/amount1Min are already 0 and the price is one we set — so a wide window is strictly safe.

Why tests didn't catch it

GenesisBuybackActivation.fork.t.sol runs in a single Foundry EVM at a fixed block.timestamp, so capture time equals execution time and the two-phase forge script timing gap never appears. This class of bug only surfaces under forge script, not forge test.

Verification

  • FOUNDRY_PROFILE=ci forge build --deny warnings — clean
  • forge test --match-contract GenesisBuybackActivation (non-fork) — 12/12 pass
  • Live dry run of DeployProtocol against Arbitrum Sepolia — previously reverted at the mint, now simulates to completion

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Increased the liquidity pool setup transaction deadline to one hour, reducing the likelihood of deployment failures caused by transaction timing.

The genesis buyback activation seeds the Uniswap V3 TOKEN/USDC pool with
`NonfungiblePositionManager.mint`, whose deadline was `block.timestamp`
(zero margin). The NPM enforces `block.timestamp <= deadline`, so under
`forge script` the deadline is encoded during the execution phase but the
tx mines a later block (on-chain simulation, then the real broadcast)
whose timestamp is already past it — reverting `Transaction too old`.
On Arbitrum's sub-second blocks this is deterministic, so the #1083
Arbitrum Sepolia deploy fails (and would waste gas on a live broadcast),
not just flake.

Use `block.timestamp + 1 hours`. The genesis seed has no slippage to
guard (`amount0Min`/`amount1Min` are already 0, price is one we set), so
a wide window is strictly safe.

The fork test can't catch this: it runs in a single Foundry EVM at a
fixed `block.timestamp`, so capture time equals execution time and the
two-phase `forge script` timing gap never appears. Verified instead by a
live dry run against Arbitrum Sepolia, which now simulates cleanly.

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

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alpergundogdu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 1814137b-859f-40da-896e-968c7f8794eb

📥 Commits

Reviewing files that changed from the base of the PR and between 23235de and 3c6fb63.

📒 Files selected for processing (1)
  • contracts/.gas-snapshot

Walkthrough

The deployment script changes the genesis Uniswap V3 pool mint deadline from block.timestamp to block.timestamp + 1 hours, leaving the remaining mint parameters unchanged.

Changes

Pool Mint Deadline

Layer / File(s) Summary
Extend genesis pool mint deadline
contracts/script/BaseProtocolDeploy.s.sol
The genesis pool liquidity mint now uses a deadline one hour after the current block timestamp.

Estimated code review effort: 1 (Trivial) | ~2 minutes


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

@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 updates the deployment script in BaseProtocolDeploy.s.sol to add a 1-hour buffer to the transaction deadline instead of using block.timestamp. This prevents 'Transaction too old' errors during forge script execution, where the transaction is mined in a later block than when it was simulated. There are no review comments, so we have no additional feedback to provide.

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.

@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 88.71% (2452/2764 lines)
▲ +0.00pp vs base (88.71% → 88.71%)
Run: 29149352231

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

Fixes a deterministic deployment revert when seeding the Uniswap V3 TOKEN/USDC pool during genesis buyback activation by ensuring the NonfungiblePositionManager.mint transaction has a non-zero deadline margin under forge script broadcast timing.

Changes:

  • Update Uniswap V3 position mint deadline from block.timestamp to block.timestamp + 1 hours.
  • Add an inline comment explaining why forge script makes a zero-margin deadline unsafe and why a wide window is acceptable for this seed.

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

The `block.timestamp + 1 hours` deadline arithmetic shifts deterministic
gas by ~78 units in three GenesisBuybackActivation tests. Regenerated via
`FOUNDRY_PROFILE=ci forge snapshot --snap .gas-snapshot`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu merged commit 5df6318 into main Jul 11, 2026
23 checks passed
@alpergundogdu
alpergundogdu deleted the claude/interesting-pascal-ee98a4 branch July 11, 2026 11:24
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.

2 participants