docs: document the onchain CLOB and how to run it on Monad - #3
Merged
Conversation
Replace the stock Scaffold-ETH 2 README with documentation for the order book in packages/foundry/contracts/CLOB.sol: how bids and asks rest in the two price-sorted linked lists, how placeOrder matches at the resting price and settles each fill, how cancelOrder unlinks and refunds, the public functions, events and custom errors, known limitations, and Foundry build/test/deploy steps for Monad (chain id 143, https://rpc.monad.xyz) and Monad testnet. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
scripts-js/parseArgs.js never reads ETH_KEYSTORE_ACCOUNT; on a live network it either uses --keystore or opens an interactive picker. Tell readers to pass --keystore so unattended deploys do not stall. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The README shipped the stock Scaffold-ETH 2 boilerplate and said nothing about the order book. This replaces it with documentation written from
packages/foundry/contracts/CLOB.sol, the tests, and the deploy script.What the new README covers:
bidHead/askHead), immediate ERC20 settlement per fill. Framed as a workshop/reference implementation, not an audited DEX.placeOrderpulls the locked token, walks the opposite list while the price crosses, fills at the resting order's price, unlinks fully filled orders, and rests the remainder via_insertOrder(price-time priority).cancelOrderwalks the list, unlinks, refunds the stored remainder.testSellMatchBidpins (10 token0 bid at price 2, 3 token1 ask: seller gets 6 token0, bid remainder reads 7),OrderMatchedemitting0for both order ids, linear list walks, rounding, the openmint()on the mock tokens, and the hardcoded mint recipient in the deploy script.castexamples, and Monad network details (mainnet chain id 143,https://rpc.monad.xyz; testnet 10143,https://testnet-rpc.monad.xyz). Mainnet is not infoundry.tomlyet, so the README says to add it; this PR does not touch config.Verification
forge buildandforge teston this branch: 5 tests pass.yarn deploy --network/--keystoreflags and the live-network default-key guard checked againstscripts-js/parseArgs.js.token0) checked againstcomponents/trade/TradeForm.tsx.🤖 Generated with Claude Code
Greptile Summary
The PR replaces the Scaffold-ETH boilerplate README with detailed CLOB architecture, limitations, setup, and Monad deployment documentation. The follow-up corrects the environment-variable guidance, but the replacement keystore command remains inconsistent with the live deployment wrapper.
castworkflows.ETH_KEYSTORE_ACCOUNTguidance with explicit--keystoreusage.Confidence Score: 4/5
The PR is not yet safe to merge because its documented live deployment command may ignore the funded keystore and use a different Forge sender or fail.
The README directs users to select a live deployment account with
--keystore, but the wrapper only stores that selection in an environment variable and invokes Forge without an account argument, so the documented deployment path does not reliably use the selected signer.Files Needing Attention: README.md and packages/foundry/Makefile
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR A["yarn deploy --network monad --keystore name"] --> B["parseArgs validates name"] B --> C["Sets ETH_KEYSTORE_ACCOUNT"] C --> D["Makefile invokes forge script"] D --> E["Forge selects broadcaster without --account"] E --> F["Deployment may use the wrong sender or fail"]Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "docs: correct keystore selection instruc..." | Re-trigger Greptile