Freeze rate for operations [Private]
A pre-request for a exchange operations is required only in case when exchange is combined with deposit or withdraw.
Method name: | /v2/rate/freeze |
Request type: | POST |
To call private endpoints, you need to get a JWT token or an API key for authentication.
Here you can learn in detail how to successfully authenticate.
This endpoint is used to freeze the exchange rate for a certain period to facilitate the subsequent exchange of one asset for another. The frozen rate includes transaction costs, which are components of the exchange operation (deposit, exchange, withdrawal), and may vary depending on the type of operation.
For example, for a crypto-to-crypto exchange operation (where both the target and source assets are already in the customer's account), the exchange rate will be more favorable than for a deposit with an exchange operation (where the client buys crypto with fiat). Additionally, the selected payment method for the operation can influence the exchange rate.
To determine which assets are being exchanged, it is sufficient to specify the source and target assets: the source asset is the currency being exchanged, while the target asset is the currency being received. It is also necessary to indicate either the source amount (the amount the client is willing to spend as the source asset) or the target amount (the amount the client wishes to receive).
Good to know:
If you indicate
sourceAsset
, thentargetAsset
will be calculated automatically, and vice versa, if you indicatetargetAsset
-sourceAsset
will be calculated automatically.
For accurate calculation of the frozen rate, it is essential to specify the type of operation for which the freezing is carried out.
Deposit and withdrawal payment methods available for operation types can be obtained using a pre-request for operations and should be also provided.
It's important:
The default freeze rate duration is 30 seconds, although this value can be changed for different types of currencies.
Data dictionary
Name | Type | Parameter type | Required | Range | Description |
---|---|---|---|---|---|
sourceAsset | string | BODY | YES | - | Source or base Asset code. |
targetAsset | string | BODY | YES | - | Target or quote Asset code. |
sourceAmount | int | BODY | NO | - | Amount for sourceAsset. |
targetAmount | int | BODY | NO | - | Amount for targetAsset. |
operationType | string | BODY | YES | DepositWithExchange, WithdrawWithExchange, CryptoExchange, BuyToSendCrypto | The type of operation for which you are requesting a pre-request. |
depositPaymentCode | string | BODY | NO | - | Deposit payment code (only for DepostWithExchange and BuyToSendCrypto operations). You can get it via a pre-request. |
withdrawPaymentCode | string | BODY | NO | - | Withdrawal payment code (only for WithdrawWithExchange and BuyToSendCrypto operations). You can get it via a pre-request. |
withInternalFiat | boolean | BODY | NO | true, false | Show if operation processing with merchant fiat funds (only for DepositWithExchange, WithdrawWithExchange, BuyToSendCrypto). |
walletId | string | BODY | YES | - | Unique identifier of customer wallet in Kuna Core. |
refUserId | string | BODY | NO | - | ID of another customer. (For the referral program, if your service supports it). |
Exemplary request
// Exchange 11 USDT to ETH.
const url = BASE_URL;
const path = "/v2/rate/freeze";
const body = {
operationType: 'CryptoExchange',
withInternalFiat: false,
sourceAsset: 'USDT',
targetAsset: 'ETH',
sourceAmount: '11',
walletId: '1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5'
};
const options = {
method: "POST",
headers: {
accept: "application/json",
"Content-Type": "application/json",
"Authorization": `Bearer ${data.accessToken}` // data.accessToken - generated a JWT token via /v2/auth/login.
},
body: JSON.stringify(body),
};
fetch(url + path, options)
.then((response) => response.json())
.then((showResponse) => console.log(showResponse.data));
# Exchange 11 USDT to ETH.
import requests
url = BASE_URL
path = "/v2/rate/freeze"
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer " + data.accessToken # data.accessToken - generated a JWT token via /v2/auth/login.
}
body = {
"operationType": 'CryptoExchange',
"withInternalFiat": False,
"sourceAsset": 'USDT',
"targetAsset": 'ETH',
"sourceAmount": '11',
"walletId": '1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5'
}
request = requests.post(url + path, headers=headers, json=body)
print(request.json())
// Deposit 10 EUR and exchange to USDT.
const url = BASE_URL;
const path = "/v2/rate/freeze";
const body = {
operationType: 'DepositWithExchange',
withInternalFiat: false,
sourceAsset: 'EUR',
targetAsset: 'USDT',
sourceAmount: '10',
depositPaymentCode: 'payment_card_eur_hpp_europe',
walletId: '1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5'
};
const options = {
method: "POST",
headers: {
accept: "application/json",
"Content-Type": "application/json",
"Authorization": `Bearer ${data.accessToken}` // data.accessToken - generated a JWT token via /v2/auth/login.
},
body: JSON.stringify(body),
};
fetch(url + path, options)
.then((response) => response.json())
.then((showResponse) => console.log(showResponse.data));
# Deposit 10 EUR and exchange to USDT.
import requests
url = BASE_URL
path = "/v2/rate/freeze"
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer " + data.accessToken # data.accessToken - generated a JWT token via /v2/auth/login.
}
body = {
"operationType": 'DepositWithExchange',
"withInternalFiat": False,
"sourceAsset": 'EUR',
"targetAsset": 'USDT',
"sourceAmount": '10',
"depositPaymentCode": 'payment_card_eur_hpp_europe',
"walletId": '1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5'
}
request = requests.post(url + path, headers=headers, json=body)
print(request.json())
// Exchange 10 USDT to EUR with withdrawal to a bank card.
const url = BASE_URL;
const path = "/v2/rate/freeze";
const body = {
operationType: "WithdrawWithExchange",
withInternalFiat: false,
sourceAsset: "USDT",
targetAsset: "EUR",
sourceAmount: "10",
withdrawPaymentCode: "payment_card_eur_europe",
walletId: "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5",
};
const options = {
method: "POST",
headers: {
accept: "application/json",
"Content-Type": "application/json",
"Authorization": `Bearer ${data.accessToken}` // data.accessToken - generated a JWT token via /v2/auth/login.
},
body: JSON.stringify(body),
};
fetch(url + path, options)
.then((response) => response.json())
.then((showResponse) => console.log(showResponse.data));
# Exchange 10 USDT to EUR with withdrawal to a bank card.
import requests
url = BASE_URL
path = "/v2/rate/freeze"
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer " + data.accessToken # data.accessToken - generated a JWT token via /v2/auth/login.
}
body = {
"operationType": "WithdrawWithExchange",
"withInternalFiat": false,
"sourceAsset": "USDT",
"targetAsset": "EUR",
"sourceAmount": "10",
"withdrawPaymentCode": "payment_card_eur_europe",
"walletId": "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5"
}
request = requests.post(url + path, headers=headers, json=body)
print(request.json())
// Deposit 10 EUR and exchange to USDT with withdrawal to a wallet.
const url = BASE_URL;
const path = "/v2/rate/freeze";
const body = {
operationType: "BuyToSendCrypto",
withInternalFiat: false,
sourceAsset: "EUR",
targetAsset: "USDT",
sourceAmount: "10",
depositPaymentCode: "payment_card_eur_hpp_europe",
withdrawPaymentCode: "crypto_withdraw_trx_usdt",
walletId: "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5",
};
const options = {
method: "POST",
headers: {
accept: "application/json",
"Content-Type": "application/json",
"Authorization": `Bearer ${data.accessToken}` // data.accessToken - generated a JWT token via /v2/auth/login.
},
body: JSON.stringify(body),
};
fetch(url + path, options)
.then((response) => response.json())
.then((showResponse) => console.log(showResponse.data));
# Deposit 10 EUR and exchange to USDT with withdrawal to a wallet.
import requests
url = BASE_URL
path = "/v2/rate/freeze"
headers = {
"accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer " + data.accessToken # data.accessToken - generated a JWT token via /v2/auth/login.
}
body = {
"operationType": "BuyToSendCrypto",
"withInternalFiat": false,
"sourceAsset": "EUR",
"targetAsset": "USDT",
"sourceAmount": "10",
"depositPaymentCode": "payment_card_eur_hpp_europe",
"withdrawPaymentCode": "crypto_withdraw_trx_usdt",
"walletId": "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5"
}
request = requests.post(url + path, headers=headers, json=body)
print(request.json())
How to call private endpoints here
Response
{
"data": {
"sourceAmount": "11", // Amount spent.
"sourceAsset": "USDT", // Asset of the amount spent.
"rate": "0.00025717", // Exchange rate.
"targetAmount": "0.00282887", // Amount received.
"targetAsset": "ETH", // Asset of the amount received.
"walletId": "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5", // Customer wallet ID.
"createdAt": "2024-03-08T13:38:25.758Z", // Freeze сreation time.
"expiredAt": "2024-03-08T13:38:55.758Z", // Freeze expiration time.
"id": "2dcb5764-8705-4be6-b0ec-7fcad833dd96", // Freeze ID (rateId).
"feeDeposit": "0", // Deposit fee (only for DepostWithExchange and BuyToSendCrypto operations).
"feeDepositAsset": "USDT", // Asset of the deposit fee (only for DepostWithExchange and BuyToSendCrypto operations).
"feeWithdraw": "0", // Withdrawal fee (only for WithdrawWithExchange and BuyToSendCrypto operations).
"feeWithdrawAsset": "ETH", // Asset of the withdrawal fee (only for WithdrawWithExchange and BuyToSendCrypto operations).
"feeTrade": "0", // Fee for trading operation.
"feeTradeAsset": "ETH", // Asset of fee for trading operation.
"totalFeeSourceAsset": "0", // Total fees of the base (Source) asset.
"totalFeeTargetAsset": "0" // Total fees of the quote (Target) asset.
}
}
{
"data": {
"sourceAmount": "10",
"sourceAsset": "EUR",
"rate": "0.94767",
"targetAmount": "9.381933",
"targetAsset": "USDT",
"walletId": "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5",
"createdAt": "2024-03-08T17:33:27.459Z",
"expiredAt": "2024-03-08T17:33:57.459Z",
"id": "77db4f0e-07c5-408b-8e61-4e696b2fb879",
"feeDeposit": "0.1",
"feeDepositAsset": "EUR",
"feeWithdraw": "0",
"feeWithdrawAsset": "USDT",
"feeTrade": "0",
"feeTradeAsset": "USDT",
"totalFeeSourceAsset": "0.1",
"totalFeeTargetAsset": "0.094767"
}
}
{
"data": {
"sourceAmount": "10",
"sourceAsset": "USDT",
"rate": "0.9799755",
"targetAmount": "9.11",
"targetAsset": "EUR",
"walletId": "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5",
"createdAt": "2024-03-19T17:02:44.008Z",
"expiredAt": "2024-03-19T17:03:14.008Z",
"id": "673d2232-7aa7-4858-a2f9-b754db2b83a9",
"feeDeposit": "0",
"feeDepositAsset": "USDT",
"feeWithdraw": "0.19",
"feeWithdrawAsset": "EUR",
"feeTrade": "0.5",
"feeTradeAsset": "EUR",
"totalFeeSourceAsset": "0.704099",
"totalFeeTargetAsset": "0.69"
}
}
{
"data": {
"sourceAmount": "10",
"sourceAsset": "EUR",
"rate": "1.010178",
"targetAmount": "10.000762",
"targetAsset": "USDT",
"walletId": "1f44b1c7-9fd4-4d20-b9a4-7aca3646d0d5",
"createdAt": "2024-03-19T17:11:13.741Z",
"expiredAt": "2024-03-19T17:11:43.741Z",
"id": "bb893681-8cd9-4834-b5fe-3aae40f56bad",
"feeDeposit": "0.1",
"feeDepositAsset": "EUR",
"feeWithdraw": "0",
"feeWithdrawAsset": "USDT",
"feeTrade": "0",
"feeTradeAsset": "USDT",
"totalFeeSourceAsset": "0.1",
"totalFeeTargetAsset": "0.101018"
}
}
Updated about 2 months ago