MatchBook in nine minutes: transcript
The narration of the MatchBook video, as text. Chapters follow the video.
8 min 53 s · English narrationWatch the video
MatchBook runs on Solana devnet with test tokens. MBK/tUSD is a fictitious market whose price the bots set; it is not a real market. The program has not been audited yet.
0:00Introduction
Where does an order book live on Solana, how do orders reach it, and who pays for each trade? Take a look at this page. It's an order book: the list of who wants to buy, who wants to sell, and at what price. It never stops moving, but nobody is clicking: it's eight bots. Five act as market makers, and three simulate the clients, people and companies buying and selling as they need to. It's a sample market, MBK against tUSD, that QuantStratum has built on Solana to show what it can build.
And you can jump in and trade. You'll see where the book lives, how orders reach it, where everyone's money is kept, and who gets paid for what. MatchBook is open source and has just released version one point zero. One thing, though: it hasn't been audited yet, so with real money, only use what you can afford to lose.
0:58Where the book lives
Let's start with where it lives. MatchBook is a smart contract, what Solana calls a program: code that lives on the chain and keeps no data of its own, because data lives in accounts. Each market is a single data account, and everything goes inside it: the buy orders, the sell orders, and each trader's place in the market, which it calls a seat. The book you see on the page is literally the contents of that account. When it fills up, the account grows.
Today, the demo market takes up nine thousand two hundred bytes.
1:30How an order travels
So how does an order reach MatchBook? You press buy on the page, and your wallet signs a transaction that says, for example: buy one MBK at one hundred. The page sends it to an RPC node, the server that MatchBook's page, API and bots use to talk to Solana. The node passes it to the validator writing the current block, one of the computers that process the network's transactions. That validator runs MatchBook's code on the market account.
If nobody is selling at that price, your order stays in the book, waiting. If someone is, the trade happens right there, and both balances change in that same transaction. In some Solana order books, the seller gets paid later, when someone runs a separate step called a crank; in MatchBook, that step doesn't exist. And if anything fails, the market stays exactly as it was.
2:21Where every balance is kept
So where is everyone's money? Let's take it piece by piece. Your SOL sits in your own account, the one at your address. Other tokens, like MBK or tUSD, live in separate accounts, one per token, tied to your address. The market has two vaults, one per token, and the key belongs to the smart contract itself, not to a person. When you deposit, your tokens move into those vaults, and the market records it in your seat: how much is free and how much is locked in orders.
When you withdraw, they go back to your account; and only the seat's owner can withdraw. Place an order, and its amount moves from free to locked; cancel it, and it's free again. You can also trade without a seat, with a swap: tokens leave and arrive straight in your token accounts.
3:11How the bots trade
And the bots? They're programs running on a server off the chain, and each one has its own wallet: its private key is in a file on that server. The five market makers use models from market-maker-rs, an open source library: Avellaneda-Stoikov, GLFT, an adaptive spread and a grid. Their balances aren't on the server, but on Solana: the SOL for fees in their wallet, and their tokens in their seat inside the market. Facing them are the other three, simulating the clients: people and companies buying or selling as they need to, some all at once at market, some following the trend, and some with orders at their own price.
The first two keep their tokens in their own token accounts and trade with swaps; the third has a seat, like the makers. Every few seconds, a market maker reads its seat on the chain, and that's its inventory: how many MBK and tUSD it holds. From that, it works out and places a ladder of orders on each side, renewing it in one go. It started with four hundred MBK; if it builds up more, it lowers its prices to sell, and past its limit, it stops buying.
That starting money comes from an admin wallet, and every ninety seconds a treasurer tops up whoever is running low. In production, each market maker would bring its own capital, and could trade with a limited key that trades but never withdraws.
4:38Your wallet
So how do you get in? You install a Solana wallet in your browser, like Phantom or Solflare, switch it to devnet, and connect it. The page's faucet sends you twenty-five MBK, two thousand five hundred tUSD and, if you're short, a little SOL for fees. You can buy or sell instantly with a swap, or set your own price with a limit order; the first time, that same transaction opens your seat and deposits your tokens. Then you can cancel, or withdraw everything back to your wallet.
Every step asks you to sign, and your private key never leaves your wallet. And through code there's more, like stops, or orders that re-post themselves.
5:17Why it costs SOL
So why does all this cost SOL? Because in MatchBook, everything you do is a transaction signed by your wallet: depositing, placing an order, cancelling it, a swap or a withdrawal. And every transaction pays the validator that runs MatchBook's code: five thousand lamports per signature, five millionths of a SOL. Half is burned and half goes to the validator; MatchBook keeps none of it. Your order also takes up a cell in the market account.
If none are free, the account grows, and whoever makes it grow leaves a deposit for that space, what Solana calls rent: less than half a thousandth of a SOL per cell. The first time, you also need your MBK and tUSD accounts, each with its own deposit, which the faucet pays for in the demo; that's why it sends you a little SOL. When the network is busy, you can add a priority fee, charged by compute, and that's where MatchBook spends little: about one thousand three hundred units per order, while other order books use between one thousand nine hundred and eighteen thousand.
For whoever runs MatchBook, the costs are deploying the smart contract, about one and a half SOL, the market's deposit, and the bots' transactions, since they renew their orders every few seconds: between half a SOL and one SOL a day. And separately there's the market's own fee, paid not in SOL but in tUSD: whoever takes liquidity pays zero point one percent; a fifth goes to the market maker and the rest to the market's owner.
6:47What it takes to run it
So what does it take to keep it running? On the chain, just two things: the smart contract and the market account. Off the chain, a few containers with the page, an API and the bots, which read and write to the market through an RPC node; with eight bots, devnet's public RPC falls short, and a paid one is the better choice. The API watches the market account and forwards it to every browser, and it stores the trades to draw the chart.
The page only shows the book: the real book lives on the chain.
7:18Who it is for
So who needs it? An exchange or a trading app that wants its own markets, or a project that wants an order book for its token. An aggregator, which looks for the best price across markets and can compute it exactly here, because the developer kit runs the same engine as the chain. A market making firm, for which renewing orders is cheap. Or a wallet, which can offer swaps to its users. And around it you can build trading interfaces, strategies that run themselves, stop-losses with no servers watching, or analytics dashboards.
And if you want to build something like this, QuantStratum can help, because we built everything you've seen on top of MatchBook: the market, the five market makers and their models, the simulated clients, the treasurer, the API and the live page, and its deployment. To sum up: MatchBook's order book is a Solana account, and the matching, a smart contract. Every action is a transaction you pay for in SOL to the validator, plus a deposit if you take up new space.
Your order travels, signed, to a validator, and settles in that same transaction. Your tokens sit in your accounts or, if you deposit, in the market's vaults, recorded in your seat; just like the bots'. Go to matchbook dot quantstratum dot com, connect your wallet on devnet, and try it. And if you want your own, we know every piece, from the market account to the last bot. Tell us about your project at quantstratum dot com.