@velora-dex/sdk 8.1.1-dev.2 → 9.1.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/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/methods/common/orders/types.d.ts +0 -2
- package/dist/methods/common/orders/types.d.ts.map +1 -1
- package/dist/methods/delta/buildDeltaOrder.d.ts +3 -5
- package/dist/methods/delta/buildDeltaOrder.d.ts.map +1 -1
- package/dist/methods/delta/cancelDeltaOrder.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaOrders.d.ts +15 -4
- package/dist/methods/delta/getDeltaOrders.d.ts.map +1 -1
- package/dist/methods/delta/getDeltaPrice.d.ts +15 -0
- package/dist/methods/delta/getDeltaPrice.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts +1 -1
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/methods/delta/index.d.ts +1 -3
- package/dist/methods/delta/index.d.ts.map +1 -1
- package/dist/methods/limitOrders/helpers/types.d.ts +2 -4
- package/dist/methods/limitOrders/helpers/types.d.ts.map +1 -1
- package/dist/methods/nftOrders/helpers/types.d.ts +2 -4
- package/dist/methods/nftOrders/helpers/types.d.ts.map +1 -1
- package/dist/sdk/simple.d.ts +1 -3
- package/dist/sdk/simple.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +33 -115
- 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 +34 -114
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -18
- package/src/methods/common/orders/types.ts +0 -7
- package/src/methods/delta/buildDeltaOrder.ts +37 -23
- package/src/methods/delta/cancelDeltaOrder.ts +1 -1
- package/src/methods/delta/getDeltaOrders.ts +31 -6
- package/src/methods/delta/getDeltaPrice.ts +28 -0
- package/src/methods/delta/helpers/types.ts +12 -1
- package/src/methods/delta/index.ts +0 -16
- package/src/methods/limitOrders/helpers/types.ts +2 -4
- package/src/methods/nftOrders/helpers/types.ts +2 -4
- package/src/sdk/simple.ts +0 -12
- package/dist/methods/delta/buildCrosschainOrderBridge.d.ts +0 -23
- package/dist/methods/delta/buildCrosschainOrderBridge.d.ts.map +0 -1
- package/dist/methods/delta/getMulticallHandlers.d.ts +0 -9
- package/dist/methods/delta/getMulticallHandlers.d.ts.map +0 -1
- package/dist/methods/delta/helpers/across.d.ts +0 -19
- package/dist/methods/delta/helpers/across.d.ts.map +0 -1
- package/src/methods/delta/buildCrosschainOrderBridge.ts +0 -96
- package/src/methods/delta/getMulticallHandlers.ts +0 -44
- package/src/methods/delta/helpers/across.ts +0 -189
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -151,12 +151,6 @@ import {
|
|
|
151
151
|
SignableDeltaOrderData,
|
|
152
152
|
SwapSideUnion,
|
|
153
153
|
} from './methods/delta/buildDeltaOrder';
|
|
154
|
-
import {
|
|
155
|
-
constructBuildCrosschainOrderBridge,
|
|
156
|
-
BuildCrosschainOrderBridgeFunctions,
|
|
157
|
-
BuildCrosschainOrderBridgeParams,
|
|
158
|
-
CrosschainOrderBridgeAndChanges,
|
|
159
|
-
} from './methods/delta/buildCrosschainOrderBridge';
|
|
160
154
|
import {
|
|
161
155
|
constructPostDeltaOrder,
|
|
162
156
|
DeltaOrderApiResponse,
|
|
@@ -181,6 +175,7 @@ import {
|
|
|
181
175
|
import {
|
|
182
176
|
constructGetDeltaOrders,
|
|
183
177
|
GetDeltaOrdersFunctions,
|
|
178
|
+
DeltaOrderFilterByStatus,
|
|
184
179
|
DeltaOrderFromAPI,
|
|
185
180
|
} from './methods/delta/getDeltaOrders';
|
|
186
181
|
import {
|
|
@@ -196,11 +191,6 @@ import {
|
|
|
196
191
|
GetBridgeInfoFunctions,
|
|
197
192
|
BridgeInfo,
|
|
198
193
|
} from './methods/delta/getBridgeInfo';
|
|
199
|
-
import {
|
|
200
|
-
constructGetMulticallHandlers,
|
|
201
|
-
GetMulticallHandlersFunctions,
|
|
202
|
-
MulticallHandlersResponse,
|
|
203
|
-
} from './methods/delta/getMulticallHandlers';
|
|
204
194
|
import {
|
|
205
195
|
constructIsTokenSupportedInDelta,
|
|
206
196
|
IsTokenSupportedInDeltaFunctions,
|
|
@@ -296,7 +286,6 @@ export {
|
|
|
296
286
|
constructBuildNFTOrderTx,
|
|
297
287
|
// Delta methods
|
|
298
288
|
constructBuildDeltaOrder,
|
|
299
|
-
constructBuildCrosschainOrderBridge,
|
|
300
289
|
constructPostDeltaOrder,
|
|
301
290
|
constructSignDeltaOrder,
|
|
302
291
|
constructGetDeltaContract,
|
|
@@ -310,7 +299,6 @@ export {
|
|
|
310
299
|
constructGetPartnerFee,
|
|
311
300
|
constructGetBridgeInfo,
|
|
312
301
|
constructIsTokenSupportedInDelta,
|
|
313
|
-
constructGetMulticallHandlers,
|
|
314
302
|
constructEthersContractCaller, // same as constructEthersV5ContractCaller for backwards compatibility
|
|
315
303
|
constructEthersV5ContractCaller,
|
|
316
304
|
constructEthersV6ContractCaller,
|
|
@@ -377,6 +365,7 @@ export type {
|
|
|
377
365
|
DeltaAuctionOrder,
|
|
378
366
|
DeltaAuction,
|
|
379
367
|
DeltaAuctionStatus,
|
|
368
|
+
DeltaOrderFilterByStatus,
|
|
380
369
|
DeltaOrderApiResponse,
|
|
381
370
|
DeltaOrderFromAPI,
|
|
382
371
|
// bridge part of DeltaOrder
|
|
@@ -387,9 +376,6 @@ export type {
|
|
|
387
376
|
BuildDeltaOrderDataParams,
|
|
388
377
|
BuildDeltaOrderFunctions,
|
|
389
378
|
SignableDeltaOrderData,
|
|
390
|
-
BuildCrosschainOrderBridgeFunctions,
|
|
391
|
-
BuildCrosschainOrderBridgeParams,
|
|
392
|
-
CrosschainOrderBridgeAndChanges,
|
|
393
379
|
PostDeltaOrderFunctions,
|
|
394
380
|
PostDeltaOrderParams,
|
|
395
381
|
SignDeltaOrderFunctions,
|
|
@@ -413,8 +399,6 @@ export type {
|
|
|
413
399
|
GetPartnerFeeFunctions,
|
|
414
400
|
GetBridgeInfoFunctions,
|
|
415
401
|
IsTokenSupportedInDeltaFunctions,
|
|
416
|
-
GetMulticallHandlersFunctions,
|
|
417
|
-
MulticallHandlersResponse,
|
|
418
402
|
Token,
|
|
419
403
|
Address,
|
|
420
404
|
AddressOrSymbol,
|
|
@@ -4,10 +4,3 @@ export type OrderTransaction = {
|
|
|
4
4
|
};
|
|
5
5
|
|
|
6
6
|
export type OrderType = 'LIMIT' | 'P2P';
|
|
7
|
-
|
|
8
|
-
// display states such as EXPIRED and PARTIALLY_FILLLED derived on client side
|
|
9
|
-
// returned by API but can be calculated too, EXPIRED == order.expiry < Date.now()/1000
|
|
10
|
-
// PARTIALLY_FILLED == order.fillableBalance < order.makerAmount && order.fillableBalance !== '0'
|
|
11
|
-
export type OrderState = 'PENDING' | 'FULFILLED' | 'CANCELLED' | 'EXPIRED';
|
|
12
|
-
|
|
13
|
-
export type BeneficiaryType = 'EOA' | 'SmartContract';
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
RequestParameters,
|
|
5
5
|
} from '../../types';
|
|
6
6
|
import { constructGetDeltaContract } from './getDeltaContract';
|
|
7
|
-
import { BridgePrice } from './getDeltaPrice';
|
|
7
|
+
import type { BridgePrice } from './getDeltaPrice';
|
|
8
8
|
import { constructGetPartnerFee } from './getPartnerFee';
|
|
9
9
|
import {
|
|
10
10
|
buildDeltaSignableOrderData,
|
|
@@ -12,8 +12,9 @@ import {
|
|
|
12
12
|
type SignableDeltaOrderData,
|
|
13
13
|
} from './helpers/buildDeltaOrderData';
|
|
14
14
|
import { SwapSideToOrderKind } from './helpers/types';
|
|
15
|
-
import { BeneficiaryType } from '../common/orders/types';
|
|
16
15
|
import { SwapSide } from '../../constants';
|
|
16
|
+
import type { MarkOptional } from 'ts-essentials';
|
|
17
|
+
import { ZERO_ADDRESS } from '../common/orders/buildOrderData';
|
|
17
18
|
export type { SignableDeltaOrderData } from './helpers/buildDeltaOrderData';
|
|
18
19
|
|
|
19
20
|
export type SwapSideUnion = EnumerateLiteral<typeof SwapSide>;
|
|
@@ -42,18 +43,19 @@ export type BuildDeltaOrderDataParams = {
|
|
|
42
43
|
|
|
43
44
|
/** @description Destination Chain ID for Crosschain Orders */
|
|
44
45
|
destChainId?: number;
|
|
45
|
-
/** @description Whether the beneficiary is a contract. Needed to automatically fill in crosschain Bridge */
|
|
46
|
-
beneficiaryType?: BeneficiaryType;
|
|
47
46
|
|
|
48
47
|
/** @description price response received from /delta/prices (getDeltaPrice method) */
|
|
49
|
-
deltaPrice:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
deltaPrice: MarkOptional<
|
|
49
|
+
Pick<
|
|
50
|
+
BridgePrice,
|
|
51
|
+
| 'destAmount'
|
|
52
|
+
| 'partner'
|
|
53
|
+
| 'partnerFee'
|
|
54
|
+
| 'destToken'
|
|
55
|
+
| 'srcAmount'
|
|
56
|
+
| 'bridge'
|
|
57
|
+
>,
|
|
58
|
+
'partner' | 'partnerFee'
|
|
57
59
|
>;
|
|
58
60
|
|
|
59
61
|
/** @description partner fee in basis points (bps), 50bps=0.5% */
|
|
@@ -100,7 +102,10 @@ export const constructBuildDeltaOrder = (
|
|
|
100
102
|
// externally supplied partner fee data takes precedence
|
|
101
103
|
let partnerAddress = options.partnerAddress;
|
|
102
104
|
let partnerFeeBps =
|
|
103
|
-
options.partnerFeeBps ??
|
|
105
|
+
options.partnerFeeBps ??
|
|
106
|
+
(options.deltaPrice.partnerFee
|
|
107
|
+
? options.deltaPrice.partnerFee * 100
|
|
108
|
+
: undefined);
|
|
104
109
|
let partnerTakesSurplus = options.partnerTakesSurplus;
|
|
105
110
|
|
|
106
111
|
// if fee given, takeSurplus is ignored
|
|
@@ -109,18 +114,27 @@ export const constructBuildDeltaOrder = (
|
|
|
109
114
|
|
|
110
115
|
if (partnerAddress === undefined || feeOrTakeSurplusSupplied) {
|
|
111
116
|
const partner = options.partner || options.deltaPrice.partner;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
if (!partner) {
|
|
118
|
+
// if no partner given in options or deltaPrice, default partnerAddress to zero,
|
|
119
|
+
// unless supplied explicitly
|
|
120
|
+
partnerAddress = partnerAddress ?? ZERO_ADDRESS;
|
|
121
|
+
} else {
|
|
122
|
+
const partnerFeeResponse = await getPartnerFee(
|
|
123
|
+
{ partner },
|
|
124
|
+
requestParams
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
partnerAddress = partnerAddress ?? partnerFeeResponse.partnerAddress;
|
|
128
|
+
// deltaPrice.partnerFee and partnerFeeResponse.partnerFee should be the same, but give priority to externally provided
|
|
129
|
+
partnerFeeBps = partnerFeeBps ?? partnerFeeResponse.partnerFee;
|
|
130
|
+
partnerTakesSurplus =
|
|
131
|
+
partnerTakesSurplus ?? partnerFeeResponse.takeSurplus;
|
|
132
|
+
}
|
|
122
133
|
}
|
|
123
134
|
|
|
135
|
+
partnerFeeBps = partnerFeeBps ?? 0;
|
|
136
|
+
partnerTakesSurplus = partnerTakesSurplus ?? false;
|
|
137
|
+
|
|
124
138
|
const swapSide = options.side ?? SwapSide.SELL;
|
|
125
139
|
|
|
126
140
|
const expectedAmount =
|
|
@@ -2,11 +2,11 @@ import type {
|
|
|
2
2
|
ConstructProviderFetchInput,
|
|
3
3
|
RequestParameters,
|
|
4
4
|
} from '../../types';
|
|
5
|
+
import { constructGetDeltaContract } from './getDeltaContract';
|
|
5
6
|
import {
|
|
6
7
|
buildCancelDeltaOrderSignableData,
|
|
7
8
|
CancelDeltaOrderData,
|
|
8
9
|
} from './helpers/buildCancelDeltaOrderData';
|
|
9
|
-
import { constructGetDeltaContract } from '../..';
|
|
10
10
|
|
|
11
11
|
type SuccessResponse = { success: true };
|
|
12
12
|
|
|
@@ -5,10 +5,18 @@ import type {
|
|
|
5
5
|
ConstructFetchInput,
|
|
6
6
|
RequestParameters,
|
|
7
7
|
} from '../../types';
|
|
8
|
-
import type { DeltaAuction } from './helpers/types';
|
|
8
|
+
import type { DeltaAuction, DeltaAuctionStatus } from './helpers/types';
|
|
9
9
|
|
|
10
10
|
export type DeltaOrderFromAPI = Omit<DeltaAuction, 'signature'>;
|
|
11
11
|
|
|
12
|
+
export type DeltaOrderFilterByStatus =
|
|
13
|
+
| DeltaAuctionStatus
|
|
14
|
+
| 'INSUFFICIENT_BALANCE'
|
|
15
|
+
| 'INSUFFICIENT_ALLOWANCE'
|
|
16
|
+
| 'INVALIDATED'
|
|
17
|
+
| 'ACTIVE'
|
|
18
|
+
| 'INACTIVE';
|
|
19
|
+
|
|
12
20
|
type GetDeltaOrderById = (
|
|
13
21
|
orderId: string,
|
|
14
22
|
requestParams?: RequestParameters
|
|
@@ -27,11 +35,24 @@ type OrdersFilter = {
|
|
|
27
35
|
/** @description Pagination option, limit. Default 100 */
|
|
28
36
|
limit?: number;
|
|
29
37
|
/** @description Filter by chainId, without this filter, orders from all chains are returned */
|
|
30
|
-
chainId?: number;
|
|
31
|
-
/**
|
|
32
|
-
|
|
38
|
+
chainId?: number[];
|
|
39
|
+
/**
|
|
40
|
+
* @description
|
|
41
|
+
* Filter by any known DeltaAuctionStatus and some custom statuses:
|
|
42
|
+
* - **INSUFFICIENT_BALANCE** — returned as SUSPENDED from API
|
|
43
|
+
* - **INSUFFICIENT_ALLOWANCE** — returned as SUSPENDED from API
|
|
44
|
+
* - **INVALIDATED** — returned as FAILED from API
|
|
45
|
+
* - **ACTIVE** — All orders with NOT_STARTED, RUNNING, EXECUTING or SUSPENDED statuses.
|
|
46
|
+
* - **INACTIVE** — All orders with EXECUTED, FAILED, EXPIRED, CANCELLED or INVALIDATED statuses.
|
|
47
|
+
*/
|
|
48
|
+
status?: DeltaOrderFilterByStatus[];
|
|
49
|
+
/** @description Filter by type. MARKET, LIMIT. Orders with both types are returned if not specified */
|
|
50
|
+
type?: 'MARKET' | 'LIMIT';
|
|
51
|
+
};
|
|
52
|
+
type OrderFiltersQuery = Omit<OrdersFilter, 'chainId' | 'status'> & {
|
|
53
|
+
chainId?: string;
|
|
54
|
+
status?: string;
|
|
33
55
|
};
|
|
34
|
-
type OrderFiltersQuery = OrdersFilter;
|
|
35
56
|
|
|
36
57
|
type GetDeltaOrders = (
|
|
37
58
|
options: OrdersFilter,
|
|
@@ -93,12 +114,16 @@ export const constructGetDeltaOrders = ({
|
|
|
93
114
|
};
|
|
94
115
|
|
|
95
116
|
const getDeltaOrders: GetDeltaOrders = async (options, requestParams) => {
|
|
117
|
+
const chainIdString = options.chainId?.join(',');
|
|
118
|
+
const statusString = options.status?.join(',');
|
|
119
|
+
|
|
96
120
|
const search = constructSearchString<OrderFiltersQuery>({
|
|
97
121
|
userAddress: options.userAddress,
|
|
98
122
|
page: options.page,
|
|
99
123
|
limit: options.limit,
|
|
100
|
-
chainId: options.chainId,
|
|
101
124
|
type: options.type,
|
|
125
|
+
chainId: chainIdString,
|
|
126
|
+
status: statusString,
|
|
102
127
|
});
|
|
103
128
|
|
|
104
129
|
const fetchURL = `${baseUrl}${search}` as const;
|
|
@@ -64,6 +64,13 @@ export type DeltaPrice = {
|
|
|
64
64
|
destAmount: string;
|
|
65
65
|
/** @description Available for SELL side */
|
|
66
66
|
destAmountBeforeFee?: string;
|
|
67
|
+
/** @description amount of the final outcome token */
|
|
68
|
+
receivedDestAmount: string;
|
|
69
|
+
receivedDestUSD: string;
|
|
70
|
+
/** @description Available for SELL side */
|
|
71
|
+
receivedDestAmountBeforeFee?: string;
|
|
72
|
+
/** @description Available for SELL side */
|
|
73
|
+
receivedDestUSDBeforeFee?: string;
|
|
67
74
|
gasCost: string;
|
|
68
75
|
gasCostBeforeFee: string;
|
|
69
76
|
gasCostUSD: string;
|
|
@@ -80,6 +87,26 @@ export type DeltaPrice = {
|
|
|
80
87
|
bridge: Bridge; // for single-chain DeltaPrice, it's DEFAULT_BRIDGE
|
|
81
88
|
};
|
|
82
89
|
|
|
90
|
+
type AvailableBridgePrice = Pick<
|
|
91
|
+
DeltaPrice,
|
|
92
|
+
| 'destToken'
|
|
93
|
+
| 'destAmount'
|
|
94
|
+
| 'destAmountBeforeFee'
|
|
95
|
+
| 'destUSD'
|
|
96
|
+
| 'destUSDBeforeFee'
|
|
97
|
+
| 'gasCostUSD'
|
|
98
|
+
| 'gasCost'
|
|
99
|
+
| 'gasCostUSDBeforeFee'
|
|
100
|
+
| 'gasCostBeforeFee'
|
|
101
|
+
>;
|
|
102
|
+
|
|
103
|
+
type AvailableBridge = AvailableBridgePrice & {
|
|
104
|
+
bridgeParams: {
|
|
105
|
+
bridge: Bridge;
|
|
106
|
+
bridgeInfo: BridgePriceInfo;
|
|
107
|
+
}[];
|
|
108
|
+
};
|
|
109
|
+
|
|
83
110
|
export type BridgePrice = Omit<DeltaPrice, 'bridge'> & {
|
|
84
111
|
// destAmountAfterBridge: string; // became bridgeInfo.destAmountAfterBridge
|
|
85
112
|
// destUSDAfterBridge: string; // became bridgeInfo.destUSDAfterBridge
|
|
@@ -88,6 +115,7 @@ export type BridgePrice = Omit<DeltaPrice, 'bridge'> & {
|
|
|
88
115
|
// poolAddress: string;
|
|
89
116
|
bridge: Bridge;
|
|
90
117
|
bridgeInfo: BridgePriceInfo;
|
|
118
|
+
availableBridges: AvailableBridge[];
|
|
91
119
|
};
|
|
92
120
|
|
|
93
121
|
type DeltaPriceResponse = {
|
|
@@ -137,7 +137,18 @@ export type BridgeStatus = 'pending' | 'filled' | 'expired' | 'refunded';
|
|
|
137
137
|
//// available on BridgePrice ////
|
|
138
138
|
|
|
139
139
|
// so far
|
|
140
|
-
type ProtocolName =
|
|
140
|
+
type ProtocolName =
|
|
141
|
+
| 'Across'
|
|
142
|
+
| 'StargateBus'
|
|
143
|
+
| 'StargateTaxi'
|
|
144
|
+
| 'StargateOftV2'
|
|
145
|
+
| 'Relay'
|
|
146
|
+
| 'CCTPFast'
|
|
147
|
+
| 'CCTPStandard'
|
|
148
|
+
| 'Celer'
|
|
149
|
+
| 'Canonical'
|
|
150
|
+
| 'Polygon'
|
|
151
|
+
| 'Arbitrum';
|
|
141
152
|
|
|
142
153
|
type BridgeQuoteFee = {
|
|
143
154
|
feeToken: string;
|
|
@@ -38,18 +38,10 @@ import {
|
|
|
38
38
|
constructGetBridgeInfo,
|
|
39
39
|
GetBridgeInfoFunctions,
|
|
40
40
|
} from './getBridgeInfo';
|
|
41
|
-
import {
|
|
42
|
-
constructGetMulticallHandlers,
|
|
43
|
-
GetMulticallHandlersFunctions,
|
|
44
|
-
} from './getMulticallHandlers';
|
|
45
41
|
import {
|
|
46
42
|
constructIsTokenSupportedInDelta,
|
|
47
43
|
IsTokenSupportedInDeltaFunctions,
|
|
48
44
|
} from './isTokenSupportedInDelta';
|
|
49
|
-
import {
|
|
50
|
-
BuildCrosschainOrderBridgeFunctions,
|
|
51
|
-
constructBuildCrosschainOrderBridge,
|
|
52
|
-
} from './buildCrosschainOrderBridge';
|
|
53
45
|
import {
|
|
54
46
|
CancelDeltaOrderFunctions,
|
|
55
47
|
constructCancelDeltaOrder,
|
|
@@ -101,12 +93,10 @@ export const constructSubmitDeltaOrder = (
|
|
|
101
93
|
export type DeltaOrderHandlers<T> = SubmitDeltaOrderFuncs &
|
|
102
94
|
ApproveTokenForDeltaFunctions<T> &
|
|
103
95
|
BuildDeltaOrderFunctions &
|
|
104
|
-
BuildCrosschainOrderBridgeFunctions &
|
|
105
96
|
GetDeltaOrdersFunctions &
|
|
106
97
|
GetDeltaPriceFunctions &
|
|
107
98
|
GetDeltaContractFunctions &
|
|
108
99
|
GetPartnerFeeFunctions &
|
|
109
|
-
GetMulticallHandlersFunctions &
|
|
110
100
|
GetBridgeInfoFunctions &
|
|
111
101
|
IsTokenSupportedInDeltaFunctions &
|
|
112
102
|
PostDeltaOrderFunctions &
|
|
@@ -127,15 +117,11 @@ export const constructAllDeltaOrdersHandlers = <TxResponse>(
|
|
|
127
117
|
const partnerFee = constructGetPartnerFee(options);
|
|
128
118
|
const bridgeInfo = constructGetBridgeInfo(options);
|
|
129
119
|
const isTokenSupportedInDelta = constructIsTokenSupportedInDelta(options);
|
|
130
|
-
const multicallHandlers = constructGetMulticallHandlers(options);
|
|
131
120
|
|
|
132
121
|
const approveTokenForDelta = constructApproveTokenForDelta(options);
|
|
133
122
|
|
|
134
123
|
const deltaOrdersSubmit = constructSubmitDeltaOrder(options);
|
|
135
124
|
|
|
136
|
-
const buildCrosschainOrderBridge =
|
|
137
|
-
constructBuildCrosschainOrderBridge(options);
|
|
138
|
-
|
|
139
125
|
const deltaOrdersBuild = constructBuildDeltaOrder(options);
|
|
140
126
|
const deltaOrdersSign = constructSignDeltaOrder(options);
|
|
141
127
|
const deltaOrdersPost = constructPostDeltaOrder(options);
|
|
@@ -149,13 +135,11 @@ export const constructAllDeltaOrdersHandlers = <TxResponse>(
|
|
|
149
135
|
...partnerFee,
|
|
150
136
|
...bridgeInfo,
|
|
151
137
|
...isTokenSupportedInDelta,
|
|
152
|
-
...multicallHandlers,
|
|
153
138
|
...approveTokenForDelta,
|
|
154
139
|
...deltaOrdersSubmit,
|
|
155
140
|
...deltaOrdersBuild,
|
|
156
141
|
...deltaOrdersSign,
|
|
157
142
|
...deltaOrdersPost,
|
|
158
143
|
...deltaOrdersCancel,
|
|
159
|
-
...buildCrosschainOrderBridge,
|
|
160
144
|
};
|
|
161
145
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OrderTransaction } from '../../common/orders/types';
|
|
1
2
|
import type { OrderData } from './buildOrderData';
|
|
2
3
|
|
|
3
4
|
export type LimitOrderType = 'LIMIT' | 'P2P';
|
|
@@ -36,10 +37,7 @@ export type LimitOrderState =
|
|
|
36
37
|
|
|
37
38
|
export type LimitOrderEvent = '';
|
|
38
39
|
|
|
39
|
-
export type LimitOrderTransaction =
|
|
40
|
-
hash: string;
|
|
41
|
-
event_type: 'OrderFilled' | 'OrderCancelled';
|
|
42
|
-
};
|
|
40
|
+
export type LimitOrderTransaction = OrderTransaction;
|
|
43
41
|
|
|
44
42
|
export type LimitOrderFromApi = {
|
|
45
43
|
chainId: number;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { Address } from '../../../types';
|
|
2
|
+
import { OrderTransaction } from '../../common/orders/types';
|
|
2
3
|
import type { NFTOrderData } from './buildOrderData';
|
|
3
4
|
import type { AssetType } from './misc';
|
|
4
5
|
|
|
5
|
-
export type NFTOrderTransaction =
|
|
6
|
-
hash: string;
|
|
7
|
-
event_type: 'OrderFilled' | 'OrderCancelled';
|
|
8
|
-
};
|
|
6
|
+
export type NFTOrderTransaction = OrderTransaction;
|
|
9
7
|
|
|
10
8
|
export type NFTOrderType = 'LIMIT' | 'P2P';
|
|
11
9
|
|
package/src/sdk/simple.ts
CHANGED
|
@@ -132,18 +132,10 @@ import {
|
|
|
132
132
|
constructGetBridgeInfo,
|
|
133
133
|
GetBridgeInfoFunctions,
|
|
134
134
|
} from '../methods/delta/getBridgeInfo';
|
|
135
|
-
import {
|
|
136
|
-
constructGetMulticallHandlers,
|
|
137
|
-
GetMulticallHandlersFunctions,
|
|
138
|
-
} from '../methods/delta/getMulticallHandlers';
|
|
139
135
|
import {
|
|
140
136
|
constructIsTokenSupportedInDelta,
|
|
141
137
|
IsTokenSupportedInDeltaFunctions,
|
|
142
138
|
} from '../methods/delta/isTokenSupportedInDelta';
|
|
143
|
-
import {
|
|
144
|
-
BuildCrosschainOrderBridgeFunctions,
|
|
145
|
-
constructBuildCrosschainOrderBridge,
|
|
146
|
-
} from '../methods/delta/buildCrosschainOrderBridge';
|
|
147
139
|
|
|
148
140
|
export type SwapFetchMethods = GetBalancesFunctions &
|
|
149
141
|
GetTokensFunctions &
|
|
@@ -166,12 +158,10 @@ export type NFTOrdersFetchMethods = GetNFTOrdersContractFunctions &
|
|
|
166
158
|
BuildNFTOrdersTxFunctions;
|
|
167
159
|
|
|
168
160
|
export type DeltaFetchMethods = BuildDeltaOrderFunctions &
|
|
169
|
-
BuildCrosschainOrderBridgeFunctions &
|
|
170
161
|
GetDeltaOrdersFunctions &
|
|
171
162
|
GetDeltaPriceFunctions &
|
|
172
163
|
GetDeltaContractFunctions &
|
|
173
164
|
GetPartnerFeeFunctions &
|
|
174
|
-
GetMulticallHandlersFunctions &
|
|
175
165
|
GetBridgeInfoFunctions &
|
|
176
166
|
IsTokenSupportedInDeltaFunctions &
|
|
177
167
|
PostDeltaOrderFunctions;
|
|
@@ -288,13 +278,11 @@ export function constructSimpleSDK(
|
|
|
288
278
|
const delta = constructPartialSDK(
|
|
289
279
|
config,
|
|
290
280
|
constructBuildDeltaOrder,
|
|
291
|
-
constructBuildCrosschainOrderBridge,
|
|
292
281
|
constructPostDeltaOrder,
|
|
293
282
|
constructGetDeltaOrders,
|
|
294
283
|
constructGetDeltaPrice,
|
|
295
284
|
constructGetDeltaContract,
|
|
296
285
|
constructGetPartnerFee,
|
|
297
|
-
constructGetMulticallHandlers,
|
|
298
286
|
constructGetBridgeInfo,
|
|
299
287
|
constructIsTokenSupportedInDelta
|
|
300
288
|
);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
2
|
-
import { BridgePrice } from './getDeltaPrice';
|
|
3
|
-
import { GetDeltaBridgeAndDestTokenOutput } from './helpers/across';
|
|
4
|
-
import { BeneficiaryType } from '../common/orders/types';
|
|
5
|
-
export type { SignableDeltaOrderData } from './helpers/buildDeltaOrderData';
|
|
6
|
-
export type BuildCrosschainOrderBridgeParams = {
|
|
7
|
-
/** @description The address of the destination token on the destination chain */
|
|
8
|
-
destToken: string;
|
|
9
|
-
/** @description Destination Chain ID for Crosschain Orders */
|
|
10
|
-
destChainId: number;
|
|
11
|
-
/** @description Whether the beneficiary is a contract. Needed to automatically fill in crosschain Bridge */
|
|
12
|
-
beneficiaryType: BeneficiaryType;
|
|
13
|
-
/** @description price response received from /delta/prices (getDeltaPrice method) */
|
|
14
|
-
deltaPrice: BridgePrice;
|
|
15
|
-
};
|
|
16
|
-
type BuildCrosschainOrderBridge = (buildOrderParams: BuildCrosschainOrderBridgeParams, requestParams?: RequestParameters) => Promise<GetDeltaBridgeAndDestTokenOutput>;
|
|
17
|
-
export { GetDeltaBridgeAndDestTokenOutput as CrosschainOrderBridgeAndChanges };
|
|
18
|
-
export type BuildCrosschainOrderBridgeFunctions = {
|
|
19
|
-
/** @description Build Orders to be posted to Delta API for execution */
|
|
20
|
-
buildCrosschainOrderBridge: BuildCrosschainOrderBridge;
|
|
21
|
-
};
|
|
22
|
-
export declare const constructBuildCrosschainOrderBridge: (options: ConstructFetchInput) => BuildCrosschainOrderBridgeFunctions;
|
|
23
|
-
//# sourceMappingURL=buildCrosschainOrderBridge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildCrosschainOrderBridge.d.ts","sourceRoot":"","sources":["../../../src/methods/delta/buildCrosschainOrderBridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAEL,gCAAgC,EACjC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,4GAA4G;IAC5G,eAAe,EAAE,eAAe,CAAC;IAEjC,qFAAqF;IACrF,UAAU,EAAE,WAAW,CAAC;CACzB,CAAC;AAEF,KAAK,0BAA0B,GAAG,CAChC,gBAAgB,EAAE,gCAAgC,EAClD,aAAa,CAAC,EAAE,iBAAiB,KAC9B,OAAO,CAAC,gCAAgC,CAAC,CAAC;AAE/C,OAAO,EAAE,gCAAgC,IAAI,+BAA+B,EAAE,CAAC;AAE/E,MAAM,MAAM,mCAAmC,GAAG;IAChD,wEAAwE;IACxE,0BAA0B,EAAE,0BAA0B,CAAC;CACxD,CAAC;AAEF,eAAO,MAAM,mCAAmC,YACrC,mBAAmB,KAC3B,mCA0DF,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Address, ConstructFetchInput, RequestParameters } from '../../types';
|
|
2
|
-
export type MulticallHandlersResponse = Record<number, Address>;
|
|
3
|
-
type GetMulticallHandlers = (requestParams?: RequestParameters) => Promise<MulticallHandlersResponse>;
|
|
4
|
-
export type GetMulticallHandlersFunctions = {
|
|
5
|
-
getMulticallHandlers: GetMulticallHandlers;
|
|
6
|
-
};
|
|
7
|
-
export declare const constructGetMulticallHandlers: ({ apiURL, fetcher, }: ConstructFetchInput) => GetMulticallHandlersFunctions;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=getMulticallHandlers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getMulticallHandlers.d.ts","sourceRoot":"","sources":["../../../src/methods/delta/getMulticallHandlers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,OAAO,EACP,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAGrB,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEhE,KAAK,oBAAoB,GAAG,CAC1B,aAAa,CAAC,EAAE,iBAAiB,KAC9B,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAExC,MAAM,MAAM,6BAA6B,GAAG;IAC1C,oBAAoB,EAAE,oBAAoB,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,6BAA6B,yBAGvC,mBAAmB,KAAG,6BAqBxB,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BeneficiaryType } from '../../common/orders/types';
|
|
2
|
-
import { Bridge } from './types';
|
|
3
|
-
export declare const ACROSS_WETH_ADDRESSES_MAP: Record<number, string>;
|
|
4
|
-
export declare function isAcrossWETH(tokenAddress: string, chainId: number): boolean;
|
|
5
|
-
export declare function isETHaddress(tokenAddress: string): boolean;
|
|
6
|
-
export type GetDeltaBridgeAndDestTokenInput = {
|
|
7
|
-
destTokenDestChain: string;
|
|
8
|
-
destChainId: number;
|
|
9
|
-
bridgeFee: string;
|
|
10
|
-
bridgeOutputToken: string;
|
|
11
|
-
beneficiaryType: BeneficiaryType;
|
|
12
|
-
getMulticallHandler: (chainId: number) => Promise<string>;
|
|
13
|
-
};
|
|
14
|
-
export type GetDeltaBridgeAndDestTokenOutput = {
|
|
15
|
-
/** @description The bridge object to be used for Order.bridge */
|
|
16
|
-
bridge: Bridge;
|
|
17
|
-
};
|
|
18
|
-
export declare function getDeltaBridge({ destTokenDestChain, destChainId, bridgeFee, bridgeOutputToken, beneficiaryType, getMulticallHandler, }: GetDeltaBridgeAndDestTokenInput): Promise<GetDeltaBridgeAndDestTokenOutput>;
|
|
19
|
-
//# sourceMappingURL=across.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"across.d.ts","sourceRoot":"","sources":["../../../../src/methods/delta/helpers/across.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuE5D,CAAC;AAEF,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,WAKjE;AAQD,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAE1D;AAQD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,eAAe,CAAC;IACjC,mBAAmB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,cAAc,CAAC,EACnC,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,mBAAmB,GACpB,EAAE,+BAA+B,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAkE7E"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { assert } from 'ts-essentials';
|
|
2
|
-
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
3
|
-
import { BridgePrice } from './getDeltaPrice';
|
|
4
|
-
// import { constructGetMulticallHandlers } from './getMulticallHandlers';
|
|
5
|
-
import {
|
|
6
|
-
// getDeltaBridge,
|
|
7
|
-
GetDeltaBridgeAndDestTokenOutput,
|
|
8
|
-
} from './helpers/across';
|
|
9
|
-
import { BeneficiaryType } from '../common/orders/types';
|
|
10
|
-
export type { SignableDeltaOrderData } from './helpers/buildDeltaOrderData';
|
|
11
|
-
|
|
12
|
-
export type BuildCrosschainOrderBridgeParams = {
|
|
13
|
-
/** @description The address of the destination token on the destination chain */
|
|
14
|
-
destToken: string; // lowercase
|
|
15
|
-
/** @description Destination Chain ID for Crosschain Orders */
|
|
16
|
-
destChainId: number;
|
|
17
|
-
/** @description Whether the beneficiary is a contract. Needed to automatically fill in crosschain Bridge */
|
|
18
|
-
beneficiaryType: BeneficiaryType;
|
|
19
|
-
|
|
20
|
-
/** @description price response received from /delta/prices (getDeltaPrice method) */
|
|
21
|
-
deltaPrice: BridgePrice;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type BuildCrosschainOrderBridge = (
|
|
25
|
-
buildOrderParams: BuildCrosschainOrderBridgeParams,
|
|
26
|
-
requestParams?: RequestParameters
|
|
27
|
-
) => Promise<GetDeltaBridgeAndDestTokenOutput>;
|
|
28
|
-
|
|
29
|
-
export { GetDeltaBridgeAndDestTokenOutput as CrosschainOrderBridgeAndChanges };
|
|
30
|
-
|
|
31
|
-
export type BuildCrosschainOrderBridgeFunctions = {
|
|
32
|
-
/** @description Build Orders to be posted to Delta API for execution */
|
|
33
|
-
buildCrosschainOrderBridge: BuildCrosschainOrderBridge;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const constructBuildCrosschainOrderBridge = (
|
|
37
|
-
options: ConstructFetchInput
|
|
38
|
-
): BuildCrosschainOrderBridgeFunctions => {
|
|
39
|
-
const { chainId } = options;
|
|
40
|
-
|
|
41
|
-
// cached internally for `multicall` contracts
|
|
42
|
-
// const { getMulticallHandlers } = constructGetMulticallHandlers(options);
|
|
43
|
-
|
|
44
|
-
const buildCrosschainOrderBridge: BuildCrosschainOrderBridge = async (
|
|
45
|
-
{ destToken, destChainId, beneficiaryType, deltaPrice },
|
|
46
|
-
requestParams
|
|
47
|
-
) => {
|
|
48
|
-
assert(
|
|
49
|
-
chainId !== deltaPrice.bridge.destinationChainId,
|
|
50
|
-
'`deltaPrice.bridge.destinationChainId` must be different from `chainId` for crosschain Order.bridge'
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
assert(
|
|
54
|
-
destChainId === deltaPrice.bridge.destinationChainId,
|
|
55
|
-
'`destChainId` must match `deltaPrice.bridge.destinationChainId` for crosschain Order.bridge'
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
/* const getMulticallHandler = async (chainId: number) => {
|
|
59
|
-
const multicallHandlersMap = await getMulticallHandlers(requestParams);
|
|
60
|
-
const multicallHandler = multicallHandlersMap[chainId];
|
|
61
|
-
|
|
62
|
-
assert(
|
|
63
|
-
multicallHandler,
|
|
64
|
-
`Multicall handler not found for chain ${chainId}`
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return multicallHandler;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const { bridge } = await getDeltaBridge({
|
|
71
|
-
destTokenDestChain: destToken,
|
|
72
|
-
destChainId,
|
|
73
|
-
bridgeFee: deltaPrice.bridgeFee,
|
|
74
|
-
bridgeOutputToken: deltaPrice.bridge.outputToken,
|
|
75
|
-
beneficiaryType,
|
|
76
|
-
getMulticallHandler,
|
|
77
|
-
}); */
|
|
78
|
-
|
|
79
|
-
// @TODO remove the whole buildCrosschainOrderBridge() when API provides BridgePrice.bridge = whole Bridge object
|
|
80
|
-
const bridge = {
|
|
81
|
-
protocolSelector: '0x00000000',
|
|
82
|
-
scalingFactor: 0,
|
|
83
|
-
protocolData: '0x',
|
|
84
|
-
destinationChainId: deltaPrice.bridge.destinationChainId,
|
|
85
|
-
outputToken: deltaPrice.bridge.outputToken,
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
bridge,
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
buildCrosschainOrderBridge,
|
|
95
|
-
};
|
|
96
|
-
};
|