squarefi-bff-api-module 1.36.25 → 1.36.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api/orders.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { API } from './types/types';
|
|
2
2
|
export declare const orders: {
|
|
3
|
-
calc: ({ signal, ...params }: API.Orders.Calc.Request) => Promise<API.Orders.Calc.Response>;
|
|
4
|
-
orderTypes: {
|
|
5
|
-
list: () => Promise<API.Orders.OrderTypes.List.Response>;
|
|
6
|
-
};
|
|
7
3
|
create: {
|
|
8
4
|
byOrderType: {
|
|
9
5
|
TRANSFER_INTERNAL: (data: API.Orders.Create.ByOrderType.INTERNAL_TRANSFER.Request) => Promise<API.Orders.Create.ByOrderType.INTERNAL_TRANSFER.Response>;
|
package/dist/api/orders.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { apiClientV1, apiClientV1Frontend } from '../utils/apiClientFactory';
|
|
2
2
|
import { OrderType } from '../constants';
|
|
3
3
|
export const orders = {
|
|
4
|
-
calc: ({ signal, ...params }) => apiClientV1.getRequest('/orders/calc', {
|
|
5
|
-
params,
|
|
6
|
-
signal,
|
|
7
|
-
}),
|
|
8
|
-
orderTypes: {
|
|
9
|
-
list: () => apiClientV1.getRequest('/orders/order_types'),
|
|
10
|
-
},
|
|
11
4
|
create: {
|
|
12
5
|
byOrderType: {
|
|
13
6
|
[OrderType.TRANSFER_INTERNAL]: (data) => apiClientV1.postRequest('/orders/INTERNAL_TRANSFER', {
|
|
@@ -4950,7 +4950,8 @@ export interface paths {
|
|
|
4950
4950
|
amount: number;
|
|
4951
4951
|
/** @description Idempotency key (UUID) */
|
|
4952
4952
|
request_id: string;
|
|
4953
|
-
documents
|
|
4953
|
+
/** @description Optional supporting documents persisted with the order. */
|
|
4954
|
+
documents?: components["schemas"]["OrderDocumentInput"][];
|
|
4954
4955
|
};
|
|
4955
4956
|
};
|
|
4956
4957
|
};
|
|
@@ -5620,6 +5621,8 @@ export interface paths {
|
|
|
5620
5621
|
/** @description Idempotency key */
|
|
5621
5622
|
reference_id?: string;
|
|
5622
5623
|
note?: string;
|
|
5624
|
+
/** @description Optional supporting documents persisted with the order. */
|
|
5625
|
+
documents?: components["schemas"]["OrderDocumentInput"][];
|
|
5623
5626
|
};
|
|
5624
5627
|
};
|
|
5625
5628
|
};
|
|
@@ -6006,7 +6009,10 @@ export interface paths {
|
|
|
6006
6009
|
from_currency_id: string;
|
|
6007
6010
|
to_currency_id: string;
|
|
6008
6011
|
/** @description If `true`, calculates inputs needed to receive the given amount. */
|
|
6009
|
-
is_reverse
|
|
6012
|
+
is_reverse: boolean;
|
|
6013
|
+
/** @description If `true`, the network fee is subtracted from `result_amount`. If `false`, the fee is added on top of `from_amount` and the recipient gets the full converted amount. Ignored for reverse calculations. Required so the client always states the fee-allocation mode explicitly — a change of the server-side fallback can never silently alter the calculation.
|
|
6014
|
+
* */
|
|
6015
|
+
is_subtract: boolean;
|
|
6010
6016
|
/** @description Destination address (for crypto withdrawals; affects network fee estimation). */
|
|
6011
6017
|
to_address?: string;
|
|
6012
6018
|
};
|
|
@@ -6021,7 +6027,13 @@ export interface paths {
|
|
|
6021
6027
|
headers: {
|
|
6022
6028
|
[name: string]: unknown;
|
|
6023
6029
|
};
|
|
6024
|
-
content
|
|
6030
|
+
content: {
|
|
6031
|
+
"application/json": {
|
|
6032
|
+
/** @example true */
|
|
6033
|
+
success: boolean;
|
|
6034
|
+
data: components["schemas"]["OrderCalculation"];
|
|
6035
|
+
};
|
|
6036
|
+
};
|
|
6025
6037
|
};
|
|
6026
6038
|
/** @description Invalid request (e.g. unknown `order_type`, missing required parameter, exchange rate not found) */
|
|
6027
6039
|
400: {
|
|
@@ -6032,6 +6044,15 @@ export interface paths {
|
|
|
6032
6044
|
"application/json": components["schemas"]["ErrorResponse"];
|
|
6033
6045
|
};
|
|
6034
6046
|
};
|
|
6047
|
+
/** @description Calculation failed (e.g. network fee estimation error) */
|
|
6048
|
+
500: {
|
|
6049
|
+
headers: {
|
|
6050
|
+
[name: string]: unknown;
|
|
6051
|
+
};
|
|
6052
|
+
content: {
|
|
6053
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
6054
|
+
};
|
|
6055
|
+
};
|
|
6035
6056
|
};
|
|
6036
6057
|
};
|
|
6037
6058
|
put?: never;
|
|
@@ -10053,6 +10074,58 @@ export interface components {
|
|
|
10053
10074
|
* @enum {string}
|
|
10054
10075
|
*/
|
|
10055
10076
|
OrderTypeId: "EXCHANGE_OMNI" | "EXCHANGE_OMNI_ONRAMP" | "EXCHANGE_OMNI_OFFRAMP" | "EXCHANGE_OMNI_CRYPTO" | "EXCHANGE_CRYPTO_INTERNAL" | "L2F_ACH_ONRAMP" | "L2F_ACH_OFFRAMP" | "L2F_SEPA_ONRAMP" | "L2F_SEPA_OFFRAMP" | "L2F_SWIFT_ONRAMP" | "L2F_SWIFT_OFFRAMP" | "L2F_WIRE_ONRAMP" | "L2F_WIRE_OFFRAMP" | "L2F_CHAPS_ONRAMP" | "L2F_CHAPS_OFFRAMP" | "L2F_FPS_ONRAMP" | "L2F_FPS_OFFRAMP" | "BRL_WIRE_ONRAMP" | "BRL_WIRE_OFFRAMP" | "BRL_ACH_ONRAMP" | "BRL_ACH_OFFRAMP" | "BRL_RTP_OFFRAMP" | "DLS_WIRE_ONRAMP" | "DLS_WIRE_OFFRAMP" | "DLS_ACH_ONRAMP" | "DLS_ACH_OFFRAMP" | "DLS_SEPA_ONRAMP" | "DLS_SEPA_OFFRAMP" | "DLS_SWIFT_ONRAMP" | "DLS_SWIFT_OFFRAMP" | "OMNIBUS_CRYPTO_TRANSFER" | "OMNIBUS_CRYPTO_WITHDRAWAL" | "OMNIBUS_INTERNAL_TRANSFER" | "SEGREGATED_CRYPTO_TRANSFER" | "TRANSFER_INTERNAL" | "TRANSFER_CARD_PREPAID" | "TRANSFER_CARD_SUBACCOUNT" | "TRANSFER_CARD_WHOLESALE" | "WITHDRAW_CARD_PREPAID" | "WITHDRAW_CARD_SUBACCOUNT" | "REFUND_CARD_PREPAID" | "REFUND_CARD_SUBACCOUNT" | "RN_CARDS_OFFRAMP" | "CARD_ISSUING_FEE";
|
|
10077
|
+
OrderCalculation: {
|
|
10078
|
+
/**
|
|
10079
|
+
* Format: uuid
|
|
10080
|
+
* @description Source currency UUID.
|
|
10081
|
+
*/
|
|
10082
|
+
from_currency: string;
|
|
10083
|
+
/**
|
|
10084
|
+
* Format: uuid
|
|
10085
|
+
* @description Destination currency UUID.
|
|
10086
|
+
*/
|
|
10087
|
+
to_currency: string;
|
|
10088
|
+
/**
|
|
10089
|
+
* @description Amount to be spent in the source currency.
|
|
10090
|
+
* @example 100
|
|
10091
|
+
*/
|
|
10092
|
+
from_amount: number;
|
|
10093
|
+
/**
|
|
10094
|
+
* @description Amount to be received in the destination currency.
|
|
10095
|
+
* @example 98.5
|
|
10096
|
+
*/
|
|
10097
|
+
result_amount: number;
|
|
10098
|
+
/**
|
|
10099
|
+
* @description Exchange rate applied (source → destination), 6 decimals.
|
|
10100
|
+
* @example 0.985
|
|
10101
|
+
*/
|
|
10102
|
+
rate: number;
|
|
10103
|
+
/**
|
|
10104
|
+
* @description Total fees (comission + network_fee), in the source currency.
|
|
10105
|
+
* @example 1.5
|
|
10106
|
+
*/
|
|
10107
|
+
fees: number;
|
|
10108
|
+
/**
|
|
10109
|
+
* @description Service commission (wire name is intentionally `comission`).
|
|
10110
|
+
* @example 1.5
|
|
10111
|
+
*/
|
|
10112
|
+
comission: number;
|
|
10113
|
+
/**
|
|
10114
|
+
* @description Estimated blockchain network fee (crypto withdrawals only, otherwise 0).
|
|
10115
|
+
* @example 0
|
|
10116
|
+
*/
|
|
10117
|
+
network_fee: number;
|
|
10118
|
+
/**
|
|
10119
|
+
* @description Transaction fee. Always 0 for now.
|
|
10120
|
+
* @example 0
|
|
10121
|
+
*/
|
|
10122
|
+
transaction_fee: number;
|
|
10123
|
+
/**
|
|
10124
|
+
* @description Source currency symbol.
|
|
10125
|
+
* @example USDT
|
|
10126
|
+
*/
|
|
10127
|
+
from_symbol: string;
|
|
10128
|
+
};
|
|
10056
10129
|
PaginationResponse: {
|
|
10057
10130
|
offset: number;
|
|
10058
10131
|
limit: number;
|
|
@@ -10694,6 +10767,15 @@ export interface components {
|
|
|
10694
10767
|
[key: string]: unknown;
|
|
10695
10768
|
}[];
|
|
10696
10769
|
};
|
|
10770
|
+
/** @description Supporting document attached to an order at creation time (persisted to order_documents). */
|
|
10771
|
+
OrderDocumentInput: {
|
|
10772
|
+
/**
|
|
10773
|
+
* Format: uri
|
|
10774
|
+
* @description Document URL (must be a valid URL)
|
|
10775
|
+
*/
|
|
10776
|
+
url: string;
|
|
10777
|
+
description?: string;
|
|
10778
|
+
};
|
|
10697
10779
|
FrontendCryptoTransferRequest: {
|
|
10698
10780
|
/**
|
|
10699
10781
|
* Format: uuid
|
|
@@ -10713,6 +10795,8 @@ export interface components {
|
|
|
10713
10795
|
request_id: string;
|
|
10714
10796
|
reference?: string;
|
|
10715
10797
|
note?: string;
|
|
10798
|
+
/** @description Optional supporting documents persisted with the order. */
|
|
10799
|
+
documents?: components["schemas"]["OrderDocumentInput"][];
|
|
10716
10800
|
};
|
|
10717
10801
|
FrontendL2FOrderRequest: {
|
|
10718
10802
|
/**
|
|
@@ -10733,6 +10817,8 @@ export interface components {
|
|
|
10733
10817
|
request_id: string;
|
|
10734
10818
|
reference?: string;
|
|
10735
10819
|
note?: string;
|
|
10820
|
+
/** @description Optional supporting documents persisted with the order. */
|
|
10821
|
+
documents?: components["schemas"]["OrderDocumentInput"][];
|
|
10736
10822
|
};
|
|
10737
10823
|
FrontendExchangeOrderRequest: {
|
|
10738
10824
|
/** Format: uuid */
|
|
@@ -1758,6 +1758,8 @@ export declare namespace API {
|
|
|
1758
1758
|
}
|
|
1759
1759
|
}
|
|
1760
1760
|
namespace Frontend {
|
|
1761
|
+
type OrderDocumentInput = componentsV1Frontend['schemas']['OrderDocumentInput'];
|
|
1762
|
+
type OrderCalculation = componentsV1Frontend['schemas']['OrderCalculation'];
|
|
1761
1763
|
type OrderEnvelope = {
|
|
1762
1764
|
success?: boolean;
|
|
1763
1765
|
data?: componentsV1Frontend['schemas']['Order'];
|
|
@@ -1834,7 +1836,7 @@ export declare namespace API {
|
|
|
1834
1836
|
type Request = pathsV1Frontend['/frontend/orders/calc']['get']['parameters']['query'] & {
|
|
1835
1837
|
signal?: AbortSignal;
|
|
1836
1838
|
};
|
|
1837
|
-
type Response =
|
|
1839
|
+
type Response = pathsV1Frontend['/frontend/orders/calc']['get']['responses'][200]['content']['application/json'];
|
|
1838
1840
|
}
|
|
1839
1841
|
namespace GetById {
|
|
1840
1842
|
type Request = pathsV1Frontend['/frontend/orders/id/{order_id}']['get']['parameters']['path'];
|
package/dist/hooks/useCalc.d.ts
CHANGED
|
@@ -1,13 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type CalcResult = {
|
|
2
|
+
from_currency: string;
|
|
3
|
+
to_currency: string;
|
|
4
|
+
from_amount: number;
|
|
5
|
+
result_amount: number;
|
|
6
|
+
rate: number;
|
|
7
|
+
fees: number;
|
|
8
|
+
comission: number;
|
|
9
|
+
network_fee: number;
|
|
10
|
+
transaction_fee: number;
|
|
11
|
+
from_symbol: string;
|
|
12
|
+
};
|
|
13
|
+
type CalcData = CalcResult & {
|
|
3
14
|
is_subtract: boolean;
|
|
4
15
|
is_reverse: boolean;
|
|
5
16
|
};
|
|
6
|
-
export type OrderCalcHandlerProps =
|
|
17
|
+
export type OrderCalcHandlerProps = {
|
|
18
|
+
from_currency_id: string;
|
|
19
|
+
to_currency_id: string;
|
|
20
|
+
amount: number;
|
|
21
|
+
is_reverse: boolean;
|
|
22
|
+
is_subtract: boolean;
|
|
23
|
+
to_address?: string;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
};
|
|
7
26
|
export type UseOrderCalcProps = {
|
|
8
27
|
from_currency_id: string | null | undefined;
|
|
9
28
|
to_currency_id: string | null | undefined;
|
|
10
|
-
calcHandler: (props: OrderCalcHandlerProps) => Promise<
|
|
29
|
+
calcHandler: (props: OrderCalcHandlerProps) => Promise<CalcResult>;
|
|
11
30
|
disableCalculation?: boolean;
|
|
12
31
|
to_address?: string;
|
|
13
32
|
};
|
package/dist/hooks/useCalc.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import debounce from 'lodash.debounce';
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
|
-
export const useOrderCalc = (
|
|
4
|
-
const { from_currency_id, to_currency_id, calcHandler, disableCalculation, to_address } = props;
|
|
3
|
+
export const useOrderCalc = ({ from_currency_id, to_currency_id, calcHandler, disableCalculation, to_address, }) => {
|
|
5
4
|
const [sellingAmount, setSellingAmount] = useState(0);
|
|
6
5
|
const [buyingAmount, setBuyingAmount] = useState(0);
|
|
7
6
|
const [calcData, setCalcData] = useState(null);
|
|
@@ -49,7 +48,16 @@ export const useOrderCalc = (props) => {
|
|
|
49
48
|
is_reverse ? setIsSellingValuePending(true) : setIsBuyingValuePending(true);
|
|
50
49
|
const data = await calcHandler(calcParams);
|
|
51
50
|
setCalcData({
|
|
52
|
-
|
|
51
|
+
from_currency: data.from_currency,
|
|
52
|
+
to_currency: data.to_currency,
|
|
53
|
+
from_amount: data.from_amount,
|
|
54
|
+
result_amount: data.result_amount,
|
|
55
|
+
rate: data.rate,
|
|
56
|
+
fees: data.fees,
|
|
57
|
+
comission: data.comission,
|
|
58
|
+
network_fee: data.network_fee,
|
|
59
|
+
transaction_fee: data.transaction_fee,
|
|
60
|
+
from_symbol: data.from_symbol,
|
|
53
61
|
is_reverse,
|
|
54
62
|
is_subtract,
|
|
55
63
|
});
|