Repository navigation
Conversation
Cross-margin perps with one collateral: a price-time order book per market, an admin-pushed oracle and funding index, admin-attested deposits, and liquidations the server submits after every accepted batch. TYPEWRITER_GAPS.md records where Typewriter forced those choices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…quote interval Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Adds
apps/perps: a cross-margin perpetuals exchange with one collateral. It has a FIFO price-time order book per market, an oracle and funding index the admin pushes, deposits the admin attests, and an inline liquidator in the API server. There's no frontend yet.Mutations (11):
SetAdmin,AddMarket,UpdateMarket,SetOraclePrices,AccrueFunding,Deposit,Liquidateare admin-only.CancelOrder,LimitOrder(post-only),MarketOrder(fill-or-kill),Withdrawalare for users. The model and API are inapps/perps/README.md.Typewriter gaps:
apps/perps/TYPEWRITER_GAPS.md. The biggest one: liquidations can only land in the batch after the price move.Verification
forge test: 15 tests (matching priority, PnL and value conservation, funding, margin, reduce-only, self-trade, liquidation, bad debt).tscand biome are clean.forge fmt --checkis clean.forge lintgives warnings only, as order-book does.bun devboots: the parser and determinism check pass, then the admin claims the seat, markets are listed, and the maker, oracle, and funding loops start.scripts/liquidation.tsagainst the dev server: a ~9.3x BTC long, then an 8% oracle drop. The liquidator closed all 1203 lots in the next batch.Deposit/SetAdmin(NotAdmin), a crossing limit order (WouldCross), withdrawing too much (InsufficientCollateral), and withdrawing while an order rests (InsufficientMargin). Cancel followed by a full withdrawal succeeded.🤖 Generated with Claude Code