Foreign Currency Exchange

Overview

The Foreign Exchange module provides the infrastructure to carry out currency exchanges on behalf of customers —a particularly important feature for platforms that accommodate multiple currencies. This module includes a series of endpoints tailored to the needs of users looking to perform, monitor, and manage asset exchanges for their customers.

Offering functions from quoting to execution, along with detailed tracking mechanisms, the Foreign Exchange module endpoints include:

  1. Get Available Currency Pairs: Provides a full list of currency pairs available for exchange.

  2. Get Account Details: This endpoint will return available source and destination accounts the customer can choose to do the exchange.

  3. Get Quote for Exchange: Provides an estimate for an exchange, detailing the source and destination amount before the actual exchange is executed, ensuring that the customer is informed about the potential transaction.

  4. Execute Exchange: Execute the quote exchange using the id received from the quote for exchange.

Overall, the Exchange module is designed to offer a seamless and secure experience for handling the exchange requirements of customers, ensuring that users can manage these operations effectively with great precision and control.


Get Available Currency Pairs

Provides a full list of asset pairs enabled for the API user. The response will also include information on limits and minimums associated with each asset pair for exchanges.

  • Endpoint: /api/v1/customer/foreign-exchanges/pairs

  • Method: GET

Success Response Example:

{
    "id": 14107,
    "details": [
        {
            "baseAsset": "CNH",
            "exchangeAsset": "SGD"
        },        
        {
            "baseAsset": "EUR",
            "exchangeAsset": "CHF"
        },
        {
            "baseAsset": "GBP",
            "exchangeAsset": "SGD"
        },
        {
            "baseAsset": "USD",
            "exchangeAsset": "SGD"
        }
    ],
    "pageSize": 100,
    "pageNumber": 1,
    "numberOfPages": 1,
    "status": "1",
    "errors": []
}

Get Account Details

Provides list of source and destination accounts based on the source and destination currency provided for the customer.

  • Endpoint: /api/v1/customer/foreign-exchanges/account-details

  • Method: GET

Success Response Example:

{
    "id": 14107,
    "details": {
        "sourceAsset": "GBP",
        "destinationAsset": "SGD",
        "fromAccounts": [
            {
                "accountID": "3140",
                "displayName": "GBP Account",
                "currencySymbol": "£",
                "balance": 5159.54
            }
        ],
        "toAccounts": [
            {
                "accountID": "3146",
                "displayName": "SGD Account",
                "currencySymbol": "S$",
                "balance": 2399.32
            }
        ]
    },
    "status": "1",
    "errors": []
}

Get Quote for Exchange

This endpoint provides a quoted market price for a proposed asset exchange for a particular customer, detailing the source and destination amount for either a "Buy" or "Sell" exchange type. By specifying details of the desired trade, a customer can see the cost or proceeds they might expect from completing a transaction, including any applicable fees. This helps customers decide whether to proceed with an exchange based on real-time financial data.

  • Endpoint: /api/v1/customer/foreign-exchanges/quote

  • Method: POST

Request Example:

{
    "SourceCurrency": "GBP",
    "DestinationCurrency": "SGD",
    "SourceAmount": "100",
    "SourceAccountId": 3140,
    "DestinationAccountId":3146
}

Success Response Example:

{
    "id": 1,
    "details": {
        "sourceAmount": 100,
        "destinationAmount": null,
        "quoteSourceAmount": null,
        "quoteDestinationAmount": 167.89,
        "sourceAmountLessFees": 99.5,
        "comissionFees": 0.5,
        "totalFees": 0.5,
        "quotedFXRate": "1.687312",
        "quotedFXRateID": 1423,
        "quotedFxRateExpiry": "2024-08-19T14:13:22.6153953Z"
    },
    "status": "1",
    "errors": []
}

Possible Error Codes

Error Message Code
Description

Required

Named field missing or zero

Invalid

Value given for named field is invalid

No_Account

No source account details found

Insufficient_Funds

Source account do not have enough funds to performa the exchange


Execute Exchange

This endpoint is designed to initiate a sell exchange, allowing a customer to sell an asset at a given price or for a specific amount.

  • Endpoint: /api/v1/customer/foreign-exchanges/executeexchange

  • Method: POST

Request Body Example:

{
    "FxRateId": 1423,
    "PurposeCode": "test"
}

Success Response Example:

{
    "id": 14589,
    "details": {},
    "status": "1",
    "errors": []
}

Possible Error Codes

Error Message Code
Description

Required

Named field missing or zero

Invalid

Value given for named field is invalid

Documents_Not_Verified

Cannot perform this action for this customer due to the KYC state


Last updated