Sell a customer's naira from their NGN account for USDC in their own USDC wallet, at a quoted rate.
6 min read
This recipe sells a customer's naira from their NGN account for USDC in their own USDC wallet, at a quoted rate.
Who it is for. A Lagos savings app whose customers keep naira on Gravv and want to move part of it into USDC in their own Gravv wallet.
Status. Available once Gravv sets an OTC rate for your business.
Money example
Chidi has 1,600,000 NGN in his NGN account, and a USDC wallet.
1.
You get a quote to sell 1,530,000 NGN for USDC. The rate is 0.00065, so Chidi gets 994.5 USDC. The price holds until expires_at.
2.
Chidi taps "Convert". You place the order with that quote. Gravv takes 1,530,000 NGN from his NGN account at once, and the order is pending.
3.
994.5 USDC reaches his USDC wallet, and the order is completed.
Before you start
•
The NGN account is active, in NGN, and holds the sell amount plus any transfer fee on your pricing. The account is held on a wallet, so it has wallet_address and blockchain_network.
•
The USDC wallet belongs to the same customer.
•
A scoped key needs fx:read for the quote and fx:order_create for the order.
Find out what is required
The quote is the real check. For a pair not priced for your business, the quote returns quote currency pair is not supported. Rates from GET /v1/fx/rates are for display only.
currency must be NGN and balance must cover the sell amount. Gravv checks only the balance number, not the account's currency, so you must pick the right account.
Steps
1. Check the destination wallet
Gravv does not check that an internal destination can hold the currency you buy.
amount is always what you sell. rate is units of USDC per 1 NGN. to_amount is not rounded, so round it for display only. Show Chidi to_amount and expires_at, and get his confirmation.
3. Place the order
Place the order before expires_at. Do not send an amount, because the quote sets it.
Poll until status is completed, cancelled or rejected. pending covers both "debit running" and "debited, waiting to settle". There is no progress field.
5. See where the money went
•
For the naira, GET /v1/transactions?account_id=bd9c66b3-ad3c-4d6d-9a3d-1fa7bc8960a9&direction=out shows an outgoing row of 1,530,000 NGN whose description is OTC order 17fc695a-07a0-4a6e-8822-e8f36c031199 source debit.
•
For the USDC, GET /v1/wallets/972a8469-1641-4f82-8b9d-2434e465e150 shows the balance 994.5 higher once the order is completed.
What can go wrong
Response
Why
Fix
400 quote currency pair is not supported
The pair is not priced for your business, or its format is wrong
Send FROM_TO (NGN_USDC). If the format is right, ask for the pair
400 quote amount must be a positive number
The amount is missing, zero or negative
Send a positive decimal string
400 invalid request encoding
You sent amount as a number
Send a string, such as "amount": "1530000"
400 quote is invalid or expired on the order
The quote is expired, already used, another business's, or missing. The API checks the quote first
The order is waiting to settle, and you have nothing to send
Keep polling, and contact support with order_id. Do not cancel
The order is cancelled without you cancelling
The naira debit failed and moved nothing
Check the balance and re-quote
Webhooks you will receive
Gravv sends no webhooks for an FX order. Poll the order.
Testing in sandbox
The sandbox has no OTC rates today. Every quote returns quote currency pair is not supported. Ask support to set a rate on your sandbox business before you build the flow.