/order endpoint enables trading from any spot token to a prediction market outcome token, including market tokenization when needed.
Trading Flow Overview
When you want to trade a spot token for a prediction market outcome token, the/order endpoint orchestrates the entire transaction flow behind the scenes. The endpoint automatically:
- Detects whether the target market has been tokenized (initialized)
- Executes a two-step swap path: Input Token → Settlement Mint → Outcome Token
- Handles market tokenization if the market hasn’t been initialized yet
The
/order endpoint accepts any spot token as inputMint and any outcome
token mint as outputMint. The endpoint automatically constructs the
appropriate transaction path based on the market’s initialization status.Transaction Flow
All trades from spot tokens to outcome tokens follow a two-step swap path that route through the settlement mint as an intermediate step:- Input Token → Settlement Mint
- Settlement Mint → Outcome Token
/order endpoint returns a single transaction that executes both swaps.
Market Initialization States
The/order endpoint automatically detects whether the target market has been tokenized and handles the transaction accordingly:
Initialized Markets
When a market has already been tokenized, the transaction executes the two-step swap path directly: Input Token → Settlement Mint → Outcome TokenUninitialized Markets
When a market hasn’t been tokenized yet, the/order endpoint automatically includes market tokenization in the transaction before executing the swap:
Market Tokenization + (Input Token → Settlement Mint → Outcome Token)
The transaction will:
- First perform on-demand market tokenization (creating the YES and NO outcome tokens on-chain)
- Then execute the two-step swap: Input Token → Settlement Mint → Outcome Token
On-demand market creation (tokenization) incurs a small fee. This fee is
automatically included in the transaction when trading into an uninitialized
market.
Checking Market Status
You can check a market’s initialization status using the Prediction Market Metadata API. TheisInitialized field in the market response indicates whether the market has been tokenized:
isInitialized: true- Market is already tokenized; direct swap pathisInitialized: false- Market needs tokenization; transaction will include initialization
/order endpoint handles the detection automatically, so you don’t need to check beforehand.
Key Takeaways
- The
/orderendpoint accepts any spot token as input and any outcome token as output - All trades execute through the settlement mint as an intermediate step: Input Token → Settlement Mint → Outcome Token
- For initialized markets, the transaction executes the swap path directly
- For uninitialized markets, the transaction includes market tokenization before executing the swap path
- On-demand market creation (tokenization) incurs a small fee
- The endpoint automatically detects market initialization status and constructs the appropriate transaction
- You can check
isInitializedvia the metadata API
Related Resources
Order Endpoint Reference
Complete API reference for the
/order endpoint, including all parameters
and response formatsTrade Tokens Quickstart
Learn how to use the DFlow Trade API to execute trades programmatically
Markets API Reference
Query market data including initialization status and outcome token
addresses
Discover Prediction Tokens
Learn how to find markets and access outcome token mint addresses for
trading