How Exchange Rates Work
Exchange rates work similarly for both offramps (stablecoin to fiat) and onramps (fiat to stablecoin):1
Request rate
Query the rates endpoint with the source and destination currencies.
2
Display to user
Show the rate to your user in your UI before they initiate the transaction.
Retrieving Exchange Rates
Use these endpoints to get estimated conversion rates:- Retrieve Offramp Rate - For stablecoin to fiat conversions
- Retrieve Onramp Rate - For fiat to stablecoin conversions
Offramp Rates (Stablecoin to Fiat)
| Parameter | Required | Supported Values |
|---|---|---|
| fromCurrency | Yes | usdc |
| toCurrency | Yes | usd, eur, brl, mxn, ars, cop, ugx, ngn, kes, xof, rwf, tzs, zmw, mwk, xaf |
Onramp Rates (Fiat to Stablecoin)
| Parameter | Required | Supported Values |
|---|---|---|
| fromCurrency | Yes | usd, eur, brl, mxn, ars, cop, ugx, ngn, kes, xof, rwf, tzs, zmw, mwk, xaf |
| toCurrency | Yes | usdc |
Response
Source currency code (e.g.,
usdc for stablecoin, usd, eur, brl for
fiat).Destination currency code (e.g.,
usd, eur, brl for fiat, usdc for
stablecoin).Estimated conversion rate from the source currency to the destination
currency. The rate is expressed as a string to preserve precision.
Usage Examples
Display Rate in UI
Retrieve rates to show users estimated conversion amounts before they create an offramp or onramp:Calculate Estimated Amount
Use the rate to calculate estimated conversion amounts:Key Concepts
Estimated vs. Final Rates
Estimated vs. Final Rates
Exchange rates from these endpoints are estimates for display purposes. The final conversion rate will be determined when you create the offramp or onramp request and may differ based on:
- Current market conditions at transaction time
- Fee calculations
- Network fees
- Quote expiration (quotes are valid for 10 minutes)
Rate Format
Rate Format
Conversion rates are returned as strings to preserve decimal precision. When performing calculations, always parse them to numbers.Use
parseFloat() or a decimal library (like decimal.js) for financial calculations to maintain accuracy.Error Handling
Error Handling
Handle common error responses:
- 401 Unauthorized: Invalid or missing API key
- 404 Not Found: Unsupported currency pair
- 500 Internal Server Error: Temporary service issue
Best Practices
Rate Caching: Cache exchange rates for 1-2 minutes to reduce API calls
while keeping data reasonably fresh. Don’t cache longer than 5 minutes as
rates can change.
- Show estimates only: Always label displayed rates as “estimated” to set user expectations
- Refresh on user action: Update rates when users change currency pairs
- Handle rate changes gracefully: If a rate changes between display and transaction creation, the quote will show the actual rate
- Validate currency pairs: Verify the requested currency pair is supported before displaying rates
Getting Help
- 📧 Email: support@hifibridge.com
- 💬 Slack: Message us in our shared Slack channel
Related Resources
- Offramps - Create offramp transactions using these rates
- Onramps - Create onramp transactions using these rates
- Currencies Reference - Complete list of supported currencies