Skip to main content

Overview

1

Create swap request

Specify source currency, destination currency, and amount to exchange. The swap is created with OPEN_QUOTE status.
2

Accept the swap

Accept the swap using the Accept Swap endpoint to execute the exchange.
3

Completion

Receive the swapped currency in the destination wallet once the swap is accepted and executed.

Supported Pairs

USDG swapping is available upon request. Please contact support to get access.

Fees

The Swap endpoint uses a two-part billing model:
  • Market quote fees: Fees are included in the swap quote response. Check the quoteInformation fields (sendNet, receiveNet) to see the amounts after market fees are applied.
  • Gas fees: Network gas fees are charged separately on your invoice and are not included in the quote response.

Creating Swaps

Use the Create Swap endpoint to exchange currencies on the same chain.
The response contains the swap details. Swaps are created in PENDING status and require acceptance:
string
Unique swap ID. Use this to check status using the Retrieve Swap endpoint.
string
Swap status. Swaps are created with OPEN_QUOTE status and must be accepted before execution. See Transaction Status for details.
object
Source wallet details including currency, amount, chain, and user information.
object
Destination wallet details including currency, amount received, chain, and user information.
object
Swap quote details including exchange rate, amounts sent and received.
For detailed field documentation, see the Create Swap API reference.

Accepting Swaps

All swaps are created in PENDING status and require explicit acceptance before execution. Use the Accept Swap endpoint to accept and execute a swap. Request:
The accept endpoint returns the same swap details structure as the create endpoint, with updated status:
string
Swap status after acceptance. Transitions from PENDING to COMPLETED upon successful acceptance. See Transaction Status for details.
Required Step: All swaps must be accepted before execution. After creating a swap, always call the accept endpoint to execute the exchange.

Transaction Status

Swaps progress through the following statuses:
Status Updates: Subscribe to SWAP.TRANSACTION.CREATE and SWAP.STATUS.* webhook events to receive real-time status notifications. See Webhooks for setup instructions.

Tracking Swaps

Monitor swap status using the Retrieve Swap endpoint. Request:
The retrieve response includes current swap status:
string
Current swap status. See Transaction Status for all possible statuses.

Listing Swaps

Retrieve a list of all swaps associated with users under your organization using the List Swaps endpoint. Swaps are returned sorted by creation date, with the most recent swaps appearing first. Request:
Query Parameters:
string
required
Filter swaps by a specific user ID. If omitted, returns swaps for all users under your organization.
string
required
Number of swaps to return. Defaults to 10, maximum is 100.
string
required
Filter swaps created before this date. ISO format: YYYY-MM-DD.
string
required
Filter swaps created after this date. ISO format: YYYY-MM-DD.
Response:
integer
Total number of swaps returned in this response.
array
Array of swap objects. Each object follows the same structure as the swap details returned by the retrieve endpoint.
string
Timestamp cursor for pagination. Use this value with createdBefore parameter to fetch the next page of results.
Pagination: To fetch more swaps, use the nextCursor value as the createdBefore parameter in your next request. Continue until count is less than your limit, indicating you’ve reached the end.

Key Concepts

You can specify the amount in either source or destination:Source amount (you send exactly 100 USDC):
Destination amount (you receive exactly 100 USDT):
Provide amount in only one side - the system calculates the other based on the current rate.
The quoteInformation.rate shows the exchange rate between currencies. Rates may vary slightly based on liquidity Always verify receiveNet to see the exact amount you’ll receive after any fees.
Swap to external wallets (not managed by HIFI) by providing externalWalletId or walletAddress:
Or use a registered external wallet:
Understanding the differences:Swaps: Exchange different currencies on the same/across chain (USDC → USDT)Bridges: Move same currency across chains (USDC on Polygon → USDC on Ethereum)Transfers: Move same currency to another wallet on same chain (USDC wallet A → USDC wallet B on Polygon)

Sample Code

Basic swap flow

1

Create swap

The response will show status OPEN_QUOTE. Save the swap id from the response.
2

Accept the swap

Accept the swap to execute the exchange:
The response will show status CRAETED for successful swap request acceptance.
3

Verify completion

Review the swap details to confirm:
  • Status – should be COMPLETED
  • Destination Amount – the amount received
4

Handle errors

If status is FAILED:
  • Check error field for error type
  • Review errorDetails for specific failure reason
  • Common issues: insufficient balance, unsupported pair, not enough liquidity

Getting Help

  • 📧 Email: support@hifi.com
  • 💬 Slack: Message us in our shared Slack channel