@velora-dex/sdk 9.5.3 → 9.5.4-dev.0
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/examples/deltaV2.d.ts +2 -0
- package/dist/examples/deltaV2.d.ts.map +1 -0
- package/dist/examples/helpers/deltaV2.d.ts +5 -0
- package/dist/examples/helpers/deltaV2.d.ts.map +1 -0
- package/dist/examples/wagmi.d.ts.map +1 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/methods/delta/cancelDeltaOrder.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaOrders.d.ts +4 -4
- package/dist/methods/delta/getDeltaOrders.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaPrice.d.ts +1 -1
- package/dist/methods/delta/getDeltaPrice.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts +11 -4
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/methods/delta/postDeltaOrder.d.ts +3 -3
- package/dist/methods/delta/postDeltaOrder.d.ts.map +1 -1
- package/dist/methods/deltaV2/buildDeltaOrderV2.d.ts +44 -0
- package/dist/methods/deltaV2/buildDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/buildExternalDeltaOrderV2.d.ts +48 -0
- package/dist/methods/deltaV2/buildExternalDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/buildTWAPDeltaOrderV2.d.ts +59 -0
- package/dist/methods/deltaV2/buildTWAPDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/cancelDeltaOrderV2.d.ts +21 -0
- package/dist/methods/deltaV2/cancelDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/getAgentsListV2.d.ts +10 -0
- package/dist/methods/deltaV2/getAgentsListV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/getBridgeRoutes.d.ts +20 -0
- package/dist/methods/deltaV2/getBridgeRoutes.d.ts.map +1 -0
- package/dist/methods/deltaV2/getDeltaOrdersV2.d.ts +33 -0
- package/dist/methods/deltaV2/getDeltaOrdersV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/getDeltaPriceV2.d.ts +46 -0
- package/dist/methods/deltaV2/getDeltaPriceV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/index.d.ts +59 -0
- package/dist/methods/deltaV2/index.d.ts.map +1 -0
- package/dist/methods/deltaV2/isTokenSupportedInDeltaV2.d.ts +8 -0
- package/dist/methods/deltaV2/isTokenSupportedInDeltaV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/postDeltaOrderV2.d.ts +28 -0
- package/dist/methods/deltaV2/postDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/postExternalDeltaOrderV2.d.ts +11 -0
- package/dist/methods/deltaV2/postExternalDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/postTWAPDeltaOrderV2.d.ts +16 -0
- package/dist/methods/deltaV2/postTWAPDeltaOrderV2.d.ts.map +1 -0
- package/dist/methods/deltaV2/types.d.ts +163 -0
- package/dist/methods/deltaV2/types.d.ts.map +1 -0
- package/dist/sdk/full.d.ts +2 -0
- package/dist/sdk/full.d.ts.map +1 -1
- package/dist/sdk/simple.d.ts +10 -0
- package/dist/sdk/simple.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +1072 -242
- 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 +1056 -243
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/examples/deltaV2.ts +200 -0
- package/src/examples/helpers/deltaV2.ts +29 -0
- package/src/index.js +18 -0
- package/src/index.ts +148 -0
- package/src/methods/delta/cancelDeltaOrder.ts +4 -1
- package/src/methods/delta/getDeltaOrders.ts +6 -5
- package/src/methods/delta/getDeltaPrice.ts +1 -1
- package/src/methods/delta/helpers/types.ts +22 -12
- package/src/methods/delta/postDeltaOrder.ts +4 -4
- package/src/methods/delta/postTWAPDeltaOrder.ts +1 -1
- package/src/methods/deltaV2/buildDeltaOrderV2.ts +86 -0
- package/src/methods/deltaV2/buildExternalDeltaOrderV2.ts +95 -0
- package/src/methods/deltaV2/buildTWAPDeltaOrderV2.ts +131 -0
- package/src/methods/deltaV2/cancelDeltaOrderV2.ts +103 -0
- package/src/methods/deltaV2/getAgentsListV2.ts +34 -0
- package/src/methods/deltaV2/getBridgeRoutes.ts +82 -0
- package/src/methods/deltaV2/getDeltaOrdersV2.ts +119 -0
- package/src/methods/deltaV2/getDeltaPriceV2.ts +108 -0
- package/src/methods/deltaV2/index.ts +303 -0
- package/src/methods/deltaV2/isTokenSupportedInDeltaV2.ts +52 -0
- package/src/methods/deltaV2/postDeltaOrderV2.ts +65 -0
- package/src/methods/deltaV2/postExternalDeltaOrderV2.ts +45 -0
- package/src/methods/deltaV2/postTWAPDeltaOrderV2.ts +63 -0
- package/src/methods/deltaV2/types.ts +189 -0
- package/src/sdk/full.ts +8 -0
- package/src/sdk/simple.ts +56 -0
- package/src/types.ts +9 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { API_URL, SwapSide } from '../../constants';
|
|
2
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
3
|
+
import type {
|
|
4
|
+
ConstructFetchInput,
|
|
5
|
+
EnumerateLiteral,
|
|
6
|
+
RequestParameters,
|
|
7
|
+
} from '../../types';
|
|
8
|
+
import type { DeltaPriceV2 } from './types';
|
|
9
|
+
|
|
10
|
+
type SwapSideUnion = EnumerateLiteral<typeof SwapSide>;
|
|
11
|
+
|
|
12
|
+
export type DeltaPriceV2Params = {
|
|
13
|
+
/** @description Source Token Address */
|
|
14
|
+
srcToken: string;
|
|
15
|
+
/** @description Destination Token Address. For Crosschain Orders, the destination token on the destination chain */
|
|
16
|
+
destToken: string;
|
|
17
|
+
/** @description srcToken amount in wei */
|
|
18
|
+
amount: string;
|
|
19
|
+
/** @description Source Token Decimals */
|
|
20
|
+
srcDecimals: number;
|
|
21
|
+
/** @description Destination Token Decimals */
|
|
22
|
+
destDecimals: number;
|
|
23
|
+
/** @description User's Wallet Address */
|
|
24
|
+
userAddress?: string;
|
|
25
|
+
/** @description Beneficiary Address */
|
|
26
|
+
beneficiary?: string;
|
|
27
|
+
/** @description Partner string. */
|
|
28
|
+
partner?: string;
|
|
29
|
+
/** @description Partner fee in basis points (bps), 50bps=0.5% */
|
|
30
|
+
partnerFeeBps?: number;
|
|
31
|
+
/** @description Destination Chain ID for Crosschain Orders */
|
|
32
|
+
destChainId?: number;
|
|
33
|
+
/** @description SELL or BUY, default is SELL */
|
|
34
|
+
side?: SwapSideUnion;
|
|
35
|
+
/** @description In %. Bypasses the API price impact check (default = 15%) */
|
|
36
|
+
maxImpact?: number;
|
|
37
|
+
maxUSDImpact?: number;
|
|
38
|
+
|
|
39
|
+
includeAgents?: string[];
|
|
40
|
+
excludeAgents?: string[];
|
|
41
|
+
includeBridges?: string[];
|
|
42
|
+
excludeBridges?: string[];
|
|
43
|
+
|
|
44
|
+
/** @description Allow swap on destChain after bridge. Default is true. */
|
|
45
|
+
allowBridgeAndSwap?: boolean;
|
|
46
|
+
degenMode?: boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type DeltaPriceV2QueryOptions = Omit<
|
|
50
|
+
DeltaPriceV2Params,
|
|
51
|
+
'includeAgents' | 'excludeAgents' | 'includeBridges' | 'excludeBridges'
|
|
52
|
+
> & {
|
|
53
|
+
chainId: number;
|
|
54
|
+
includeAgents?: string;
|
|
55
|
+
excludeAgents?: string;
|
|
56
|
+
includeBridges?: string;
|
|
57
|
+
excludeBridges?: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type GetDeltaPriceV2 = (
|
|
61
|
+
options: DeltaPriceV2Params,
|
|
62
|
+
requestParams?: RequestParameters
|
|
63
|
+
) => Promise<DeltaPriceV2>;
|
|
64
|
+
|
|
65
|
+
export type GetDeltaPriceV2Functions = {
|
|
66
|
+
/** @description Fetch a v2 price quote (route-based response). */
|
|
67
|
+
getDeltaPriceV2: GetDeltaPriceV2;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const constructGetDeltaPriceV2 = ({
|
|
71
|
+
apiURL = API_URL,
|
|
72
|
+
chainId,
|
|
73
|
+
fetcher,
|
|
74
|
+
}: ConstructFetchInput): GetDeltaPriceV2Functions => {
|
|
75
|
+
const pricesUrl = `${apiURL}/delta/v2/prices` as const;
|
|
76
|
+
|
|
77
|
+
const getDeltaPriceV2: GetDeltaPriceV2 = async (options, requestParams) => {
|
|
78
|
+
const {
|
|
79
|
+
includeAgents,
|
|
80
|
+
excludeAgents,
|
|
81
|
+
includeBridges,
|
|
82
|
+
excludeBridges,
|
|
83
|
+
...rest
|
|
84
|
+
} = options;
|
|
85
|
+
|
|
86
|
+
const search = constructSearchString<DeltaPriceV2QueryOptions>({
|
|
87
|
+
...rest,
|
|
88
|
+
chainId,
|
|
89
|
+
side: options.side ?? SwapSide.SELL,
|
|
90
|
+
includeAgents: includeAgents?.join(','),
|
|
91
|
+
excludeAgents: excludeAgents?.join(','),
|
|
92
|
+
includeBridges: includeBridges?.join(','),
|
|
93
|
+
excludeBridges: excludeBridges?.join(','),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const fetchURL = `${pricesUrl}${search}` as const;
|
|
97
|
+
|
|
98
|
+
const data = await fetcher<DeltaPriceV2>({
|
|
99
|
+
url: fetchURL,
|
|
100
|
+
method: 'GET',
|
|
101
|
+
requestParams,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return data;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return { getDeltaPriceV2 };
|
|
108
|
+
};
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import type { ConstructProviderFetchInput } from '../../types';
|
|
2
|
+
import type { DeltaAuction, OnChainOrderMap } from '../delta/helpers/types';
|
|
3
|
+
|
|
4
|
+
// reused v1 modules
|
|
5
|
+
import {
|
|
6
|
+
GetDeltaContractFunctions,
|
|
7
|
+
constructGetDeltaContract,
|
|
8
|
+
} from '../delta/getDeltaContract';
|
|
9
|
+
import {
|
|
10
|
+
constructGetPartnerFee,
|
|
11
|
+
GetPartnerFeeFunctions,
|
|
12
|
+
} from '../delta/getPartnerFee';
|
|
13
|
+
import {
|
|
14
|
+
ApproveTokenForDeltaFunctions,
|
|
15
|
+
constructApproveTokenForDelta,
|
|
16
|
+
} from '../delta/approveForDelta';
|
|
17
|
+
import {
|
|
18
|
+
constructPreSignDeltaOrder,
|
|
19
|
+
PreSignDeltaOrderFunctions,
|
|
20
|
+
} from '../delta/preSignDeltaOrder';
|
|
21
|
+
import {
|
|
22
|
+
constructPreSignExternalDeltaOrder,
|
|
23
|
+
PreSignExternalDeltaOrderFunctions,
|
|
24
|
+
} from '../delta/preSignExternalDeltaOrder';
|
|
25
|
+
import {
|
|
26
|
+
constructPreSignTWAPDeltaOrder,
|
|
27
|
+
PreSignTWAPDeltaOrderFunctions,
|
|
28
|
+
} from '../delta/preSignTWAPDeltaOrder';
|
|
29
|
+
import {
|
|
30
|
+
DeltaTokenModuleFunctions,
|
|
31
|
+
constructDeltaTokenModule,
|
|
32
|
+
} from '../delta/deltaTokenModule';
|
|
33
|
+
|
|
34
|
+
// new v2 modules
|
|
35
|
+
import {
|
|
36
|
+
BuildDeltaOrderV2Functions,
|
|
37
|
+
BuildDeltaOrderV2Params,
|
|
38
|
+
BuiltDeltaOrderV2,
|
|
39
|
+
constructBuildDeltaOrderV2,
|
|
40
|
+
} from './buildDeltaOrderV2';
|
|
41
|
+
import {
|
|
42
|
+
BuildExternalDeltaOrderV2Functions,
|
|
43
|
+
BuildExternalDeltaOrderV2Params,
|
|
44
|
+
constructBuildExternalDeltaOrderV2,
|
|
45
|
+
} from './buildExternalDeltaOrderV2';
|
|
46
|
+
import {
|
|
47
|
+
BuildTWAPDeltaOrderV2Functions,
|
|
48
|
+
BuildTWAPDeltaOrderV2Params,
|
|
49
|
+
constructBuildTWAPDeltaOrderV2,
|
|
50
|
+
} from './buildTWAPDeltaOrderV2';
|
|
51
|
+
import {
|
|
52
|
+
constructPostDeltaOrderV2,
|
|
53
|
+
DeltaOrderToPostV2,
|
|
54
|
+
PostDeltaOrderV2Functions,
|
|
55
|
+
} from './postDeltaOrderV2';
|
|
56
|
+
import {
|
|
57
|
+
constructPostExternalDeltaOrderV2,
|
|
58
|
+
PostExternalDeltaOrderV2Functions,
|
|
59
|
+
} from './postExternalDeltaOrderV2';
|
|
60
|
+
import {
|
|
61
|
+
constructPostTWAPDeltaOrderV2,
|
|
62
|
+
PostTWAPDeltaOrderV2Functions,
|
|
63
|
+
} from './postTWAPDeltaOrderV2';
|
|
64
|
+
import {
|
|
65
|
+
constructGetDeltaPriceV2,
|
|
66
|
+
GetDeltaPriceV2Functions,
|
|
67
|
+
} from './getDeltaPriceV2';
|
|
68
|
+
import {
|
|
69
|
+
constructGetDeltaOrdersV2,
|
|
70
|
+
GetDeltaOrdersV2Functions,
|
|
71
|
+
} from './getDeltaOrdersV2';
|
|
72
|
+
import {
|
|
73
|
+
constructGetBridgeRoutes,
|
|
74
|
+
GetBridgeRoutesFunctions,
|
|
75
|
+
} from './getBridgeRoutes';
|
|
76
|
+
import {
|
|
77
|
+
constructIsTokenSupportedInDeltaV2,
|
|
78
|
+
IsTokenSupportedInDeltaV2Functions,
|
|
79
|
+
} from './isTokenSupportedInDeltaV2';
|
|
80
|
+
import {
|
|
81
|
+
CancelDeltaOrderV2Functions,
|
|
82
|
+
constructCancelDeltaOrderV2,
|
|
83
|
+
} from './cancelDeltaOrderV2';
|
|
84
|
+
import {
|
|
85
|
+
constructGetAgentsListV2,
|
|
86
|
+
GetAgentsListV2Functions,
|
|
87
|
+
} from './getAgentsListV2';
|
|
88
|
+
|
|
89
|
+
// ── Sign v2 ─────────────────────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
type SignDeltaOrderV2 = (builtOrder: BuiltDeltaOrderV2) => Promise<string>;
|
|
92
|
+
|
|
93
|
+
export type SignDeltaOrderV2Functions = {
|
|
94
|
+
/** @description Sign a BuiltDeltaOrderV2 (any order type) using EIP-712 typed data. */
|
|
95
|
+
signDeltaOrderV2: SignDeltaOrderV2;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const constructSignDeltaOrderV2 = (
|
|
99
|
+
options: Pick<
|
|
100
|
+
ConstructProviderFetchInput<any, 'signTypedDataCall'>,
|
|
101
|
+
'contractCaller'
|
|
102
|
+
>
|
|
103
|
+
): SignDeltaOrderV2Functions => {
|
|
104
|
+
const signDeltaOrderV2: SignDeltaOrderV2 = async (builtOrder) => {
|
|
105
|
+
return options.contractCaller.signTypedDataCall({
|
|
106
|
+
types: builtOrder.toSign.types,
|
|
107
|
+
domain: builtOrder.toSign.domain,
|
|
108
|
+
data: builtOrder.toSign.value,
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return { signDeltaOrderV2 };
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// ── Submit orchestrators ─────────────────────────────────────────────────────
|
|
115
|
+
|
|
116
|
+
export type SubmitDeltaOrderV2Params = BuildDeltaOrderV2Params & {
|
|
117
|
+
/** @description Referrer address */
|
|
118
|
+
referrerAddress?: string;
|
|
119
|
+
degenMode?: boolean;
|
|
120
|
+
} & Pick<DeltaOrderToPostV2, 'type' | 'includeAgents' | 'excludeAgents'>;
|
|
121
|
+
|
|
122
|
+
type SubmitDeltaOrderV2 = (
|
|
123
|
+
orderParams: SubmitDeltaOrderV2Params
|
|
124
|
+
) => Promise<DeltaAuction<'Order'>>;
|
|
125
|
+
|
|
126
|
+
export type SubmitDeltaOrderV2Funcs = {
|
|
127
|
+
submitDeltaOrderV2: SubmitDeltaOrderV2;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const constructSubmitDeltaOrderV2 = (
|
|
131
|
+
options: ConstructProviderFetchInput<any, 'signTypedDataCall'>
|
|
132
|
+
): SubmitDeltaOrderV2Funcs => {
|
|
133
|
+
const { buildDeltaOrderV2 } = constructBuildDeltaOrderV2(options);
|
|
134
|
+
const { signDeltaOrderV2 } = constructSignDeltaOrderV2(options);
|
|
135
|
+
const { postDeltaOrderV2 } = constructPostDeltaOrderV2(options);
|
|
136
|
+
|
|
137
|
+
const submitDeltaOrderV2: SubmitDeltaOrderV2 = async (orderParams) => {
|
|
138
|
+
const orderData = await buildDeltaOrderV2(orderParams);
|
|
139
|
+
const signature = await signDeltaOrderV2(orderData);
|
|
140
|
+
|
|
141
|
+
return postDeltaOrderV2({
|
|
142
|
+
signature,
|
|
143
|
+
partner: orderParams.partner,
|
|
144
|
+
order: orderData.toSign.value as OnChainOrderMap['Order'],
|
|
145
|
+
partiallyFillable: orderParams.partiallyFillable,
|
|
146
|
+
referrerAddress: orderParams.referrerAddress,
|
|
147
|
+
type: orderParams.type,
|
|
148
|
+
includeAgents: orderParams.includeAgents,
|
|
149
|
+
excludeAgents: orderParams.excludeAgents,
|
|
150
|
+
degenMode: orderParams.degenMode,
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return { submitDeltaOrderV2 };
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type SubmitExternalDeltaOrderV2Params =
|
|
158
|
+
BuildExternalDeltaOrderV2Params & {
|
|
159
|
+
referrerAddress?: string;
|
|
160
|
+
} & Pick<DeltaOrderToPostV2, 'type' | 'includeAgents' | 'excludeAgents'>;
|
|
161
|
+
|
|
162
|
+
type SubmitExternalDeltaOrderV2 = (
|
|
163
|
+
orderParams: SubmitExternalDeltaOrderV2Params
|
|
164
|
+
) => Promise<DeltaAuction<'ExternalOrder'>>;
|
|
165
|
+
|
|
166
|
+
export type SubmitExternalDeltaOrderV2Funcs = {
|
|
167
|
+
submitExternalDeltaOrderV2: SubmitExternalDeltaOrderV2;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const constructSubmitExternalDeltaOrderV2 = (
|
|
171
|
+
options: ConstructProviderFetchInput<any, 'signTypedDataCall'>
|
|
172
|
+
): SubmitExternalDeltaOrderV2Funcs => {
|
|
173
|
+
const { buildExternalDeltaOrderV2 } =
|
|
174
|
+
constructBuildExternalDeltaOrderV2(options);
|
|
175
|
+
const { signDeltaOrderV2 } = constructSignDeltaOrderV2(options);
|
|
176
|
+
const { postExternalDeltaOrderV2 } =
|
|
177
|
+
constructPostExternalDeltaOrderV2(options);
|
|
178
|
+
|
|
179
|
+
const submitExternalDeltaOrderV2: SubmitExternalDeltaOrderV2 = async (
|
|
180
|
+
orderParams
|
|
181
|
+
) => {
|
|
182
|
+
const orderData = await buildExternalDeltaOrderV2(orderParams);
|
|
183
|
+
const signature = await signDeltaOrderV2(orderData);
|
|
184
|
+
|
|
185
|
+
return postExternalDeltaOrderV2({
|
|
186
|
+
signature,
|
|
187
|
+
partner: orderParams.partner,
|
|
188
|
+
order: orderData.toSign.value as OnChainOrderMap['ExternalOrder'],
|
|
189
|
+
partiallyFillable: orderParams.partiallyFillable,
|
|
190
|
+
referrerAddress: orderParams.referrerAddress,
|
|
191
|
+
type: orderParams.type,
|
|
192
|
+
includeAgents: orderParams.includeAgents,
|
|
193
|
+
excludeAgents: orderParams.excludeAgents,
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
return { submitExternalDeltaOrderV2 };
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export type SubmitTWAPDeltaOrderV2Params = BuildTWAPDeltaOrderV2Params & {
|
|
201
|
+
referrerAddress?: string;
|
|
202
|
+
degenMode?: boolean;
|
|
203
|
+
} & Pick<DeltaOrderToPostV2, 'type' | 'includeAgents' | 'excludeAgents'>;
|
|
204
|
+
|
|
205
|
+
type SubmitTWAPDeltaOrderV2 = (
|
|
206
|
+
orderParams: SubmitTWAPDeltaOrderV2Params
|
|
207
|
+
) => Promise<DeltaAuction<'TWAPOrder'> | DeltaAuction<'TWAPBuyOrder'>>;
|
|
208
|
+
|
|
209
|
+
export type SubmitTWAPDeltaOrderV2Funcs = {
|
|
210
|
+
submitTWAPDeltaOrderV2: SubmitTWAPDeltaOrderV2;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export const constructSubmitTWAPDeltaOrderV2 = (
|
|
214
|
+
options: ConstructProviderFetchInput<any, 'signTypedDataCall'>
|
|
215
|
+
): SubmitTWAPDeltaOrderV2Funcs => {
|
|
216
|
+
const { buildTWAPDeltaOrderV2 } = constructBuildTWAPDeltaOrderV2(options);
|
|
217
|
+
const { signDeltaOrderV2 } = constructSignDeltaOrderV2(options);
|
|
218
|
+
const { postTWAPDeltaOrderV2 } = constructPostTWAPDeltaOrderV2(options);
|
|
219
|
+
|
|
220
|
+
const submitTWAPDeltaOrderV2: SubmitTWAPDeltaOrderV2 = async (
|
|
221
|
+
orderParams
|
|
222
|
+
) => {
|
|
223
|
+
const orderData = await buildTWAPDeltaOrderV2(orderParams);
|
|
224
|
+
const signature = await signDeltaOrderV2(orderData);
|
|
225
|
+
|
|
226
|
+
return postTWAPDeltaOrderV2({
|
|
227
|
+
signature,
|
|
228
|
+
partner: orderParams.partner,
|
|
229
|
+
order: orderData.toSign.value as
|
|
230
|
+
| OnChainOrderMap['TWAPOrder']
|
|
231
|
+
| OnChainOrderMap['TWAPBuyOrder'],
|
|
232
|
+
onChainOrderType: orderParams.onChainOrderType,
|
|
233
|
+
partiallyFillable: orderParams.partiallyFillable,
|
|
234
|
+
referrerAddress: orderParams.referrerAddress,
|
|
235
|
+
type: orderParams.type,
|
|
236
|
+
includeAgents: orderParams.includeAgents,
|
|
237
|
+
excludeAgents: orderParams.excludeAgents,
|
|
238
|
+
degenMode: orderParams.degenMode,
|
|
239
|
+
});
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
return { submitTWAPDeltaOrderV2 };
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// ── Handler bundle ───────────────────────────────────────────────────────────
|
|
246
|
+
|
|
247
|
+
export type DeltaV2OrderHandlers<TxResponse> = SubmitDeltaOrderV2Funcs &
|
|
248
|
+
SubmitExternalDeltaOrderV2Funcs &
|
|
249
|
+
SubmitTWAPDeltaOrderV2Funcs &
|
|
250
|
+
BuildDeltaOrderV2Functions &
|
|
251
|
+
BuildExternalDeltaOrderV2Functions &
|
|
252
|
+
BuildTWAPDeltaOrderV2Functions &
|
|
253
|
+
PostDeltaOrderV2Functions &
|
|
254
|
+
PostExternalDeltaOrderV2Functions &
|
|
255
|
+
PostTWAPDeltaOrderV2Functions &
|
|
256
|
+
SignDeltaOrderV2Functions &
|
|
257
|
+
PreSignDeltaOrderFunctions<TxResponse> &
|
|
258
|
+
PreSignExternalDeltaOrderFunctions<TxResponse> &
|
|
259
|
+
PreSignTWAPDeltaOrderFunctions<TxResponse> &
|
|
260
|
+
GetDeltaPriceV2Functions &
|
|
261
|
+
GetDeltaOrdersV2Functions &
|
|
262
|
+
GetBridgeRoutesFunctions &
|
|
263
|
+
IsTokenSupportedInDeltaV2Functions &
|
|
264
|
+
GetAgentsListV2Functions &
|
|
265
|
+
GetDeltaContractFunctions &
|
|
266
|
+
GetPartnerFeeFunctions &
|
|
267
|
+
ApproveTokenForDeltaFunctions<TxResponse> &
|
|
268
|
+
DeltaTokenModuleFunctions<TxResponse> &
|
|
269
|
+
CancelDeltaOrderV2Functions;
|
|
270
|
+
|
|
271
|
+
/** @description Construct an SDK bundle exposing every Delta v2 method (queries, build/sign/post, on-chain helpers). */
|
|
272
|
+
export const constructAllDeltaV2OrdersHandlers = <TxResponse>(
|
|
273
|
+
options: ConstructProviderFetchInput<
|
|
274
|
+
TxResponse,
|
|
275
|
+
'signTypedDataCall' | 'transactCall'
|
|
276
|
+
>
|
|
277
|
+
): DeltaV2OrderHandlers<TxResponse> => {
|
|
278
|
+
return {
|
|
279
|
+
...constructSubmitDeltaOrderV2(options),
|
|
280
|
+
...constructSubmitExternalDeltaOrderV2(options),
|
|
281
|
+
...constructSubmitTWAPDeltaOrderV2(options),
|
|
282
|
+
...constructBuildDeltaOrderV2(options),
|
|
283
|
+
...constructBuildExternalDeltaOrderV2(options),
|
|
284
|
+
...constructBuildTWAPDeltaOrderV2(options),
|
|
285
|
+
...constructPostDeltaOrderV2(options),
|
|
286
|
+
...constructPostExternalDeltaOrderV2(options),
|
|
287
|
+
...constructPostTWAPDeltaOrderV2(options),
|
|
288
|
+
...constructSignDeltaOrderV2(options),
|
|
289
|
+
...constructPreSignDeltaOrder(options),
|
|
290
|
+
...constructPreSignExternalDeltaOrder(options),
|
|
291
|
+
...constructPreSignTWAPDeltaOrder(options),
|
|
292
|
+
...constructGetDeltaPriceV2(options),
|
|
293
|
+
...constructGetDeltaOrdersV2(options),
|
|
294
|
+
...constructGetBridgeRoutes(options),
|
|
295
|
+
...constructIsTokenSupportedInDeltaV2(options),
|
|
296
|
+
...constructGetAgentsListV2(options),
|
|
297
|
+
...constructGetDeltaContract(options),
|
|
298
|
+
...constructGetPartnerFee(options),
|
|
299
|
+
...constructApproveTokenForDelta(options),
|
|
300
|
+
...constructDeltaTokenModule(options),
|
|
301
|
+
...constructCancelDeltaOrderV2(options),
|
|
302
|
+
};
|
|
303
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
3
|
+
import type {
|
|
4
|
+
Address,
|
|
5
|
+
ConstructFetchInput,
|
|
6
|
+
RequestParameters,
|
|
7
|
+
} from '../../types';
|
|
8
|
+
|
|
9
|
+
type TokenSupportedResponse = { supported: boolean };
|
|
10
|
+
type IsTokenSupportedQuery = {
|
|
11
|
+
token: Address;
|
|
12
|
+
chainId: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type IsTokenSupportedInDeltaV2 = (
|
|
16
|
+
token: Address,
|
|
17
|
+
requestParams?: RequestParameters
|
|
18
|
+
) => Promise<boolean>;
|
|
19
|
+
|
|
20
|
+
export type IsTokenSupportedInDeltaV2Functions = {
|
|
21
|
+
isTokenSupportedInDeltaV2: IsTokenSupportedInDeltaV2;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const constructIsTokenSupportedInDeltaV2 = ({
|
|
25
|
+
apiURL = API_URL,
|
|
26
|
+
chainId,
|
|
27
|
+
fetcher,
|
|
28
|
+
}: ConstructFetchInput): IsTokenSupportedInDeltaV2Functions => {
|
|
29
|
+
const baseUrl = `${apiURL}/delta/v2/prices/is-token-supported` as const;
|
|
30
|
+
|
|
31
|
+
const isTokenSupportedInDeltaV2: IsTokenSupportedInDeltaV2 = async (
|
|
32
|
+
token,
|
|
33
|
+
requestParams
|
|
34
|
+
) => {
|
|
35
|
+
const search = constructSearchString<IsTokenSupportedQuery>({
|
|
36
|
+
token,
|
|
37
|
+
chainId,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const fetchURL = `${baseUrl}/${search}` as const;
|
|
41
|
+
|
|
42
|
+
const data = await fetcher<TokenSupportedResponse>({
|
|
43
|
+
url: fetchURL,
|
|
44
|
+
method: 'GET',
|
|
45
|
+
requestParams,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return data.supported;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return { isTokenSupportedInDeltaV2 };
|
|
52
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
3
|
+
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
4
|
+
import type {
|
|
5
|
+
DeltaAuction,
|
|
6
|
+
DeltaOrderType,
|
|
7
|
+
OnChainOrderMap,
|
|
8
|
+
} from '../delta/helpers/types';
|
|
9
|
+
|
|
10
|
+
export type DeltaOrderToPostV2<T extends keyof OnChainOrderMap = 'Order'> = {
|
|
11
|
+
/** @description Partner string */
|
|
12
|
+
partner?: string;
|
|
13
|
+
/** @description Referrer address */
|
|
14
|
+
referrerAddress?: string;
|
|
15
|
+
order: OnChainOrderMap[T];
|
|
16
|
+
/** @description Signature of the order from order.owner address. EOA signatures must be submitted in ERC-2098 Compact Representation. */
|
|
17
|
+
signature: string;
|
|
18
|
+
chainId: number;
|
|
19
|
+
/** @description Designates the Order as being able to be partially filled, as opposed to fill-or-kill */
|
|
20
|
+
partiallyFillable?: boolean;
|
|
21
|
+
/** @description Type of the order. MARKET or LIMIT. Default is MARKET */
|
|
22
|
+
type?: DeltaOrderType;
|
|
23
|
+
includeAgents?: string[];
|
|
24
|
+
excludeAgents?: string[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type PostDeltaOrderV2Params = Omit<DeltaOrderToPostV2, 'chainId'> & {
|
|
28
|
+
degenMode?: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type PostDeltaOrderV2 = (
|
|
32
|
+
postData: PostDeltaOrderV2Params,
|
|
33
|
+
requestParams?: RequestParameters
|
|
34
|
+
) => Promise<DeltaAuction<'Order'>>;
|
|
35
|
+
|
|
36
|
+
export type PostDeltaOrderV2Functions = {
|
|
37
|
+
postDeltaOrderV2: PostDeltaOrderV2;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const constructPostDeltaOrderV2 = ({
|
|
41
|
+
apiURL = API_URL,
|
|
42
|
+
chainId,
|
|
43
|
+
fetcher,
|
|
44
|
+
}: ConstructFetchInput): PostDeltaOrderV2Functions => {
|
|
45
|
+
const postOrderUrl = `${apiURL}/delta/v2/orders` as const;
|
|
46
|
+
|
|
47
|
+
const postDeltaOrderV2: PostDeltaOrderV2 = (_postData, requestParams) => {
|
|
48
|
+
const { degenMode, ...postData } = _postData;
|
|
49
|
+
const deltaOrderToPost: DeltaOrderToPostV2 = { ...postData, chainId };
|
|
50
|
+
|
|
51
|
+
const search = constructSearchString<{ degenMode?: boolean }>({
|
|
52
|
+
degenMode,
|
|
53
|
+
});
|
|
54
|
+
const fetchURL = `${postOrderUrl}${search}` as const;
|
|
55
|
+
|
|
56
|
+
return fetcher<DeltaAuction<'Order'>>({
|
|
57
|
+
url: fetchURL,
|
|
58
|
+
method: 'POST',
|
|
59
|
+
data: deltaOrderToPost,
|
|
60
|
+
requestParams,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return { postDeltaOrderV2 };
|
|
65
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { API_URL } from '../../constants';
|
|
2
|
+
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
3
|
+
import type { DeltaAuction } from '../delta/helpers/types';
|
|
4
|
+
import type { DeltaOrderToPostV2 } from './postDeltaOrderV2';
|
|
5
|
+
|
|
6
|
+
export type PostExternalDeltaOrderV2Params = Omit<
|
|
7
|
+
DeltaOrderToPostV2<'ExternalOrder'>,
|
|
8
|
+
'chainId'
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
type PostExternalDeltaOrderV2 = (
|
|
12
|
+
postData: PostExternalDeltaOrderV2Params,
|
|
13
|
+
requestParams?: RequestParameters
|
|
14
|
+
) => Promise<DeltaAuction<'ExternalOrder'>>;
|
|
15
|
+
|
|
16
|
+
export type PostExternalDeltaOrderV2Functions = {
|
|
17
|
+
postExternalDeltaOrderV2: PostExternalDeltaOrderV2;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const constructPostExternalDeltaOrderV2 = ({
|
|
21
|
+
apiURL = API_URL,
|
|
22
|
+
chainId,
|
|
23
|
+
fetcher,
|
|
24
|
+
}: ConstructFetchInput): PostExternalDeltaOrderV2Functions => {
|
|
25
|
+
const postOrderUrl = `${apiURL}/delta/v2/orders` as const;
|
|
26
|
+
|
|
27
|
+
const postExternalDeltaOrderV2: PostExternalDeltaOrderV2 = (
|
|
28
|
+
postData,
|
|
29
|
+
requestParams
|
|
30
|
+
) => {
|
|
31
|
+
const deltaOrderToPost: DeltaOrderToPostV2<'ExternalOrder'> = {
|
|
32
|
+
...postData,
|
|
33
|
+
chainId,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return fetcher<DeltaAuction<'ExternalOrder'>>({
|
|
37
|
+
url: postOrderUrl,
|
|
38
|
+
method: 'POST',
|
|
39
|
+
data: deltaOrderToPost,
|
|
40
|
+
requestParams,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return { postExternalDeltaOrderV2 };
|
|
45
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Prettify } from 'ts-essentials';
|
|
2
|
+
import { API_URL } from '../../constants';
|
|
3
|
+
import { constructSearchString } from '../../helpers/misc';
|
|
4
|
+
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
5
|
+
import type {
|
|
6
|
+
DeltaAuction,
|
|
7
|
+
TWAPOnChainOrderType,
|
|
8
|
+
} from '../delta/helpers/types';
|
|
9
|
+
import type { DeltaOrderToPostV2 } from './postDeltaOrderV2';
|
|
10
|
+
|
|
11
|
+
export type PostTWAPDeltaOrderV2Params = Prettify<
|
|
12
|
+
Omit<
|
|
13
|
+
DeltaOrderToPostV2<'TWAPOrder'> | DeltaOrderToPostV2<'TWAPBuyOrder'>,
|
|
14
|
+
'chainId'
|
|
15
|
+
> & {
|
|
16
|
+
/** @description Must be "TWAPOrder" or "TWAPBuyOrder" */
|
|
17
|
+
onChainOrderType: TWAPOnChainOrderType;
|
|
18
|
+
degenMode?: boolean;
|
|
19
|
+
}
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
type PostTWAPDeltaOrderV2 = (
|
|
23
|
+
postData: PostTWAPDeltaOrderV2Params,
|
|
24
|
+
requestParams?: RequestParameters
|
|
25
|
+
) => Promise<DeltaAuction<'TWAPOrder'> | DeltaAuction<'TWAPBuyOrder'>>;
|
|
26
|
+
|
|
27
|
+
export type PostTWAPDeltaOrderV2Functions = {
|
|
28
|
+
postTWAPDeltaOrderV2: PostTWAPDeltaOrderV2;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const constructPostTWAPDeltaOrderV2 = ({
|
|
32
|
+
apiURL = API_URL,
|
|
33
|
+
chainId,
|
|
34
|
+
fetcher,
|
|
35
|
+
}: ConstructFetchInput): PostTWAPDeltaOrderV2Functions => {
|
|
36
|
+
const postOrderUrl = `${apiURL}/delta/v2/orders` as const;
|
|
37
|
+
|
|
38
|
+
const postTWAPDeltaOrderV2: PostTWAPDeltaOrderV2 = (
|
|
39
|
+
_postData,
|
|
40
|
+
requestParams
|
|
41
|
+
) => {
|
|
42
|
+
const { degenMode, ...postData } = _postData;
|
|
43
|
+
const deltaOrderToPost: DeltaOrderToPostV2<'TWAPOrder' | 'TWAPBuyOrder'> = {
|
|
44
|
+
...postData,
|
|
45
|
+
chainId,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const search = constructSearchString<{ degenMode?: boolean }>({
|
|
49
|
+
degenMode,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const fetchURL = `${postOrderUrl}${search}` as const;
|
|
53
|
+
|
|
54
|
+
return fetcher<DeltaAuction<'TWAPOrder'> | DeltaAuction<'TWAPBuyOrder'>>({
|
|
55
|
+
url: fetchURL,
|
|
56
|
+
method: 'POST',
|
|
57
|
+
data: deltaOrderToPost,
|
|
58
|
+
requestParams,
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return { postTWAPDeltaOrderV2 };
|
|
63
|
+
};
|