Drift Protocol v2

โŒ˜K
๐Ÿ‘พWelcome to Drift Protocol
๐ŸงฎDrift DEX
๐Ÿ‘‹Getting Started
๐Ÿ“ˆPerpetual Futures
๐Ÿ“ŠSpot Margin Trading
๐ŸฆBorrow & Lend
๐Ÿ›๏ธStaking
๐Ÿ”ฌTechnical Explanations
๐Ÿ“Accounting and Settlement
โž—Borrow Interest Rate
๐Ÿ“œDelisting Process
โ›ฒDrift AMM
๐ŸƒJust-In-Time (JIT) Auctions
๐Ÿ“šKeepers & Decentralised Orderbook
โ˜ ๏ธLiquidators
๐Ÿ’งLiquidity Providers (LPs)
๐Ÿ“‹Protocol Guard Rails
๐Ÿ“Risks
๐Ÿ–ฅ๏ธDeveloper Resources
๐Ÿ“”Overview
โŒจ๏ธSDK Documentation
โŒจ๏ธTutorial: Bots
โš ๏ธTroubleshooting
๐Ÿ› ๏ธKeeper Bots
๐Ÿ› ๏ธTrading Bots
โŒจ๏ธHistorical Data (v1)
โŒจ๏ธAPI
๐Ÿ›ก๏ธSecurity
๐Ÿ›ก๏ธAudits
๐Ÿ›ก๏ธBug Bounty
โš–๏ธLegal and Regulations
๐Ÿ“Terms of Use
๐Ÿ“Disclaimer
๐Ÿ“Privacy Policy
๐Ÿ“Competition Terms and Conditions
๐Ÿ“šGlossary
Docs powered byย archbeeย 
9min

Tutorial: JIT Maker Bot

Market orders go through the Just-In-Time (JIT) Auctions where Makers fight to fill orders before the order is allowed to fill against the Dynamic AMM (DAMM).

JIT Maker Bots maintain a local copy of the decentralised orderbook (DLOB) (see: Keepers & Decentralised Orderbook) in order to see which orders are in the auction phase and can be bid on.

Getting Started

โ˜ ๏ธ This bot requires collateral to run. This tutorial is a developer's guide and holds no responsibility over bot outcomes.

The reference implementation of the JIT Maker Bot is available here.

Follow the instructions at ๏ปฟ๏ปฟKeeper Bots to set the required environment variables, initialise theClearingHouseUser and deposit some collateral.

Start the JIT Maker Bot:

Shell
|

Technical Explanation

Streaming User Orders

The Typescript SDK exposes a EventSubscriber object that you can use to receive market orders on chain.

TypeScript
|

๏ปฟ

Bidding on JIT Auctions

Technical details on the JIT Auction and its pricing can be found Just-In-Time (JIT) Auctions. The reference implementation acts on each user order received and makes the order in the opposite direction at the auction end price with a random order size between 20 and MAX_TRADE_SIZE_QUOTE.

TypeScript
|

Determine how much longer the auction will last

It may be helpful to determine how much time is left in the order's auction in order to get the current dutch auction price:

TypeScript
|

Tracking Open Positions and Orders

The main ClearingHouse object from the SDK will update (polling or WebSocket) the user's account details behind the scenes. You can access the open orders and open positions of the user account by reading the positions and orders object of the ClearingHouseUser.

TypeScript
|
Updated 22 Nov 2022
Did this page help you?
Yes
No
UP NEXT
Historical Data (v1)
Docs powered byย archbeeย 
TABLE OF CONTENTS
Getting Started
Technical Explanation
Streaming User Orders
Bidding on JIT Auctions
Determine how much longer the auction will last
Tracking Open Positions and Orders