Overview
The Swift order subscriber enables market makers to receive real-time off-chain order authorizations from takers. Swift orders are signed messages that can be placed and filled by any willing counter-party within specified time-price bounds.subscribe_swift_orders
client- Drift client instancemarkets- List of perp markets to listen on for new Swift ordersaccept_sanitized- Set to true to receive sanitized order flow (default: false)accept_deposit_trades- Set to true to receive deposit+trade order flow (default: false)swift_ws_override- Optional custom Swift WebSocket endpoint
SwiftOrderStream- Stream of new Swift order messages
Important Notes
Sanitized Orders: A sanitized order may have its auction parameters modified by the program when placed onchain. Market makers should understand the time/price implications before accepting these orders. Deposit+Trade Orders: These orders require fillers to send an attached, preceding deposit transaction before the Swift order transaction.SignedOrderInfo
Represents a Swift order with metadata received from the WebSocket.ts- Order creation timestamp (unix milliseconds)taker_authority- The taker’s authority public keysigner- The authority pubkey that verifies the signature (taker authority or delegate)signature- Signature over the serialized order payloadwill_sanitize- True if order params are likely to be sanitized by the programpre_deposit- Taker signed pre-deposit transaction (for deposit+trade orders)
Methods
slot
order_uuid_str
order_uuid
order_params
taker_subaccount
encode_for_signing
to_ix_data
using_delegate_signing
has_builder
has_isolated_position_deposit
isolated_position_deposit
Constructors
authority
SignedOrderInfo for an authority-signed order.
delegated
SignedOrderInfo for a delegate-signed order.
SignedOrderType
Enum representing either authority-signed or delegate-signed Swift orders.Methods
is_delegated
to_borsh
info
Message Types
SignedOrder (Authority)
Swift order signed by the taker’s authority keypair.SignedDelegateOrder
Swift order signed by an authorized delegate keypair.Constants
Message Discriminators
WebSocket Endpoints
SwiftOrderStream
Stream trait from futures.
Example:
Authentication Flow
The Swift WebSocket connection automatically handles:- Challenge-Response Authentication: Signs a server-provided nonce with the maker’s wallet
- Market Subscription: Subscribes to specified perp markets after authentication
- Heartbeat Handling: Maintains connection with periodic heartbeat messages