Direct exchange
This guide will explain how to perform a Currency Exchange using the Vault API. You will be able to exchange one currency for another on the user’s account with ease. The process involves creating a request to exchange the source currency for the target currency. --- ## Step 1: Make a Request to Exchange Currency To create a currency exchange, send a POST
request to the direct-exchange
endpoint. ### Endpoint
Step 1: Make a Request to Exchange Currency
To create a currency exchange, send a POST
request to the direct-exchange endpoint.
Query Parameters
Parameter | Type | Description |
---|---|---|
dryRun | boolean | If true, simulates the exchange and returns the expected rate and fee without performing the exchange. |
Body Parameters
The following parameters are required in the request body to initiate the exchange:
Parameter | Type | Description |
---|---|---|
fromAccount | string | The account initiating the exchange (required). |
toAccount | string | The destination account for the exchange (required). |
fromCurrency | string | The currency to exchange from (required). |
toCurrency | string | The currency to exchange to (required). |
fromAmount | string | The amount of the source currency to exchange (required). |
toAmount | string | The amount in the target currency that you expect to receive (required). |
signedRate | object | The exchange rate object for the transaction. |
signedRate
Object
signedRate
ObjectThis object contains the rate at which the exchange is executed.
Parameter | Type | Description |
---|---|---|
rateRequest | object | Request details for the currency conversion rate. |
rate | string | The rate at which the exchange will happen. |
validUntil | string | The timestamp until which the rate is valid. |
signature | string | The digital signature for the rate. |
Best Practices
-
Use
dryRun
for Testing:
Always usedryRun
to simulate the exchange and check the rate and fees before performing the actual exchange. -
Check Expiry Dates:
Ensure that the exchange rate has not expired by reviewing thevalidUntil
timestamp. -
Review Fees:
The exchange will involve a fee (feeAmount
). Review it to understand the total cost of the exchange.
Conclusion
This guide explains the process for creating a currency exchange between two accounts using the Vault API. By using the dryRun
feature, you can simulate the exchange before committing to the transaction, ensuring you understand the rate and fee structure. Always review the details before performing a live exchange.
For any issues or questions, refer to the official API documentation or contact support for assistance.
Updated 23 days ago