Order Gateway

Overview

The order gateway has two contracts

  • DelayedOrderGateway

  • orderGatewayV2 (used by front end and API)

DelayedOrderGateway is covered here; orderGatewayV2 is limited to use by the Perp v3 frontend and API (no external functions for direct contract interaction).

The order gateways have two key roles:

  1. Route orders to the optimal liquidity source

  2. Prevent trades from front-running the oracle using a 3 second delay

Workflow

  1. Call createOrder() to generate an order, including createdAt and executableAt timestamps

  2. Wait for executableAt() timestamp

  3. Call executeOrder() with orderId to execute a trade

  4. Call cancelOrder() with orderID to cancel an unexecuted order

Contract

Last updated

Was this helpful?