@velora-dex/sdk 9.5.4-dev.0 → 9.5.4-dev.2
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/README.md +156 -0
- package/dist/examples/helpers/delta.d.ts +1 -1
- package/dist/examples/helpers/delta.d.ts.map +1 -1
- package/dist/examples/helpers/deltaV2.d.ts +3 -3
- package/dist/examples/helpers/deltaV2.d.ts.map +1 -1
- package/dist/examples/wagmi.d.ts.map +1 -1
- package/dist/index.d.ts +4 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/methods/delta/helpers/orders.d.ts +16 -1
- package/dist/methods/delta/helpers/orders.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts +48 -5
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/methods/deltaV2/{buildDeltaOrderV2.d.ts → buildDeltaOrder.d.ts} +10 -9
- package/dist/methods/deltaV2/buildDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/{buildExternalDeltaOrderV2.d.ts → buildExternalDeltaOrder.d.ts} +10 -9
- package/dist/methods/deltaV2/buildExternalDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/{buildTWAPDeltaOrderV2.d.ts → buildTWAPDeltaOrder.d.ts} +13 -12
- package/dist/methods/deltaV2/buildTWAPDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/cancelDeltaOrder.d.ts +21 -0
- package/dist/methods/deltaV2/cancelDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/getAgentsList.d.ts +10 -0
- package/dist/methods/deltaV2/getAgentsList.d.ts.map +1 -0
- package/dist/methods/deltaV2/getBridgeRoutes.d.ts +3 -3
- package/dist/methods/deltaV2/getBridgeRoutes.d.ts.map +1 -1
- package/dist/methods/deltaV2/getDeltaOrders.d.ts +40 -0
- package/dist/methods/deltaV2/getDeltaOrders.d.ts.map +1 -0
- package/dist/methods/deltaV2/{getDeltaPriceV2.d.ts → getDeltaPrice.d.ts} +7 -7
- package/dist/methods/deltaV2/getDeltaPrice.d.ts.map +1 -0
- package/dist/methods/deltaV2/helpers/orders.d.ts +191 -0
- package/dist/methods/deltaV2/helpers/orders.d.ts.map +1 -0
- package/dist/methods/deltaV2/index.d.ts +51 -38
- package/dist/methods/deltaV2/index.d.ts.map +1 -1
- package/dist/methods/deltaV2/isTokenSupportedInDelta.d.ts +8 -0
- package/dist/methods/deltaV2/isTokenSupportedInDelta.d.ts.map +1 -0
- package/dist/methods/deltaV2/{postDeltaOrderV2.d.ts → postDeltaOrder.d.ts} +9 -8
- package/dist/methods/deltaV2/postDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/postExternalDeltaOrder.d.ts +11 -0
- package/dist/methods/deltaV2/postExternalDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/postTWAPDeltaOrder.d.ts +17 -0
- package/dist/methods/deltaV2/postTWAPDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/types.d.ts +26 -20
- package/dist/methods/deltaV2/types.d.ts.map +1 -1
- package/dist/sdk/full.d.ts +1 -1
- package/dist/sdk/full.d.ts.map +1 -1
- package/dist/sdk/simple.d.ts +3 -9
- package/dist/sdk/simple.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +1602 -1281
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +1586 -1249
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.js +6 -1
- package/src/examples/deltaV2.ts +21 -25
- package/src/examples/helpers/delta.ts +6 -1
- package/src/examples/helpers/deltaV2.ts +9 -4
- package/src/index.js +167 -83
- package/src/index.ts +32 -143
- package/src/methods/delta/helpers/orders.ts +31 -1
- package/src/methods/delta/helpers/types.ts +59 -19
- package/src/methods/deltaV2/{buildDeltaOrderV2.ts → buildDeltaOrder.ts} +16 -16
- package/src/methods/deltaV2/{buildExternalDeltaOrderV2.ts → buildExternalDeltaOrder.ts} +16 -16
- package/src/methods/deltaV2/{buildTWAPDeltaOrderV2.ts → buildTWAPDeltaOrder.ts} +22 -22
- package/src/methods/deltaV2/{cancelDeltaOrderV2.ts → cancelDeltaOrder.ts} +17 -20
- package/src/methods/deltaV2/getAgentsList.ts +32 -0
- package/src/methods/deltaV2/getBridgeRoutes.ts +7 -7
- package/src/methods/deltaV2/getDeltaOrders.ts +149 -0
- package/src/methods/deltaV2/{getDeltaPriceV2.ts → getDeltaPrice.ts} +15 -15
- package/src/methods/deltaV2/helpers/orders.ts +363 -0
- package/src/methods/deltaV2/index.ts +148 -139
- package/src/methods/deltaV2/{isTokenSupportedInDeltaV2.ts → isTokenSupportedInDelta.ts} +7 -7
- package/src/methods/deltaV2/{postDeltaOrderV2.ts → postDeltaOrder.ts} +13 -16
- package/src/methods/deltaV2/postExternalDeltaOrder.ts +45 -0
- package/src/methods/deltaV2/{postTWAPDeltaOrderV2.ts → postTWAPDeltaOrder.ts} +14 -19
- package/src/methods/deltaV2/types.ts +35 -22
- package/src/sdk/full.ts +2 -2
- package/src/sdk/simple.ts +17 -43
- package/dist/methods/deltaV2/buildDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/buildExternalDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/buildTWAPDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/cancelDeltaOrderV2.d.ts +0 -21
- package/dist/methods/deltaV2/cancelDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/getAgentsListV2.d.ts +0 -10
- package/dist/methods/deltaV2/getAgentsListV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/getDeltaOrdersV2.d.ts +0 -33
- package/dist/methods/deltaV2/getDeltaOrdersV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/getDeltaPriceV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/isTokenSupportedInDeltaV2.d.ts +0 -8
- package/dist/methods/deltaV2/isTokenSupportedInDeltaV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/postDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/postExternalDeltaOrderV2.d.ts +0 -11
- package/dist/methods/deltaV2/postExternalDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/postTWAPDeltaOrderV2.d.ts +0 -16
- package/dist/methods/deltaV2/postTWAPDeltaOrderV2.d.ts.map +0 -1
- package/src/methods/deltaV2/getAgentsListV2.ts +0 -34
- package/src/methods/deltaV2/getDeltaOrdersV2.ts +0 -119
- package/src/methods/deltaV2/postExternalDeltaOrderV2.ts +0 -45
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { API_URL } from '../../constants';
|
|
2
2
|
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type { TWAPBuyDeltaOrder, TWAPDeltaOrder } from '../delta/helpers/types';
|
|
4
|
+
import type { BuiltDeltaOrder, DeltaRoute } from './types';
|
|
5
|
+
export type { BuiltDeltaOrder } from './types';
|
|
5
6
|
|
|
6
|
-
type
|
|
7
|
+
type BuildTWAPDeltaOrderBase = {
|
|
7
8
|
/** @description The address of the order owner */
|
|
8
9
|
owner: string;
|
|
9
10
|
/** @description The address of the order beneficiary. Defaults to owner. */
|
|
@@ -22,7 +23,7 @@ type BuildTWAPDeltaOrderV2Base = {
|
|
|
22
23
|
numSlices: number;
|
|
23
24
|
/** @description Slippage in basis points (bps). 10000 = 100%, 50 = 0.5%. Default 0. */
|
|
24
25
|
slippage?: number;
|
|
25
|
-
/** @description DeltaRoute from
|
|
26
|
+
/** @description DeltaRoute from getDeltaPrice for a single slice */
|
|
26
27
|
route: DeltaRoute;
|
|
27
28
|
/** @description Partner fee in basis points (bps) */
|
|
28
29
|
partnerFeeBps?: number;
|
|
@@ -40,13 +41,13 @@ type BuildTWAPDeltaOrderV2Base = {
|
|
|
40
41
|
limitAmount?: string;
|
|
41
42
|
};
|
|
42
43
|
|
|
43
|
-
export type
|
|
44
|
+
export type BuildTWAPSellDeltaOrderParams = BuildTWAPDeltaOrderBase & {
|
|
44
45
|
onChainOrderType: 'TWAPOrder';
|
|
45
46
|
/** @description Total source token amount across all slices. route.origin.input.amount must equal floor(totalSrcAmount / numSlices). */
|
|
46
47
|
totalSrcAmount: string;
|
|
47
48
|
};
|
|
48
49
|
|
|
49
|
-
export type
|
|
50
|
+
export type BuildTWAPBuyDeltaOrderParams = BuildTWAPDeltaOrderBase & {
|
|
50
51
|
onChainOrderType: 'TWAPBuyOrder';
|
|
51
52
|
/** @description Total destination token amount to buy across all slices. route.origin.output.amount must equal floor(totalDestAmount / numSlices). */
|
|
52
53
|
totalDestAmount: string;
|
|
@@ -54,32 +55,31 @@ export type BuildTWAPBuyDeltaOrderV2Params = BuildTWAPDeltaOrderV2Base & {
|
|
|
54
55
|
maxSrcAmount: string;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
|
-
export type
|
|
58
|
-
|
|
|
59
|
-
|
|
|
58
|
+
export type BuildTWAPDeltaOrderParams =
|
|
59
|
+
| BuildTWAPSellDeltaOrderParams
|
|
60
|
+
| BuildTWAPBuyDeltaOrderParams;
|
|
60
61
|
|
|
61
|
-
type
|
|
62
|
-
buildOrderParams:
|
|
62
|
+
type BuildTWAPDeltaOrder = (
|
|
63
|
+
buildOrderParams: BuildTWAPDeltaOrderParams,
|
|
63
64
|
requestParams?: RequestParameters
|
|
64
|
-
) => Promise<
|
|
65
|
+
) => Promise<BuiltDeltaOrder<TWAPDeltaOrder | TWAPBuyDeltaOrder>>;
|
|
65
66
|
|
|
66
|
-
export type
|
|
67
|
+
export type BuildTWAPDeltaOrderFunctions = {
|
|
67
68
|
/** @description Build a Delta v2 TWAP Order (sell or buy) from a DeltaRoute via the server endpoint, ready to sign and post. */
|
|
68
|
-
|
|
69
|
+
buildTWAPDeltaOrder: BuildTWAPDeltaOrder;
|
|
69
70
|
};
|
|
70
71
|
|
|
71
|
-
export const
|
|
72
|
+
export const constructBuildTWAPDeltaOrder = (
|
|
72
73
|
options: ConstructFetchInput
|
|
73
|
-
):
|
|
74
|
-
const { apiURL = API_URL,
|
|
74
|
+
): BuildTWAPDeltaOrderFunctions => {
|
|
75
|
+
const { apiURL = API_URL, fetcher } = options;
|
|
75
76
|
const buildUrl = `${apiURL}/delta/v2/orders/build` as const;
|
|
76
77
|
|
|
77
|
-
const
|
|
78
|
+
const buildTWAPDeltaOrder: BuildTWAPDeltaOrder = async (
|
|
78
79
|
params,
|
|
79
80
|
requestParams
|
|
80
81
|
) => {
|
|
81
82
|
const commonBody = {
|
|
82
|
-
chainId,
|
|
83
83
|
route: params.route,
|
|
84
84
|
owner: params.owner,
|
|
85
85
|
beneficiary: params.beneficiary,
|
|
@@ -100,7 +100,7 @@ export const constructBuildTWAPDeltaOrderV2 = (
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
if (params.onChainOrderType === 'TWAPOrder') {
|
|
103
|
-
return fetcher<
|
|
103
|
+
return fetcher<BuiltDeltaOrder<TWAPDeltaOrder>>({
|
|
104
104
|
url: buildUrl,
|
|
105
105
|
method: 'POST',
|
|
106
106
|
data: {
|
|
@@ -113,7 +113,7 @@ export const constructBuildTWAPDeltaOrderV2 = (
|
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
return fetcher<
|
|
116
|
+
return fetcher<BuiltDeltaOrder<TWAPBuyDeltaOrder>>({
|
|
117
117
|
url: buildUrl,
|
|
118
118
|
method: 'POST',
|
|
119
119
|
data: {
|
|
@@ -127,5 +127,5 @@ export const constructBuildTWAPDeltaOrderV2 = (
|
|
|
127
127
|
});
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
return {
|
|
130
|
+
return { buildTWAPDeltaOrder };
|
|
131
131
|
};
|
|
@@ -16,39 +16,39 @@ type CancelDeltaOrderRequestParams = {
|
|
|
16
16
|
signature: string;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export type
|
|
19
|
+
export type SignCancelDeltaOrderRequest = (
|
|
20
20
|
params: CancelDeltaOrderData,
|
|
21
21
|
requestParams?: RequestParameters
|
|
22
22
|
) => Promise<string>;
|
|
23
23
|
|
|
24
|
-
export type
|
|
24
|
+
export type PostCancelDeltaOrderRequest = (
|
|
25
25
|
params: CancelDeltaOrderRequestParams,
|
|
26
26
|
requestParams?: RequestParameters
|
|
27
27
|
) => Promise<SuccessResponse>;
|
|
28
28
|
|
|
29
|
-
export type
|
|
29
|
+
export type CancelDeltaOrder = (
|
|
30
30
|
params: CancelDeltaOrderData,
|
|
31
31
|
requestParams?: RequestParameters
|
|
32
32
|
) => Promise<SuccessResponse>;
|
|
33
33
|
|
|
34
|
-
export type
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
export type CancelDeltaOrderFunctions = {
|
|
35
|
+
signCancelDeltaOrderRequest: SignCancelDeltaOrderRequest;
|
|
36
|
+
postCancelDeltaOrderRequest: PostCancelDeltaOrderRequest;
|
|
37
37
|
/** @description Cancel one or more Delta orders via the v2 endpoint */
|
|
38
|
-
|
|
38
|
+
cancelDeltaOrders: CancelDeltaOrder;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
export const
|
|
41
|
+
export const constructCancelDeltaOrder = (
|
|
42
42
|
options: Pick<
|
|
43
43
|
ConstructProviderFetchInput<any, 'signTypedDataCall'>,
|
|
44
44
|
'contractCaller' | 'fetcher' | 'apiURL' | 'chainId'
|
|
45
45
|
>
|
|
46
|
-
):
|
|
46
|
+
): CancelDeltaOrderFunctions => {
|
|
47
47
|
const apiURL = options.apiURL ?? API_URL;
|
|
48
48
|
|
|
49
49
|
const { getDeltaContract } = constructGetDeltaContract(options);
|
|
50
50
|
|
|
51
|
-
const
|
|
51
|
+
const signCancelDeltaOrderRequest: SignCancelDeltaOrderRequest = async (
|
|
52
52
|
params,
|
|
53
53
|
requestParams
|
|
54
54
|
) => {
|
|
@@ -66,7 +66,7 @@ export const constructCancelDeltaOrderV2 = (
|
|
|
66
66
|
return options.contractCaller.signTypedDataCall(typedData);
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
const
|
|
69
|
+
const postCancelDeltaOrderRequest: PostCancelDeltaOrderRequest = async (
|
|
70
70
|
params,
|
|
71
71
|
requestParams
|
|
72
72
|
) => {
|
|
@@ -80,24 +80,21 @@ export const constructCancelDeltaOrderV2 = (
|
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
const
|
|
83
|
+
const cancelDeltaOrders: CancelDeltaOrder = async (
|
|
84
84
|
{ orderIds },
|
|
85
85
|
requestParams
|
|
86
86
|
) => {
|
|
87
|
-
const signature = await
|
|
87
|
+
const signature = await signCancelDeltaOrderRequest(
|
|
88
88
|
{ orderIds },
|
|
89
89
|
requestParams
|
|
90
90
|
);
|
|
91
91
|
|
|
92
|
-
return
|
|
93
|
-
{ orderIds, signature },
|
|
94
|
-
requestParams
|
|
95
|
-
);
|
|
92
|
+
return postCancelDeltaOrderRequest({ orderIds, signature }, requestParams);
|
|
96
93
|
};
|
|
97
94
|
|
|
98
95
|
return {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
signCancelDeltaOrderRequest,
|
|
97
|
+
postCancelDeltaOrderRequest,
|
|
98
|
+
cancelDeltaOrders,
|
|
102
99
|
};
|
|
103
100
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
3
|
+
|
|
4
|
+
export type AgentList = string[];
|
|
5
|
+
|
|
6
|
+
type AgentsListResponse = AgentList;
|
|
7
|
+
|
|
8
|
+
type GetAgentsList = (requestParams?: RequestParameters) => Promise<AgentList>;
|
|
9
|
+
|
|
10
|
+
export type GetAgentsListFunctions = {
|
|
11
|
+
/** @description List agents available on the current chain. */
|
|
12
|
+
getAgentsList: GetAgentsList;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const constructGetAgentsList = ({
|
|
16
|
+
apiURL = API_URL,
|
|
17
|
+
chainId,
|
|
18
|
+
fetcher,
|
|
19
|
+
}: ConstructFetchInput): GetAgentsListFunctions => {
|
|
20
|
+
const baseUrl = `${apiURL}/delta/v2/agents/list/${chainId}` as const;
|
|
21
|
+
|
|
22
|
+
const getAgentsList: GetAgentsList = async (requestParams) => {
|
|
23
|
+
const data = await fetcher<AgentsListResponse>({
|
|
24
|
+
url: baseUrl,
|
|
25
|
+
method: 'GET',
|
|
26
|
+
requestParams,
|
|
27
|
+
});
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return { getAgentsList };
|
|
32
|
+
};
|
|
@@ -23,19 +23,19 @@ type GetBridgeRoutes = (
|
|
|
23
23
|
requestParams?: RequestParameters
|
|
24
24
|
) => Promise<BridgeRoute[]>;
|
|
25
25
|
|
|
26
|
-
type
|
|
26
|
+
type GetBridgeProtocols = (
|
|
27
27
|
requestParams?: RequestParameters
|
|
28
28
|
) => Promise<BridgeProtocolResponse[]>;
|
|
29
29
|
|
|
30
|
-
type
|
|
30
|
+
type BridgeProtocolsResponse = {
|
|
31
31
|
bridgeProtocols: BridgeProtocolResponse[];
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export type GetBridgeRoutesFunctions = {
|
|
35
35
|
/** @description Fetch supported bridge routes as a flat array (v2 replacement for bridge-info). */
|
|
36
36
|
getBridgeRoutes: GetBridgeRoutes;
|
|
37
|
-
/** @description Fetch supported bridge protocols (
|
|
38
|
-
|
|
37
|
+
/** @description Fetch supported bridge protocols (unchanged from v1). */
|
|
38
|
+
getBridgeProtocols: GetBridgeProtocols;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export const constructGetBridgeRoutes = ({
|
|
@@ -66,10 +66,10 @@ export const constructGetBridgeRoutes = ({
|
|
|
66
66
|
return data.routes;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
const
|
|
69
|
+
const getBridgeProtocols: GetBridgeProtocols = async (requestParams) => {
|
|
70
70
|
const fetchURL = `${deltaPricesUrl}/bridge-protocols` as const;
|
|
71
71
|
|
|
72
|
-
const data = await fetcher<
|
|
72
|
+
const data = await fetcher<BridgeProtocolsResponse>({
|
|
73
73
|
url: fetchURL,
|
|
74
74
|
method: 'GET',
|
|
75
75
|
requestParams,
|
|
@@ -78,5 +78,5 @@ export const constructGetBridgeRoutes = ({
|
|
|
78
78
|
return data.bridgeProtocols;
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
return { getBridgeRoutes,
|
|
81
|
+
return { getBridgeRoutes, getBridgeProtocols };
|
|
82
82
|
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
3
|
+
import type {
|
|
4
|
+
Address,
|
|
5
|
+
ConstructFetchInput,
|
|
6
|
+
PaginatedResponse,
|
|
7
|
+
RequestParameters,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
import type { DeltaOrderType, OnChainOrderType } from '../delta/helpers/types';
|
|
10
|
+
import type { DeltaOrderStatus, DeltaAuction } from './types';
|
|
11
|
+
|
|
12
|
+
type GetDeltaOrderById = (
|
|
13
|
+
orderId: string,
|
|
14
|
+
requestParams?: RequestParameters
|
|
15
|
+
) => Promise<DeltaAuction>;
|
|
16
|
+
|
|
17
|
+
type GetDeltaOrderByHash = (
|
|
18
|
+
orderHash: string,
|
|
19
|
+
requestParams?: RequestParameters
|
|
20
|
+
) => Promise<DeltaAuction>;
|
|
21
|
+
|
|
22
|
+
type OrdersFilter = {
|
|
23
|
+
/** @description `order.owner` to fetch Delta Orders for. */
|
|
24
|
+
userAddress: Address;
|
|
25
|
+
/** @description Pagination option. Default 1. */
|
|
26
|
+
page?: number;
|
|
27
|
+
/** @description Pagination option. Default 100, max 1000. */
|
|
28
|
+
limit?: number;
|
|
29
|
+
/** @description Filter by chainId. Omitted = orders across all chains. */
|
|
30
|
+
chainId?: number[];
|
|
31
|
+
/** @description Filter by integrator-facing status. */
|
|
32
|
+
status?: DeltaOrderStatus[];
|
|
33
|
+
/** @description Filter by order type. MARKET or LIMIT. */
|
|
34
|
+
type?: DeltaOrderType;
|
|
35
|
+
/** @description Filter by on-chain order type. */
|
|
36
|
+
onChainOrderType?: OnChainOrderType;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type OrderFiltersQuery = Omit<OrdersFilter, 'chainId' | 'status'> & {
|
|
40
|
+
chainId?: string;
|
|
41
|
+
status?: string;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type GetDeltaOrders = (
|
|
45
|
+
options: OrdersFilter,
|
|
46
|
+
requestParams?: RequestParameters
|
|
47
|
+
) => Promise<PaginatedResponse<DeltaAuction>>;
|
|
48
|
+
|
|
49
|
+
type GetRequiredBalanceParams = {
|
|
50
|
+
userAddress: Address;
|
|
51
|
+
tokenAddress?: Address;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type GetRequiredBalance = (
|
|
55
|
+
userParams: GetRequiredBalanceParams,
|
|
56
|
+
requestParams?: RequestParameters
|
|
57
|
+
) => Promise<Record<string, string>>; // token -> required balance across open Delta orders
|
|
58
|
+
|
|
59
|
+
export type GetDeltaOrdersFunctions = {
|
|
60
|
+
/** @description Fetch a single order by its UUID. */
|
|
61
|
+
getDeltaOrderById: GetDeltaOrderById;
|
|
62
|
+
/** @description Fetch a single order by its EIP-712 order hash. */
|
|
63
|
+
getDeltaOrderByHash: GetDeltaOrderByHash;
|
|
64
|
+
/** @description List Delta orders with the v2 pagination envelope. */
|
|
65
|
+
getDeltaOrders: GetDeltaOrders;
|
|
66
|
+
/** @description Required balance per token across the user's open Delta v2 orders. Pass `tokenAddress` to narrow the result to a single token. */
|
|
67
|
+
getRequiredBalanceForDeltaOrders: GetRequiredBalance;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const constructGetDeltaOrders = ({
|
|
71
|
+
apiURL = API_URL,
|
|
72
|
+
fetcher,
|
|
73
|
+
chainId,
|
|
74
|
+
}: ConstructFetchInput): GetDeltaOrdersFunctions => {
|
|
75
|
+
const baseUrl = `${apiURL}/delta/v2/orders` as const;
|
|
76
|
+
|
|
77
|
+
const getDeltaOrderById: GetDeltaOrderById = async (
|
|
78
|
+
orderId,
|
|
79
|
+
requestParams
|
|
80
|
+
) => {
|
|
81
|
+
const fetchURL = `${baseUrl}/${orderId}` as const;
|
|
82
|
+
return fetcher<DeltaAuction>({
|
|
83
|
+
url: fetchURL,
|
|
84
|
+
method: 'GET',
|
|
85
|
+
requestParams,
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const getDeltaOrderByHash: GetDeltaOrderByHash = async (
|
|
90
|
+
orderHash,
|
|
91
|
+
requestParams
|
|
92
|
+
) => {
|
|
93
|
+
const fetchURL = `${baseUrl}/hash/${orderHash}` as const;
|
|
94
|
+
return fetcher<DeltaAuction>({
|
|
95
|
+
url: fetchURL,
|
|
96
|
+
method: 'GET',
|
|
97
|
+
requestParams,
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const getDeltaOrders: GetDeltaOrders = async (options, requestParams) => {
|
|
102
|
+
const chainIdString = options.chainId?.join(',');
|
|
103
|
+
const statusString = options.status?.join(',');
|
|
104
|
+
|
|
105
|
+
const search = constructSearchString<OrderFiltersQuery>({
|
|
106
|
+
userAddress: options.userAddress,
|
|
107
|
+
page: options.page,
|
|
108
|
+
limit: options.limit,
|
|
109
|
+
type: options.type,
|
|
110
|
+
onChainOrderType: options.onChainOrderType,
|
|
111
|
+
chainId: chainIdString,
|
|
112
|
+
status: statusString,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const fetchURL = `${baseUrl}${search}` as const;
|
|
116
|
+
|
|
117
|
+
return fetcher<PaginatedResponse<DeltaAuction>>({
|
|
118
|
+
url: fetchURL,
|
|
119
|
+
method: 'GET',
|
|
120
|
+
requestParams,
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const getRequiredBalanceForDeltaOrders: GetRequiredBalance = async (
|
|
125
|
+
userParams,
|
|
126
|
+
requestParams
|
|
127
|
+
) => {
|
|
128
|
+
const userURL =
|
|
129
|
+
`${baseUrl}/fillablebalance/${chainId}/${userParams.userAddress}` as const;
|
|
130
|
+
const fetchURL = userParams.tokenAddress
|
|
131
|
+
? (`${userURL}/${userParams.tokenAddress}` as const)
|
|
132
|
+
: userURL;
|
|
133
|
+
|
|
134
|
+
const response = await fetcher<Record<string, string>>({
|
|
135
|
+
url: fetchURL,
|
|
136
|
+
method: 'GET',
|
|
137
|
+
requestParams,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return response;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
getDeltaOrderById,
|
|
145
|
+
getDeltaOrderByHash,
|
|
146
|
+
getDeltaOrders,
|
|
147
|
+
getRequiredBalanceForDeltaOrders,
|
|
148
|
+
};
|
|
149
|
+
};
|
|
@@ -5,11 +5,11 @@ import type {
|
|
|
5
5
|
EnumerateLiteral,
|
|
6
6
|
RequestParameters,
|
|
7
7
|
} from '../../types';
|
|
8
|
-
import type {
|
|
8
|
+
import type { DeltaPrice } from './types';
|
|
9
9
|
|
|
10
10
|
type SwapSideUnion = EnumerateLiteral<typeof SwapSide>;
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type DeltaPriceParams = {
|
|
13
13
|
/** @description Source Token Address */
|
|
14
14
|
srcToken: string;
|
|
15
15
|
/** @description Destination Token Address. For Crosschain Orders, the destination token on the destination chain */
|
|
@@ -46,8 +46,8 @@ export type DeltaPriceV2Params = {
|
|
|
46
46
|
degenMode?: boolean;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
type
|
|
50
|
-
|
|
49
|
+
type DeltaPriceQueryOptions = Omit<
|
|
50
|
+
DeltaPriceParams,
|
|
51
51
|
'includeAgents' | 'excludeAgents' | 'includeBridges' | 'excludeBridges'
|
|
52
52
|
> & {
|
|
53
53
|
chainId: number;
|
|
@@ -57,24 +57,24 @@ type DeltaPriceV2QueryOptions = Omit<
|
|
|
57
57
|
excludeBridges?: string;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
type
|
|
61
|
-
options:
|
|
60
|
+
type GetDeltaPrice = (
|
|
61
|
+
options: DeltaPriceParams,
|
|
62
62
|
requestParams?: RequestParameters
|
|
63
|
-
) => Promise<
|
|
63
|
+
) => Promise<DeltaPrice>;
|
|
64
64
|
|
|
65
|
-
export type
|
|
65
|
+
export type GetDeltaPriceFunctions = {
|
|
66
66
|
/** @description Fetch a v2 price quote (route-based response). */
|
|
67
|
-
|
|
67
|
+
getDeltaPrice: GetDeltaPrice;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
export const
|
|
70
|
+
export const constructGetDeltaPrice = ({
|
|
71
71
|
apiURL = API_URL,
|
|
72
72
|
chainId,
|
|
73
73
|
fetcher,
|
|
74
|
-
}: ConstructFetchInput):
|
|
74
|
+
}: ConstructFetchInput): GetDeltaPriceFunctions => {
|
|
75
75
|
const pricesUrl = `${apiURL}/delta/v2/prices` as const;
|
|
76
76
|
|
|
77
|
-
const
|
|
77
|
+
const getDeltaPrice: GetDeltaPrice = async (options, requestParams) => {
|
|
78
78
|
const {
|
|
79
79
|
includeAgents,
|
|
80
80
|
excludeAgents,
|
|
@@ -83,7 +83,7 @@ export const constructGetDeltaPriceV2 = ({
|
|
|
83
83
|
...rest
|
|
84
84
|
} = options;
|
|
85
85
|
|
|
86
|
-
const search = constructSearchString<
|
|
86
|
+
const search = constructSearchString<DeltaPriceQueryOptions>({
|
|
87
87
|
...rest,
|
|
88
88
|
chainId,
|
|
89
89
|
side: options.side ?? SwapSide.SELL,
|
|
@@ -95,7 +95,7 @@ export const constructGetDeltaPriceV2 = ({
|
|
|
95
95
|
|
|
96
96
|
const fetchURL = `${pricesUrl}${search}` as const;
|
|
97
97
|
|
|
98
|
-
const data = await fetcher<
|
|
98
|
+
const data = await fetcher<DeltaPrice>({
|
|
99
99
|
url: fetchURL,
|
|
100
100
|
method: 'GET',
|
|
101
101
|
requestParams,
|
|
@@ -104,5 +104,5 @@ export const constructGetDeltaPriceV2 = ({
|
|
|
104
104
|
return data;
|
|
105
105
|
};
|
|
106
106
|
|
|
107
|
-
return {
|
|
107
|
+
return { getDeltaPrice };
|
|
108
108
|
};
|