Running a market
A market opened by anyone is run by the key that opened it. Three things have to keep happening.
1. The price
npm run solator -- price run <market> --from url:<http url> [--json a.b.c]
npm run solator -- price run <market> --from cmd:"<shell command that prints a number>"Every 3 seconds the loop reads your source. It posts when the price has moved by 1 basis point or when a third of the price's lifetime has passed, whichever comes first (--every, --min-move, --heartbeat change these).
| Market | Posts a day | SOL a day |
|---|---|---|
| A quiet price, good for 1 minute (a post every 40 s) | 2,160 | about 0.011 |
| A price that moves every 3 seconds | 28,800 | about 0.146 |
Each post is one transaction of about 5,060 lamports.
A move of more than 5% is held by the program until the next post confirms it. The loop's next turn is that post.
2. Settling filled orders
A resting order that is filled is booked into its owner's account when that account is next touched. Each turn, the loop does that for every account a fill is waiting for, so a maker sees the position without doing anything.
3. Liquidations
Each turn, the loop also looks at every account holding a position in your market and asks the program about those under their maintenance margin. The program judges each account itself; the loop sends only what it accepts.
- Under maintenance. A quarter of the position at a time is closed against the orders resting in the book: within 5% of the mark, then 10%, then 20%.
- Worth less than nothing. What is left is closed at the mark against the opposite positions with the largest gain for their size. The loss is paid from your market's bond first, then from those positions' gain on what was closed. Only what neither can pay is written down as the market's bad debt.
An account under maintenance that is still worth something waits when no order within 20% of the mark can take it, or when the only orders are so far away that filling them would lose more than the bond holds. The loop says so once and asks again every turn. In a thin book this is the usual case, and it is what the bond is sized for: see Bond and fees.
The same work is open to anyone, on anyone's market, with no key of the market:
npm run solator -- liquidate run <market> [--earn]With --earn, a fifth of each liquidation fee is paid to the sender's own trading account in that market (the account a first deposit there opens). The rest of the fee goes to the market's insurance. Nobody is obliged to run this: while your loop runs, your market is liquidated; when it does not, it is liquidated only if someone else chooses to.
Solator's own keeper watches every market of the program, yours included, and liquidates there too, keeping the sender's fifth of the fee. That is how the keeper is built today. It is not a service you can count on.
The brakes
npm run solator -- market pause <market>
npm run solator -- market resume <market>
npm run solator -- market cap <market> <dollars>Pausing stops new orders and deposits. Closing a position, cancelling and withdrawing keep working.
Looking
npm run solator -- market show <market>
npm run solator -- market list