How Swaps Work
Swaps execute immediately upon creation:1
Create swap request
Specify source currency, destination currency, and amount to exchange.
2
Automatic execution
HIFI executes the swap at the current market rate.
3
Completion
Receive the swapped currency in the destination wallet.
Creating Swaps
Use the Create Swap endpoint to exchange currencies on the same chain.Response
Response
Unique swap ID. Use this to check status using the Retrieve Swap endpoint.
Swap status. Swaps typically complete immediately. See Transaction Status for details.
Source wallet details including currency, amount, chain, and user information.
Destination wallet details including currency, amount received, chain, and user information.
Swap quote details including exchange rate, amounts sent and received.
Fee information for the swap. Contains an array of fees with their timing (ON_INVOICE or ON_TRANSACTION).
For detailed field documentation, see the Create Swap API reference.
Transaction Status
Swaps typically complete within seconds:| Status | Description |
|---|---|
| PENDING | Swap request created and processing |
| COMPLETED | Swap successfully executed |
| FAILED | Swap failed (check error and errorDetails for specifics) |
| CANCELLED | Swap was cancelled before execution |
Status Updates: Subscribe to
SWAP.CREATE and SWAP.UPDATE webhook events to receive real-time status notifications. See Webhooks for setup instructions.Tracking Swaps
Monitor swap status using the Retrieve Swap endpoint. Request:Response
Response
Current swap status. See Transaction Status for all possible statuses.
Supported Swap Pairs
Currently supported swap combinations:| Chain | Supported Pairs |
|---|---|
| Polygon | USDC ↔ USDT, USDC ↔ USDG, USDT ↔ USDG |
| Ethereum | USDC ↔ USDT, USDC ↔ USDG, USDT ↔ USDG |
| Solana | USDC ↔ USDT |
Coming Soon: Additional chains and token pairs will be added. Contact support if you need specific swap pairs.
Key Concepts
Amount Specification
Amount Specification
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.
Exchange Rates
Exchange Rates
The
quoteInformation.rate shows the exchange rate between currencies:- 1:1 stablecoins (USDC ↔ USDT): Rate is typically “1”
- Market rates: Rates may vary slightly based on liquidity
receiveNet to see the exact amount you’ll receive after any fees.Billing Information
Billing Information
The
billingInformation.fees array shows all applicable fees:EXCHANGE_FEE: Conversion fee for the swap- timing: ON_INVOICE: Billed on your monthly invoice (not deducted from swap)
- timing: ON_TRANSACTION: Deducted from the swap amount
timing to understand when fees are charged.External Wallet Swaps
External Wallet Swaps
Swap to external wallets (not managed by HIFI) by providing Or use a registered external wallet:
externalWalletId or walletAddress:External wallet swaps may require gas sponsorship enrollment. Use
userId for HIFI wallets when possible.Swap vs Bridge vs Transfer
Swap vs Bridge vs Transfer
Understanding the differences:Swaps: Exchange currencies on the same chain (USDC → USDT on Polygon)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
2
Verify completion
The response will show status
COMPLETED for successful swaps. Check:destination.amount- Amount receivedquoteInformation.rate- Exchange rate usedbillingInformation.fees- Any applicable fees
3
Handle errors
If status is
FAILED:- Check
errorfield for error type - Review
errorDetailsfor specific failure reason - Common issues: insufficient balance, unsupported pair, network congestion
Swap with exact output amount
1
Specify destination amount
When you need to receive an exact amount:
2
Check source amount used
The response shows how much source currency was needed:
source.amount- Amount deducted from source walletquoteInformation.sendNet- Net amount sent after fees
Getting Help
- 📧 Email: support@hifibridge.com
- 💬 Slack: Message us in our shared Slack channel
Related Resources
- Wallet Transfers - Same-chain transfers without currency exchange
- Bridging - Cross-chain asset movement
- Wallets - Understand wallet addresses and balances
- Webhooks - Real-time swap status notifications
- API Reference - Complete endpoint documentation