Declarative Swaps allow Solana users to trade tokens with less slippage, lower latency, and better pricing. Using Declarative Swaps through DFlow Swap API is simple. DFlow Swap API aggregates liquidity from all the major Solana DEXs and offers an API for trading any SPL token.

This quickstart assumes familiarity with Solana’s transaction and network connection logic. If unfamiliar, please refer to the Solana Cookbook.

1

Request a Quote

DFlow Swap API returns a quote specific to the token pair, amount, slippage tolerance, platform fee, segmenter fee, and other parameters.

A route is calculated for the swap at this step, but not hardened into the transaction. Instead, the quote is committed, and the route plan will be recalculated at the time the intent is submitted.

2

Sign the Intent

Signing the intent guarantees the minimum amount of output tokens, but does not commit to any given route plan to achieve the minimum amount of output tokens.

3

Submit the Intent

Intents are submitted to the DFlow Aggregator, which optimizes the execution of the swap based on network conditions.

4

Monitor the Intent

After submitting the Intent, you can monitor its status using the monitorOrder helper function from the @dflow-protocol/swap-api-utils package.

Declarative Swaps Declarative Swaps