Skip to main content
This guide provides a step-by-step example of how to execute a swap using the Fireblocks Trading API via direct access providers, such as Uniswap. A swap is the process of exchanging one cryptocurrency for another on the same network. The guide demonstrates swapping ETH for USDC on Ethereum using Uniswap as the direct access provider.

Prerequisites

Before you begin, ensure you have completed the prerequisites outlined in the Trading API Overview:
  • βœ… Fireblocks API credentials configured
  • βœ… Vault accounts with sufficient assets
  • βœ… Fireblocks TypeScript SDK installed (@fireblocks/[emailΒ protected])

SDK Setup

First, set up your Fireblocks SDK client:

Swap Flow Overview

The following steps outline the process for executing a swap via direct access providers:

Step 1: List Available Providers

Before trading, retrieve the list of available providers and use the response to identify the id of your desired provider.

API Call

Response Example

Key Fields Explained

Direct access providers may require one-time Terms of Service approval. The fields hasTermsOfService and approved indicate whether approval is required and whether your workspace already approved it. Approval must be done once per workspace via the Fireblocks Console.

For more details about this endpoint, see the Get Providers API Reference.

Step 2: Approve Terms of Service (Direct Access Providers Only)

Direct access providers require one-time Terms of Service approval before trading. Approval must be done in the Fireblocks Console (not available via SDK).

Check Approval Status

Clarification on how to translating user intent into baseAssetId, quoteAssetId, side, and baseAmount

When creating a Quote or an Order, you express the trade using:
  • baseAssetId: the asset you receive on BUY / give on SELL
  • quoteAssetId: the counter asset used to pay/receive
  • side:
    • BUY: receive base / pay quote
    • SELL: give base / receive quote
  • baseAmount: amount in baseAssetId
    • BUY: base amount to receive
    • SELL: base amount to sell

Examples

Step 3: Create a Quote for the Swap

Creating a quote is required before executing a swap via direct access providers. A quote provides you with the exact exchange rate, expected amounts, fees, and price impact for the swap.

API Call

Quote Response Example

Understanding Quote Fields

Quotes expire quickly (typically within 1-5 minutes). Create your order promptly after receiving a quote.

For more details about this endpoint, see the Create Quote API Reference.

Step 4: Execute the Swap Order

Once you have a quote, execute the swap using that quote. Direct access providers like Uniswap require a quote to ensure you get the expected rate and protection against price slippage.

Execute Order with Quote

Why direct access providers require quotes: Unlike some account-based providers, direct access providers (like Uniswap) through Fireblocks require creating a quote first. This ensures you know the exact exchange rate, fees, and slippage protection before the transaction executes on-chain.

For more details about this endpoint, see the Create Order API Reference.

Step 5: Monitor Order Status

After creating an order, monitor its execution status to track completion.

Get Order Details

For more details about this endpoint, see the Get Order Details API Reference.

List All Orders

For more details about this endpoint, see the Get Orders (List) API Reference.

Order Status Values

Additional Resources

Support

For questions or issues with the Trading API: