Skip to content

Add ST0x order quote2 Base fork test#2628

Open
Siddharth2207 wants to merge 1 commit into
mainfrom
add-st0x-quote-fork-test
Open

Add ST0x order quote2 Base fork test#2628
Siddharth2207 wants to merge 1 commit into
mainfrom
add-st0x-quote-fork-test

Conversation

@Siddharth2207

@Siddharth2207 Siddharth2207 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds test/concrete/ob/OrderBookV6.quote.fork.t.sol, a fork test that quotes a live ST0x order on Base via quote2 with pinned orderBytes, oracle signed context, block number, and orderbook address.

How to run

export BASE_MAINNET_RPC_URL=<your-base-rpc>
forge test --match-contract OrderBookV6QuoteForkTest -vvvv

Pinned constants in the test (update when reproducing a different order):

  • Orderbook: 0xe522cB4a5fCb2eb31a52Ff41a4653d85A4fd7C9D
  • Fork block: 46815818
  • Order hash: 0x4a051ad4567935a5a0570b3e2e77714c44405bb58e5b83e3cc484de1cee0747e

Oracle signed context and signature are embedded in the test; refresh from the ST0x API/subgraph when they expire.

Test plan

  • BASE_MAINNET_RPC_URL set to a Base mainnet RPC
  • forge test --match-contract OrderBookV6QuoteForkTest -vvvv passes and logs oracle + quote values

Made with Cursor

Summary by CodeRabbit

Tests

  • Added fork test coverage for OrderBook quote functionality on Base mainnet, validating order processing and quoting behavior.

Provides a self-contained fork test with pinned order bytes, oracle signed context, and block number so others can run quote2 against the live ST0x orderbook on Base.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A new Foundry fork test validates the quote2 function of the OrderBookV6 contract against live Base mainnet state. The test decodes a hardcoded order, derives oracle context from signed values, constructs a quote request, and asserts successful execution on the deployed orderbook.

Changes

OrderBookV6 Quote Function Fork Test

Layer / File(s) Summary
Fork test contract setup and constants
test/concrete/ob/OrderBookV6.quote.fork.t.sol
Contract pragma, imports, and hardcoded constants including the orderbook address, expected order hash, fork block number, and encoded ORDER_BYTES payload used to reconstruct the test order.
Fork initialization
test/concrete/ob/OrderBookV6.quote.fork.t.sol
setUp() creates a fork using the Base mainnet RPC endpoint and rolls execution to the specified FORK_BLOCK.
Quote test execution with live orderbook
test/concrete/ob/OrderBookV6.quote.fork.t.sol
testQuoteSt0xSplgUsdcOrder() decodes the order, validates its hash, constructs SignedContextV1[] with oracle version/price/publish time, builds a QuoteV2 request, calls quote2 on the live orderbook, logs results, and asserts success.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

A fork to the Base, where orders dance free,
We call quote2 and log what we see,
Oracle prices from context extracted with care,
One order, one test, one truth to declare. 🐰✨

🚥 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 PR title accurately describes the main change—adding a fork test for ST0x order quote2 functionality on Base mainnet, which is the primary focus of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-st0x-quote-fork-test
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch add-st0x-quote-fork-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
test/concrete/ob/OrderBookV6.quote.fork.t.sol (2)

30-34: 💤 Low value

Reconsider the public RPC fallback and combine fork creation with the block.

rollFork(FORK_BLOCK) to historical block 46_815_818 requires archive-node access. The default https://mainnet.base.org public endpoint is unlikely to serve archive data reliably and will produce confusing failures, while the PR instructions state BASE_MAINNET_RPC_URL must be set. Failing fast when the env var is missing makes the contract explicit. You can also create the fork directly at the pinned block.

♻️ Proposed change
     function setUp() public {
-        string memory rpc = vm.envOr("BASE_MAINNET_RPC_URL", string("https://mainnet.base.org"));
-        vm.createSelectFork(rpc);
-        vm.rollFork(FORK_BLOCK);
+        string memory rpc = vm.envString("BASE_MAINNET_RPC_URL");
+        vm.createSelectFork(rpc, FORK_BLOCK);
     }
