Search
⌃K
🤖

Perps Market Making Bot

Show quotes on both sides of the orderbook to profit from trading activity
We've open-sourced an example market-maker bot. The bot provides liquidity to Zeta DEX by issuing bid & ask quotes per asset and instrument. It monitors mark prices from an external exchange via web sockets, and monitors quote orders via both web sockets and periodic refreshes.
Makers pay no fees on Zeta DEX (excluding SOL transaction fees), so go crazy!
If things are going well and you want to scale it up, reach out to us about our Market Maker Rewards program.

Setup

Ensure makerWallet.json file exists in project root dir, in format:
[
111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111,
111, 111, 111, 111
]
Install dependencies and start:
npm i
ts-node src/app.ts

System overview

Market-maker bot example

Modules

  • app.ts - Entrypoint with stale price check
  • maker.ts - Listens to external exchange (Bybit) orderbooks for mark price, monitors Zeta order updates, maintains current state
  • state.ts - Keeps mark prices (theos) and issued quotes
  • types.ts - Defines common types
  • utils.ts & math.ts - Mathematical and utility functions
  • configuration.ts - Parametrizes quoting strategy as per config.json

Configuration

Parameters specified in config.json
  • Exchange/connection params
    • network - Network on which the Zeta DEX program is deployed
    • programId - Zeta DEX programId
    • endpoint - RPC node url
    • markExchange - Which exchange to source mark prices from
  • Time-based params
    • requoteIntervalMs - Frequency of Zeta quote periodic refresh
    • markPriceStaleIntervalMs - Frequency of the stale price check, breach of which results in program exit
  • Asset params
    • quoteLotSize - Lot sizes for the given instrument
    • widthBps - Defines the spread between bid & ask
    • requoteBps - Defines the margin which once breached triggers re-quoting
    • Instrument params
      • marketIndex - Instrument index (137 for PERP, 22 & 45 for Futures)
      • quoteCashDelta - Cash amount offered on bid & ask