Skip to content

docs: move the JIT system guide to the solver crate - #21

Open
kayibal wants to merge 1 commit into
mainfrom
docs/jit-solver-readme
Open

docs: move the JIT system guide to the solver crate#21
kayibal wants to merge 1 commit into
mainfrom
docs/jit-solver-readme

Conversation

@kayibal

@kayibal kayibal commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

The JIT document lived at contracts/README.md as if the system were contracts only. Most of it
is now Rust, so it moves to where the crate lives and picks up references to the code.

What moved

contracts/README.md -> crates/fynd-jit-solver/README.md (559 lines), next to the code it
describes and alongside crates/intent-backrunner/README.md, the sibling mode's guide. The root
README's JIT link now points there.

What the new contracts README covers

A contracts reviewer's document, 155 lines, scoped to FyndJITRouter, RouteDictionary and
RouteDecompressor: the external surface (user entrypoints, storeRoute / storeBatch, the
views, the admin functions), the invariants that matter for review, the bit-stream layout, the
deploy script and its role grants, and the forge suites including the Base fork suite. No
economics and no architecture narrative; those live in one place now.

What was added about the Rust side

  • A module table for crates/fynd-jit-solver/src/{book,decode,engine,quoter,route_delta,gate,l1fee,compress,dictionary,decisions,state}.rs
    and one for crates/route-compressor/src/{codec,bitstream,segment,order,dictionary,contracts}.rs.
  • The five stages of a solve pass, with the function behind each.
  • The rules a reader cannot infer: the baseline is the order's own expectedAmountOut decoded
    from calldata, with no eth_call and no simulation of the original route; the surplus rule is
    the only emission rule; the same-route rule refuses a byte-identical-after-normalisation route
    as same_route, with same_pools_new_split flagged but still gated; the builder tip is
    charged in the gate because Fynd pays it; the L1 data fee is auto-detected via the OP-stack
    GasPriceOracle and is structurally zero without it; native tokens are quoted as the zero
    address while the router's convention is the 0xEeee… marker.
  • A "Running the solver" section with the flags main.rs defines, including the three whose
    environment variables are not named after the flag, and what a builder must supply.
  • The quote-trust limitation from quoter.rs, with --min-tvl as the operator's dial, kept
    alongside the existing counterfactual and compromised-key limits.

The economics section is preserved as rewritten in 1043b74: single-route framing, the four
break-even numbers, the FastLZ minimum-charge finding. The 2026-08-14 11:56 UTC prices were not
re-fetched, so the timestamp is unchanged.

Stale content fixed at this commit

  • crates/fynd-jit-solver and its anvil integration test are merged, so all "under review in
    PR feat: fynd-jit-solver solve loop, profitability gate, and emission #19" and "not on this branch" phrasing is gone.
  • The old text said the gate documents the L1 data fee as "routinely dominating". 2399ee2
    corrected that framing: L2 execution was about 274x the L1 term in the gate's own snapshot,
    and cheap blobspace is why.
  • The Rust suite is 256 passed / 3 ignored, not "102 passed, 2 ignored".
  • The old text claimed fixture regeneration leaves git status clean. It does not: the
    generator writes JSON keys in declaration order and the committed files are sorted, so all
    four fixtures come back modified with identical values.
  • Warm-cache forge test is 20 to 30 seconds, not 8, and the fork suite's RPC round trips are
    nearly all of it.

Verification

forge test from contracts/: 107 passed. cargo test --workspace: 256 passed, 3 ignored;
fixture churn dropped with git checkout -- contracts/. Every relative link resolves from its
file's directory and all 64 cited code symbols exist in the tree.

🤖 Generated with Claude Code

The JIT document lived under contracts/ as if the system were contracts
only, but most of it is now Rust: fynd-jit-solver holds the book, the
quoting, the profitability gate and the emission, and route-compressor
holds the codec, order keys, dictionary sync and calldata. Move it to
crates/fynd-jit-solver/README.md, next to the code it describes and
alongside crates/intent-backrunner/README.md, the sibling mode's guide.

contracts/README.md is now scoped to the three contracts: their external
surface, the invariants a reviewer needs, the deploy script, and the
forge suites, with a pointer to the solver crate for the system picture.

The moved document gains what a reader could not infer from the old text:
the five stages of a solve pass and the module behind each, the rules that
authorize an emission (the expectedAmountOut baseline with no simulation,
the surplus rule, the same-route refusal, the builder tip charged as a
cost, L1 fee auto-detection, native quoted as the zero address), and a
section on running the solver with the flags main.rs actually defines.

Corrections at this commit: fynd-jit-solver and its anvil test are merged,
so the PR #19 and unmerged-branch phrasing is gone; the gate no longer
claims the L1 data fee routinely dominates, which 2399ee2 corrected; the
Rust suite is 256 tests, not 102; and regenerating the fixtures does dirty
the tree, since the generator writes JSON keys in declaration order while
the committed files are sorted.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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