🤖 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 `@test/concrete/ob/OrderBookV6.quote.fork.t.sol` around lines 30 - 34, Change
setUp() to require BASE_MAINNET_RPC_URL from the environment (fail fast if
missing instead of using the public https://mainnet.base.org fallback), and
create the fork at the pinned block in one call rather than calling
vm.rollFork(FORK_BLOCK); specifically, stop using vm.envOr(...) with a public
default, read the env var directly and revert if empty, and call
vm.createSelectFork(rpc, FORK_BLOCK) (replacing the separate vm.createSelectFork
+ vm.rollFork pattern) so the fork is created at FORK_BLOCK and avoids relying
on archive access from a public RPC.

74-76: ⚡ Quick win

Re-enable the output assertions or document why they're disabled.

The test currently asserts only success, but quote2 can return success == true with a zero maxOutput/ioRatio, so this leaves the test asserting little about the actual quote. The commented-out checks at Lines 75-76 are exactly what makes the result meaningful. Please enable them, or if they intentionally cannot hold for this pinned order/context, leave a comment explaining why rather than leaving dead assertions.

💚 Proposed change
         assertTrue(success, "quote2");
-        // assertFalse(maxOutput.isZero(), "max output");
-        // assertFalse(ioRatio.isZero(), "io ratio");
+        assertFalse(maxOutput.isZero(), "max output");
+        assertFalse(ioRatio.isZero(), "io ratio");
🤖 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 `@test/concrete/ob/OrderBookV6.quote.fork.t.sol` around lines 74 - 76, The test
currently only asserts success for the quote call (assertTrue(success,
"quote2")) while the meaningful checks for non-zero outputs
(assertFalse(maxOutput.isZero(), "max output") and assertFalse(ioRatio.isZero(),
"io ratio")) are commented out; either re-enable those two assertions in the
same test (restoring assertFalse(maxOutput.isZero(), "max output") and
assertFalse(ioRatio.isZero(), "io ratio")) so the quote result is validated, or
if zero outputs are valid for this pinned order/context, leave the assertions
commented and add a short inline comment referencing the reason (e.g., “zero
output expected for pinned orders because ...”) adjacent to the assert lines;
locate the checks around the assertTrue(success, "quote2") in
test/concrete/ob/OrderBookV6.quote.fork.t.sol to apply the change.
🤖 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 `@test/concrete/ob/OrderBookV6.quote.fork.t.sol`:
- Around line 30-34: Change setUp() to require BASE_MAINNET_RPC_URL from the
environment (fail fast if missing instead of using the public
https://mainnet.base.org fallback), and create the fork at the pinned block in
one call rather than calling vm.rollFork(FORK_BLOCK); specifically, stop using
vm.envOr(...) with a public default, read the env var directly and revert if
empty, and call vm.createSelectFork(rpc, FORK_BLOCK) (replacing the separate
vm.createSelectFork + vm.rollFork pattern) so the fork is created at FORK_BLOCK
and avoids relying on archive access from a public RPC.
- Around line 74-76: The test currently only asserts success for the quote call
(assertTrue(success, "quote2")) while the meaningful checks for non-zero outputs
(assertFalse(maxOutput.isZero(), "max output") and assertFalse(ioRatio.isZero(),
"io ratio")) are commented out; either re-enable those two assertions in the
same test (restoring assertFalse(maxOutput.isZero(), "max output") and
assertFalse(ioRatio.isZero(), "io ratio")) so the quote result is validated, or
if zero outputs are valid for this pinned order/context, leave the assertions
commented and add a short inline comment referencing the reason (e.g., “zero
output expected for pinned orders because ...”) adjacent to the assert lines;
locate the checks around the assertTrue(success, "quote2") in
test/concrete/ob/OrderBookV6.quote.fork.t.sol to apply the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f3e33bd-977d-4b7f-ae6f-3b4f0ed1bc4d

📥 Commits

Reviewing files that changed from the base of the PR and between 58a738a and e9cade3.

📒 Files selected for processing (1)
  • test/concrete/ob/OrderBookV6.quote.fork.t.sol

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.

1 participant