@velora-dex/sdk 9.5.2-dev.0 → 9.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velora-dex/sdk",
3
- "version": "9.5.2-dev.0",
3
+ "version": "9.5.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/sdk.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -68,6 +68,7 @@
68
68
  "typedoc-plugin-missing-exports": "^3.0.0",
69
69
  "typedoc-plugin-replace-text": "^4.0.0",
70
70
  "typescript": "^5.6.3",
71
+ "viem": "^2.39.0",
71
72
  "wagmi": "^2.19.4",
72
73
  "web3": "^4.14.0"
73
74
  },
@@ -92,7 +93,7 @@
92
93
  }
93
94
  },
94
95
  "dependencies": {
95
- "@paraswap/core": "2.4.3",
96
+ "@paraswap/core": "2.4.1",
96
97
  "ts-essentials": "^10.0.3",
97
98
  "viem": "^2.21.0"
98
99
  },
package/src/index.ts CHANGED
@@ -155,13 +155,6 @@ import type {
155
155
  DeltaAmountsSellSlippage,
156
156
  DeltaAmountsBuySlippage,
157
157
  DeltaAmountsExplicit,
158
- DeltaAuctionDelta,
159
- DeltaAuctionTWAP,
160
- DeltaAuctionTWAPBuy,
161
- DeltaAuctionExternal,
162
- DeltaOrderUnion,
163
- DeltaAuctionUnion,
164
- UnifiedDeltaOrderData,
165
158
  } from './methods/delta/helpers/types';
