Skip to main content
Imperative trades, in contrast to Declarative trades, give traders precise control over the route plan at signature time.

How Imperative Trades Work

In an imperative trade, the app specifies the execution plan before the user signs the transaction. Here’s how it works:
  1. The app requests a order.
  2. The user signs and submits the order to a Solana RPC.
  3. Execution follows the specified path exactly.

When Imperative Trades Make Sense

Imperative trades are a good fit when an app needs:
  • To modify the swap transaction, which enables composability.
  • Deterministic execution paths.
  • Tight control over venue selection.
  • Predictable behavior for automation or compliance.
  • Integration with external systems that assume fixed routes.
Builders commonly use imperative trades for:
  • Strategy-driven or rules-based trading.
  • Research and testing.
  • Products where routing logic is part of the value proposition.

Code Recipes