Drift Protocol v2

โŒ˜K
๐Ÿ‘พWelcome to Drift Protocol
๐Ÿ“บDrift DEX
๐Ÿ‘‹Getting Started
๐Ÿ“ˆPerpetual Futures
๐Ÿ“ŠSpot Margin Trading
๐ŸฆBorrow & Lend
๐Ÿ›๏ธStaking
๐ŸชMarket Makers
๐Ÿ”ฌ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
๐Ÿ“”Program/Vault Addresses
โŒจ๏ธ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
Sweepstakes Details
๐Ÿ“šGlossary
Docs powered by
Archbee
Technical Explanations

Just-In-Time (JIT) Auctions

8min

Introduction

The JIT Auction is a supplementary liquidity mechanism that allows Market Makers (MM) to provide 'Just-in-Time' liquidity.

When a user (Taker) submits a market order, this automatically triggers an individualized Dutch Auction with a specific start price, end price, and duration. The auction forces MMs to compete in order to fulfil the user at a price better than or equal to the current auction price. If no MM steps in after the initial window (~5 seconds), the user can be fulfilled on Drift's AMM.

Auction Price Bands

To maximise on-chain compute efficiency for Makers, the start and end prices within the auction are by default determined based on the oracle price and Drift AMM prices. Like in a regular Dutch auction, the price goes from best to worst (for the Taker, and thus worst to best for the Maker).

This process can be envisioned as a 'price band'; where the upper end of the price band is the worst price the Taker is willing to pay. At the start of the JIT auction (t=0), the price the MM can fill the user at is the price that is furthest away from the maximum price. The price approaches the maximum price as the auction approaches finality (t=5).

Document image
๏ปฟ

The Auction Lifecycle

  1. User submits a market taker order.
  2. The taker order is broadcasted to Drift's Keeper Network, which keeps track of all user orders.
  3. The taker order first routes through a Just-In-Time auction where market makers (MMs) can participate in a high-frequency Dutch auction to fill a userโ€™s orders.
  4. The JIT prices typically begin at the oracle price. Makers can bid to fill the desired position.
  5. Should there be no Makers participating in the JIT auction, or should there be any remaining size on the order, the order will be routed through to Driftโ€™s AMM, as an additional source of virtual liquidity.

How is the Auction Priced?

For a market buy order:

  • The auction by default starts at the oracle price.
  • The auction by default ends at the AMM's ask price

For a market sell order:

  • The auction will start at the oracle price.
  • The auction will end at the AMM's bid price.

๏ปฟ

Auction Start Price
Auction Current Price
Auction Ending Price
|
pub fn calculate_auction_end_price(
    market: &Market,
    direction: PositionDirection,
    base_asset_amount: u128,
) -> ClearingHouseResult<u128> {
    let swap_direction = match direction {
        PositionDirection::Long => SwapDirection::Remove,
        PositionDirection::Short => SwapDirection::Add,
    };

    let (_, _, quote_asset_amount, _) =
        calculate_base_swap_output_with_spread(&market.amm, base_asset_amount, swap_direction)?;

    let auction_end_price = calculate_entry_price(quote_asset_amount, base_asset_amount)?;

    Ok(auction_end_price)
}

๏ปฟ

How does this differ from a RFQ System?

Unlike an RFQ system where the Maker has to submit their own prices, the auction prices are already pre-determined based on Driftโ€™s AMM curves based on Drift's inventory-adjusted spreads as mentioned in Drift AMM๏ปฟ.

The price of the auction is on-chain and deterministic based on the time of the auction, while in an RFQ, the Maker can submit their own price at any point. As the 5-second auction goes on, the price becomes worse for the Takers and better for the Makers. As a result, Makers need to be as competitive as possible to provide price improvements to traders.

In an RFQ system, the user would receive quotes from Makers that they would have to choose to take or not, but in a JIT auction, the prices would already be predetermined by Driftโ€™s bid/ask curve and would give the user price improvement over Driftโ€™s AMM price.

Updated 21 Feb 2023
Did this page help you?
PREVIOUS
Optimisations
NEXT
Just-In-Time Auction FAQ
Docs powered by
Archbee
TABLE OF CONTENTS
Introduction
Auction Price Bands
The Auction Lifecycle
How is the Auction Priced?
How does this differ from a RFQ System?
Docs powered by
Archbee