166
159
  import {
167
160
  BuildDeltaOrderDataParams,
@@ -457,13 +450,6 @@ export type {
457
450
  DeltaPriceParams,
458
451
  DeltaAuctionOrder,
459
452
  DeltaAuction,
460
- DeltaAuctionDelta,
461
- DeltaAuctionTWAP,
462
- DeltaAuctionTWAPBuy,
463
- DeltaAuctionExternal,
464
- DeltaOrderUnion,
465
- DeltaAuctionUnion,
466
- UnifiedDeltaOrderData,
467
453
  DeltaAuctionStatus,
468
454
  DeltaAuctionTransaction,
469
455
  DeltaOrderFilterByStatus,
@@ -566,6 +552,3 @@ export * from './methods/limitOrders/helpers/types';
566
552
  export * from './methods/nftOrders';
567
553
  export * from './methods/nftOrders/helpers/types';
568
554
  export { AssetType } from './methods/nftOrders/helpers/misc';
569
-
570
- // helpers for Delta Orders
571
- export { OrderHelpers } from './methods/delta/helpers/orders';
@@ -13,11 +13,9 @@ import type {
13
13
  TWAPDeltaOrder,
14
14
  TWAPBuyDeltaOrder,
15
15
  } from './helpers/types';
16
- import { DEFAULT_BRIDGE } from './constants';
17
16
 
18
17
  export type CancelAndWithdrawDeltaOrderParams = {
19
18
  order: DeltaAuctionOrder;
20
- signature: string;
21
19
  /** @description A boolean indicating whether the order is a fillable order. False by default */
22
20
  isFillable?: boolean;
23
21
  };
@@ -91,129 +89,100 @@ const DeltaTokenModuleAbi = [
91
89
  name: 'cancelAndWithdraw',
92
90
  inputs: [
93
91
  {
94
- name: 'orderWithSig',
92
+ name: 'order',
95
93
  type: 'tuple',
96
- internalType: 'struct OrderWithSig',
94
+ internalType: 'struct Order',
97
95
  components: [
98
96
  {
99
- name: 'order',
100
- type: 'tuple',
101
- internalType: 'struct Order',
102
- components: [
103
- {
104
- name: 'owner',
105
- type: 'address',
106
- internalType: 'address',
107
- },
108
- {
109
- name: 'beneficiary',
110
- type: 'address',
111
- internalType: 'address',
112
- },
113
- {
114
- name: 'srcToken',
115
- type: 'address',
116
- internalType: 'address',
117
- },
118
- {
119
- name: 'destToken',
120
- type: 'address',
121
- internalType: 'address',
122
- },
123
- {
124
- name: 'srcAmount',
125
- type: 'uint256',
126
- internalType: 'uint256',
127
- },
128
- {
129
- name: 'destAmount',
130
- type: 'uint256',
131
- internalType: 'uint256',
132
- },
133
- {
134
- name: 'expectedAmount',
135
- type: 'uint256',
136
- internalType: 'uint256',
137
- },
138
- {
139
- name: 'deadline',
140
- type: 'uint256',
141
- internalType: 'uint256',
142
- },
143
- {
144
- name: 'kind',
145
- type: 'uint8',
146
- internalType: 'enum OrderKind',
147
- },
148
- {
149
- name: 'nonce',
150
- type: 'uint256',
151
- internalType: 'uint256',
152
- },
153
- {
154
- name: 'partnerAndFee',
155
- type: 'uint256',
156
- internalType: 'uint256',
157
- },
158
- {
159
- name: 'permit',
160
- type: 'bytes',
161
- internalType: 'bytes',
162
- },
163
- {
164
- name: 'metadata',
165
- type: 'bytes',
166
- internalType: 'bytes',
167
- },
168
- {
169
- name: 'bridge',
170
- type: 'tuple',
171
- internalType: 'struct Bridge',
172
- components: [
173
- {
174
- name: 'protocolSelector',
175
- type: 'bytes4',
176
- internalType: 'bytes4',
177
- },
178
- {
179
- name: 'destinationChainId',
180
- type: 'uint256',
181
- internalType: 'uint256',
182
- },
183
- {
184
- name: 'outputToken',
185
- type: 'address',
186
- internalType: 'address',
187
- },
188
- {
189
- name: 'scalingFactor',
190
- type: 'int8',
191
- internalType: 'int8',
192
- },
193
- {
194
- name: 'protocolData',
195
- type: 'bytes',
196
- internalType: 'bytes',
197
- },
198
- ],
199
- },
200
- ],
97
+ name: 'owner',
98
+ type: 'address',
99
+ internalType: 'address',
100
+ },
101
+ {
102
+ name: 'beneficiary',
103
+ type: 'address',
104
+ internalType: 'address',
105
+ },
106
+ {
107
+ name: 'srcToken',
108
+ type: 'address',
109
+ internalType: 'address',
110
+ },
111
+ {
112
+ name: 'destToken',
113
+ type: 'address',
114
+ internalType: 'address',
115
+ },
116
+ {
117
+ name: 'srcAmount',
118
+ type: 'uint256',
119
+ internalType: 'uint256',
120
+ },
121
+ {
122
+ name: 'destAmount',
123
+ type: 'uint256',
124
+ internalType: 'uint256',
125
+ },
126
+ {
127
+ name: 'expectedAmount',
128
+ type: 'uint256',
129
+ internalType: 'uint256',
130
+ },
131
+ {
132
+ name: 'deadline',
133
+ type: 'uint256',
134
+ internalType: 'uint256',
135
+ },
136
+ {
137
+ name: 'kind',
138
+ type: 'uint8',
139
+ internalType: 'enum OrderKind',
140
+ },
141
+ {
142
+ name: 'nonce',
143
+ type: 'uint256',
144
+ internalType: 'uint256',
145
+ },
146
+ {
147
+ name: 'partnerAndFee',
148
+ type: 'uint256',
149
+ internalType: 'uint256',
150
+ },
151
+ {
152
+ name: 'permit',
153
+ type: 'bytes',
154
+ internalType: 'bytes',
201
155
  },
202
156
  {
203
- name: 'signature',
157
+ name: 'metadata',
204
158
  type: 'bytes',
205
159
  internalType: 'bytes',
206
160
  },
207
161
  {
208
- name: 'bridgeOverride',
162
+ name: 'bridge',
209
163
  type: 'tuple',
210
- internalType: 'struct BridgeOverride',
164
+ internalType: 'struct Bridge',
211
165
  components: [
212
166
  {
213
167
  name: 'protocolSelector',
214
168
  type: 'bytes4',
215
169
  internalType: 'bytes4',
216
170
  },
171
+ {
172
+ name: 'destinationChainId',
173
+ type: 'uint256',
174
+ internalType: 'uint256',
175
+ },
176
+ {
177
+ name: 'outputToken',
178
+ type: 'address',
179
+ internalType: 'address',
180
+ },
181
+ {
182
+ name: 'scalingFactor',
183
+ type: 'int8',
184
+ internalType: 'int8',
185
+ },
217
186
  {
218
187
  name: 'protocolData',
219
188
  type: 'bytes',
@@ -221,11 +190,6 @@ const DeltaTokenModuleAbi = [
221
190
  },
222
191
  ],
223
192
  },
224
- {
225
- name: 'cosignature',
226
- type: 'bytes',
227
- internalType: 'bytes',
228
- },
229
193
  ],
230
194
  },
231
195
  {
@@ -447,7 +411,7 @@ export const constructDeltaTokenModule = <T>(
447
411
  const { getDeltaContract } = constructGetDeltaContract(options);
448
412
 
449
413
  const cancelAndWithdrawDeltaOrder: CancelAndWithdrawDeltaOrder<T> = async (
450
- { order, signature, isFillable = false },
414
+ { order, isFillable = false },
451
415
  overrides = {},
452
416
  requestParams
453
417
  ) => {
@@ -456,23 +420,11 @@ export const constructDeltaTokenModule = <T>(
456
420
  throw new Error(`Delta is not available on chain ${options.chainId}`);
457
421
  }
458
422
 
459
- const orderWithSig = {
460
- order: sanitizeDeltaOrderData(order),
461
- signature,
462
- // bridgeOverride and cosignature are not used by the contract,
463
- // can always provide defaults
464
- bridgeOverride: {
465
- protocolData: DEFAULT_BRIDGE.protocolData,
466
- protocolSelector: DEFAULT_BRIDGE.protocolSelector,
467
- },
468
- cosignature: '0x',
469
- };
470
-
471
423
  const res = await options.contractCaller.transactCall<AvailableMethods>({
472
424
  address: ParaswapDelta,
473
425
  abi: DeltaTokenModuleAbi,
474
426
  contractMethod: 'cancelAndWithdraw',
475
- args: [orderWithSig, isFillable],
427
+ args: [sanitizeDeltaOrderData(order), isFillable],
476
428
  overrides,
477
429
  });
478
430
 
@@ -1,6 +1,5 @@
1
1
  import type { EnumerateLiteral } from '../../../types';
2
2
  import { SwapSide } from '../../../constants';
3
- import { Prettify } from 'ts-essentials';
4
3
 
5
4
  export type SwapSideUnion = EnumerateLiteral<typeof SwapSide>;
6
5
 
@@ -40,7 +39,7 @@ export type DeltaAmountsWithSlippage =
40
39
  | DeltaAmountsBuySlippage
41
40
  | DeltaAmountsExplicit;
42
41
 
43
- export enum OrderKind {
42
+ enum OrderKind {
44
43
  Sell = 0,
45
44
  Buy = 1,
46
45
  }
@@ -203,12 +202,6 @@ export type DeltaAuctionTransaction = {
203
202
  partnerFee: string;
204
203
  agent: string;
205
204
  auctionId: string;
206
-
207
- // bridge* fileds = null for single-chain orders and all TWAP orders
208
- bridgeMetadata: BridgeMetadata | null;
209
- bridgeStatus: BridgeStatus | null;
210
- bridgeProtocol: string | null;
211
- bridgeOverride: Pick<Bridge, 'protocolSelector' | 'protocolData'> | null;
212
205
  };
213
206
 
214
207
  export type OnChainOrderMap = {
@@ -218,18 +211,6 @@ export type OnChainOrderMap = {
218
211
  TWAPBuyOrder: TWAPBuyDeltaOrder;
219
212
  };
220
213
 
221
- type BaseBridgeAuctionFields = Pick<
222
- DeltaAuctionBase,
223
- 'bridgeMetadata' | 'bridgeStatus'
224
- >;
225
-
226
- type BridgeAuctionFiledsMap = {
227
- Order: BaseBridgeAuctionFields;
228
- ExternalOrder: BaseBridgeAuctionFields;
229
- TWAPOrder: Record<keyof BaseBridgeAuctionFields, null>;
230
- TWAPBuyOrder: Record<keyof BaseBridgeAuctionFields, null>;
231
- };
232
-
233
214
  type DeltaAuctionBase = {
234
215
  id: string;
235
216
  deltaVersion: string; // 1.0 or 2.0 currently
@@ -256,34 +237,19 @@ type DeltaAuctionBase = {
256
237
 
257
238
  export type DeltaAuction<T extends OnChainOrderType = OnChainOrderType> =
258
239
  T extends T
259
- ? Prettify<
260
- DeltaAuctionBase & {
261
- onChainOrderType: T;
262
- order: OnChainOrderMap[T];
263
- } & BridgeAuctionFiledsMap[T]
264
- >
240
+ ? DeltaAuctionBase & {
241
+ onChainOrderType: T;
242
+ order: OnChainOrderMap[T];
243
+ }
265
244
  : never;
266
245
 
267
- export type DeltaAuctionDelta = DeltaAuction<'Order'>;
268
- export type DeltaAuctionExternal = DeltaAuction<'ExternalOrder'>;
269
- export type DeltaAuctionTWAP = DeltaAuction<'TWAPOrder'>;
270
- export type DeltaAuctionTWAPBuy = DeltaAuction<'TWAPBuyOrder'>;
271
-
272
- export type DeltaAuctionUnion =
273
- | DeltaAuctionDelta
274
- | DeltaAuctionExternal
275
- | DeltaAuctionTWAP
276
- | DeltaAuctionTWAPBuy;
277
-
278
- export type DeltaOrderUnion = OnChainOrderMap[keyof OnChainOrderMap];
279
-
280
246
  export type BridgeMetadata = {
281
247
  /** @description The amount that user should expect to get */
282
248
  outputAmount: string;
283
249
  /** @description The cross-chain deadline. If deadline passes, the bridgeStatus would be expired */
284
- fillDeadline?: number; // available for Across protocol
250
+ fillDeadline: number;
285
251
  /** @description The deposit id */
286
- depositId?: number; // available for Across protocol
252
+ depositId: number;
287
253
  /** @description The transaction hash on the destination chain that fulfilled the order. When bridgeStatus='filled' */
288
254
  fillTx?: string;
289
255
  /** @description The transaction hash on the source chain that refunded the deposit. When bridgeStatus='refunded' */
@@ -320,35 +286,3 @@ export type BridgePriceInfo = {
320
286
  bestReturn: boolean;
321
287
  recommended: boolean;
322
288
  };
323
-
324
- export type UnifiedDeltaOrderData = {
325
- /** @description amounts at the start of Order execution and after Order execution. May differ from each other */
326
- amounts: {
327
- /** @description expected amounts at the start of Order execution */
328
- expected: {
329
- srcAmount: string;
330
- destAmount: string;
331
- };
332
- /** @description final amounts after Order execution. May be less than expected if there is slippage or only partial execution was achieved */
333
- final?: {
334
- srcAmount: string;
335
- destAmount: string;
336
- };
337
- };
338
- /** @description source chain id */
339
- srcChainId: number;
340
- /** @description destination chain id (same as source chain id for single chain orders) */
341
- destChainId: number;
342
- /** @description input token amount */
343
- srcAmount: string;
344
- /** @description output token amount (expected amount for pending orders, actual received amount for executed orders) */
345
- destAmount: string;
346
- /** @description input token address */
347
- srcToken: string;
348
- /** @description output token address */
349
- destToken: string;
350
- /** @description swap side of the order */
351
- swapSide: SwapSideUnion;
352
- /** @description filled percent of the order (based on transactions[].filledPercent) */
353
- filledPercent: number;
354
- };