@velora-dex/sdk 9.5.4-dev.1 → 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.
Files changed (96) hide show
  1. package/README.md +156 -0
  2. package/dist/examples/helpers/delta.d.ts +1 -1
  3. package/dist/examples/helpers/delta.d.ts.map +1 -1
  4. package/dist/examples/helpers/deltaV2.d.ts +3 -3
  5. package/dist/examples/helpers/deltaV2.d.ts.map +1 -1
  6. package/dist/index.d.ts +4 -17
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/methods/delta/helpers/orders.d.ts.map +1 -1
  9. package/dist/methods/delta/helpers/types.d.ts +11 -5
  10. package/dist/methods/delta/helpers/types.d.ts.map +1 -1
  11. package/dist/methods/deltaV2/{buildDeltaOrderV2.d.ts → buildDeltaOrder.d.ts} +10 -9
  12. package/dist/methods/deltaV2/buildDeltaOrder.d.ts.map +1 -0
  13. package/dist/methods/deltaV2/{buildExternalDeltaOrderV2.d.ts → buildExternalDeltaOrder.d.ts} +10 -9
  14. package/dist/methods/deltaV2/buildExternalDeltaOrder.d.ts.map +1 -0
  15. package/dist/methods/deltaV2/{buildTWAPDeltaOrderV2.d.ts → buildTWAPDeltaOrder.d.ts} +13 -12
  16. package/dist/methods/deltaV2/buildTWAPDeltaOrder.d.ts.map +1 -0
  17. package/dist/methods/deltaV2/cancelDeltaOrder.d.ts +21 -0
  18. package/dist/methods/deltaV2/cancelDeltaOrder.d.ts.map +1 -0
  19. package/dist/methods/deltaV2/getAgentsList.d.ts +10 -0
  20. package/dist/methods/deltaV2/getAgentsList.d.ts.map +1 -0
  21. package/dist/methods/deltaV2/getBridgeRoutes.d.ts +3 -3
  22. package/dist/methods/deltaV2/getBridgeRoutes.d.ts.map +1 -1
  23. package/dist/methods/deltaV2/getDeltaOrders.d.ts +40 -0
  24. package/dist/methods/deltaV2/getDeltaOrders.d.ts.map +1 -0
  25. package/dist/methods/deltaV2/{getDeltaPriceV2.d.ts → getDeltaPrice.d.ts} +7 -7
  26. package/dist/methods/deltaV2/getDeltaPrice.d.ts.map +1 -0
  27. package/dist/methods/deltaV2/helpers/orders.d.ts +191 -0
  28. package/dist/methods/deltaV2/helpers/orders.d.ts.map +1 -0
  29. package/dist/methods/deltaV2/index.d.ts +51 -38
  30. package/dist/methods/deltaV2/index.d.ts.map +1 -1
  31. package/dist/methods/deltaV2/isTokenSupportedInDelta.d.ts +8 -0
  32. package/dist/methods/deltaV2/isTokenSupportedInDelta.d.ts.map +1 -0
  33. package/dist/methods/deltaV2/{postDeltaOrderV2.d.ts → postDeltaOrder.d.ts} +9 -8
  34. package/dist/methods/deltaV2/postDeltaOrder.d.ts.map +1 -0
  35. package/dist/methods/deltaV2/postExternalDeltaOrder.d.ts +11 -0
  36. package/dist/methods/deltaV2/postExternalDeltaOrder.d.ts.map +1 -0
  37. package/dist/methods/deltaV2/postTWAPDeltaOrder.d.ts +17 -0
  38. package/dist/methods/deltaV2/postTWAPDeltaOrder.d.ts.map +1 -0
  39. package/dist/methods/deltaV2/types.d.ts +26 -20
  40. package/dist/methods/deltaV2/types.d.ts.map +1 -1
  41. package/dist/sdk/full.d.ts +1 -1
  42. package/dist/sdk/full.d.ts.map +1 -1
  43. package/dist/sdk/simple.d.ts +3 -9
  44. package/dist/sdk/simple.d.ts.map +1 -1
  45. package/dist/sdk.cjs.development.js +1600 -1298
  46. package/dist/sdk.cjs.development.js.map +1 -1
  47. package/dist/sdk.cjs.production.min.js +1 -1
  48. package/dist/sdk.cjs.production.min.js.map +1 -1
  49. package/dist/sdk.esm.js +1584 -1266
  50. package/dist/sdk.esm.js.map +1 -1
  51. package/package.json +1 -1
  52. package/src/constants.js +6 -1
  53. package/src/examples/deltaV2.ts +21 -25
  54. package/src/examples/helpers/delta.ts +6 -1
  55. package/src/examples/helpers/deltaV2.ts +9 -4
  56. package/src/index.js +167 -83
  57. package/src/index.ts +27 -143
  58. package/src/methods/delta/helpers/orders.ts +5 -1
  59. package/src/methods/delta/helpers/types.ts +19 -18
  60. package/src/methods/deltaV2/{buildDeltaOrderV2.ts → buildDeltaOrder.ts} +16 -16
  61. package/src/methods/deltaV2/{buildExternalDeltaOrderV2.ts → buildExternalDeltaOrder.ts} +16 -16
  62. package/src/methods/deltaV2/{buildTWAPDeltaOrderV2.ts → buildTWAPDeltaOrder.ts} +22 -22
  63. package/src/methods/deltaV2/{cancelDeltaOrderV2.ts → cancelDeltaOrder.ts} +17 -20
  64. package/src/methods/deltaV2/getAgentsList.ts +32 -0
  65. package/src/methods/deltaV2/getBridgeRoutes.ts +7 -7
  66. package/src/methods/deltaV2/getDeltaOrders.ts +149 -0
  67. package/src/methods/deltaV2/{getDeltaPriceV2.ts → getDeltaPrice.ts} +15 -15
  68. package/src/methods/deltaV2/helpers/orders.ts +363 -0
  69. package/src/methods/deltaV2/index.ts +148 -139
  70. package/src/methods/deltaV2/{isTokenSupportedInDeltaV2.ts → isTokenSupportedInDelta.ts} +7 -7
  71. package/src/methods/deltaV2/{postDeltaOrderV2.ts → postDeltaOrder.ts} +13 -16
  72. package/src/methods/deltaV2/postExternalDeltaOrder.ts +45 -0
  73. package/src/methods/deltaV2/{postTWAPDeltaOrderV2.ts → postTWAPDeltaOrder.ts} +14 -19
  74. package/src/methods/deltaV2/types.ts +35 -22
  75. package/src/sdk/full.ts +2 -2
  76. package/src/sdk/simple.ts +17 -43
  77. package/dist/methods/deltaV2/buildDeltaOrderV2.d.ts.map +0 -1
  78. package/dist/methods/deltaV2/buildExternalDeltaOrderV2.d.ts.map +0 -1
  79. package/dist/methods/deltaV2/buildTWAPDeltaOrderV2.d.ts.map +0 -1
  80. package/dist/methods/deltaV2/cancelDeltaOrderV2.d.ts +0 -21
  81. package/dist/methods/deltaV2/cancelDeltaOrderV2.d.ts.map +0 -1
  82. package/dist/methods/deltaV2/getAgentsListV2.d.ts +0 -10
  83. package/dist/methods/deltaV2/getAgentsListV2.d.ts.map +0 -1
  84. package/dist/methods/deltaV2/getDeltaOrdersV2.d.ts +0 -33
  85. package/dist/methods/deltaV2/getDeltaOrdersV2.d.ts.map +0 -1
  86. package/dist/methods/deltaV2/getDeltaPriceV2.d.ts.map +0 -1
  87. package/dist/methods/deltaV2/isTokenSupportedInDeltaV2.d.ts +0 -8
  88. package/dist/methods/deltaV2/isTokenSupportedInDeltaV2.d.ts.map +0 -1
  89. package/dist/methods/deltaV2/postDeltaOrderV2.d.ts.map +0 -1
  90. package/dist/methods/deltaV2/postExternalDeltaOrderV2.d.ts +0 -11
  91. package/dist/methods/deltaV2/postExternalDeltaOrderV2.d.ts.map +0 -1
  92. package/dist/methods/deltaV2/postTWAPDeltaOrderV2.d.ts +0 -16
  93. package/dist/methods/deltaV2/postTWAPDeltaOrderV2.d.ts.map +0 -1
  94. package/src/methods/deltaV2/getAgentsListV2.ts +0 -34
  95. package/src/methods/deltaV2/getDeltaOrdersV2.ts +0 -119
  96. package/src/methods/deltaV2/postExternalDeltaOrderV2.ts +0 -45
package/src/index.ts CHANGED
@@ -159,6 +159,7 @@ import type {
159
159
  DeltaAmountsBuySlippage,
160
160
  DeltaAmountsExplicit,
161
161
  DeltaAuctionDelta,
162
+ DeltaAuctionFillable,
162
163
  DeltaAuctionTWAP,
163
164
  DeltaAuctionTWAPBuy,
164
165
  DeltaAuctionExternal,
@@ -291,84 +292,6 @@ import {
291
292
  SignableCancelDeltaOrderData,
292
293
  } from './methods/delta/helpers/buildCancelDeltaOrderData';
293
294
 
294
- // Delta v2 modules
295
- import {
296
- BuildDeltaOrderV2Functions,
297
- BuildDeltaOrderV2Params,
298
- constructBuildDeltaOrderV2,
299
- } from './methods/deltaV2/buildDeltaOrderV2';
300
- import {
301
- BuildExternalDeltaOrderV2Functions,
302
- BuildExternalDeltaOrderV2Params,
303
- constructBuildExternalDeltaOrderV2,
304
- } from './methods/deltaV2/buildExternalDeltaOrderV2';
305
- import {
306
- BuildTWAPDeltaOrderV2Functions,
307
- BuildTWAPDeltaOrderV2Params,
308
- BuildTWAPSellDeltaOrderV2Params,
309
- BuildTWAPBuyDeltaOrderV2Params,
310
- constructBuildTWAPDeltaOrderV2,
311
- } from './methods/deltaV2/buildTWAPDeltaOrderV2';
312
- import {
313
- constructPostDeltaOrderV2,
314
- DeltaOrderToPostV2,
315
- PostDeltaOrderV2Functions,
316
- PostDeltaOrderV2Params,
317
- } from './methods/deltaV2/postDeltaOrderV2';
318
- import {
319
- constructPostExternalDeltaOrderV2,
320
- PostExternalDeltaOrderV2Functions,
321
- PostExternalDeltaOrderV2Params,
322
- } from './methods/deltaV2/postExternalDeltaOrderV2';
323
- import {
324
- constructPostTWAPDeltaOrderV2,
325
- PostTWAPDeltaOrderV2Functions,
326
- PostTWAPDeltaOrderV2Params,
327
- } from './methods/deltaV2/postTWAPDeltaOrderV2';
328
- import {
329
- constructGetDeltaPriceV2,
330
- DeltaPriceV2Params,
331
- GetDeltaPriceV2Functions,
332
- } from './methods/deltaV2/getDeltaPriceV2';
333
- import {
334
- constructGetDeltaOrdersV2,
335
- GetDeltaOrdersV2Functions,
336
- } from './methods/deltaV2/getDeltaOrdersV2';
337
- import {
338
- constructGetBridgeRoutes,
339
- GetBridgeRoutesFunctions,
340
- } from './methods/deltaV2/getBridgeRoutes';
341
- import {
342
- constructIsTokenSupportedInDeltaV2,
343
- IsTokenSupportedInDeltaV2Functions,
344
- } from './methods/deltaV2/isTokenSupportedInDeltaV2';
345
- import {
346
- CancelDeltaOrderV2Functions,
347
- constructCancelDeltaOrderV2,
348
- } from './methods/deltaV2/cancelDeltaOrderV2';
349
- import {
350
- AgentList,
351
- constructGetAgentsListV2,
352
- GetAgentsListV2Functions,
353
- } from './methods/deltaV2/getAgentsListV2';
354
- import type {
355
- DeltaOrderStatusV2,
356
- BuiltDeltaOrderV2,
357
- DeltaPriceToken,
358
- DeltaTokenAmount,
359
- BridgeTag,
360
- DeltaRouteBridge,
361
- DeltaRouteBridgeContractParams,
362
- DeltaRouteStep,
363
- DeltaRoute,
364
- DeltaPriceV2,
365
- BridgeRoute,
366
- DeltaOnChainOrderTypeReported,
367
- DeltaTokenSide,
368
- DeltaTransactionV2,
369
- DeltaOrderV2Response,
370
- } from './methods/deltaV2/types';
371
-
372
295
  export { constructSwapSDK, SwapSDKMethods } from './methods/swap';
373
296
 
374
297
  export {
@@ -388,18 +311,31 @@ export {
388
311
  SubmitTWAPDeltaOrderParams,
389
312
  } from './methods/delta';
390
313
 
391
- export {
392
- constructAllDeltaV2OrdersHandlers,
393
- constructSubmitDeltaOrderV2,
394
- constructSubmitExternalDeltaOrderV2,
395
- constructSubmitTWAPDeltaOrderV2,
396
- constructSignDeltaOrderV2,
397
- DeltaV2OrderHandlers,
398
- SubmitDeltaOrderV2Params,
399
- SubmitExternalDeltaOrderV2Params,
400
- SubmitTWAPDeltaOrderV2Params,
401
- SignDeltaOrderV2Functions,
402
- } from './methods/deltaV2';
314
+ // Delta v2 is exposed as a single namespace so it can ship alongside v1 without
315
+ // colliding at the top level. v2 source uses unsuffixed names internally
316
+ // (constructBuildDeltaOrder, BuiltDeltaOrder, DeltaPrice, ...); consumers reach
317
+ // them via `DeltaV2.constructBuildDeltaOrder` etc.
318
+ //
319
+ // Migration plan when deprecating v1 (breaking change):
320
+ // 1. Replace the bare `export { ... } from './methods/delta'` block above with
321
+ // `export * from './methods/deltaV2'` (or named re-exports of v2 symbols).
322
+ // Top-level `constructPostDeltaOrder` now resolves to v2.
323
+ // 2. Move v1 behind its own namespace for backcompat:
324
+ // `export * as DeltaV1 from './methods/delta'`.
325
+ // 3. Keep `export * as DeltaV2 from './methods/deltaV2'` as a redundant alias
326
+ // so code written against the v2 namespace today keeps compiling.
327
+ // 4. Mirror this on the bundled SDKs in sdk/full.ts and sdk/simple.ts:
328
+ // `sdk.delta.*` flips to v2 (use `constructAllDeltaOrdersHandlers` from
329
+ // './methods/deltaV2'), and add `sdk.deltaV1.*` for backcompat.
330
+ //
331
+ // Migration plan when dropping v1 entirely:
332
+ // - Delete the `DeltaV1` namespace export and `sdk.deltaV1` field.
333
+ // - Delete `src/methods/delta/`.
334
+ // - Delete the `DeltaV2` re-export alias (consumers can move to bare names).
335
+ // - The `methods/deltaV2/` folder can be renamed to `methods/delta/` (and the
336
+ // `/delta/v2/` URL prefix in the leaf modules updated if the server has by
337
+ // then collapsed v1 and v2 endpoints).
338
+ export * as DeltaV2 from './methods/deltaV2';
403
339
 
404
340
  export type {
405
341
  TransactionParams,
@@ -483,21 +419,6 @@ export {
483
419
  constructPreSignTWAPDeltaOrder,
484
420
  // Quote methods
485
421
  constructGetQuote,
486
- // Delta v2 runtime values (const-object enums etc.)
487
- DeltaOrderStatusV2,
488
- // Delta V2 methods
489
- constructBuildDeltaOrderV2,
490
- constructBuildExternalDeltaOrderV2,
491
- constructBuildTWAPDeltaOrderV2,
492
- constructPostDeltaOrderV2,
493
- constructPostExternalDeltaOrderV2,
494
- constructPostTWAPDeltaOrderV2,
495
- constructGetDeltaPriceV2,
496
- constructGetDeltaOrdersV2,
497
- constructGetBridgeRoutes,
498
- constructIsTokenSupportedInDeltaV2,
499
- constructCancelDeltaOrderV2,
500
- constructGetAgentsListV2,
501
422
  // different helpers
502
423
  constructGetPartnerFee,
503
424
  constructGetBridgeInfo,
@@ -568,6 +489,7 @@ export type {
568
489
  DeltaAuctionOrder,
569
490
  DeltaAuction,
570
491
  DeltaAuctionDelta,
492
+ DeltaAuctionFillable,
571
493
  DeltaAuctionTWAP,
572
494
  DeltaAuctionTWAPBuy,
573
495
  DeltaAuctionExternal,
@@ -635,44 +557,6 @@ export type {
635
557
  PostTWAPDeltaOrderFunctions,
636
558
  PostTWAPDeltaOrderParams,
637
559
  PreSignTWAPDeltaOrderFunctions,
638
- // Delta v2 types
639
- BuiltDeltaOrderV2,
640
- DeltaPriceToken,
641
- DeltaTokenAmount,
642
- BridgeTag,
643
- DeltaRouteBridge,
644
- DeltaRouteBridgeContractParams,
645
- DeltaRouteStep,
646
- DeltaRoute,
647
- DeltaPriceV2,
648
- BridgeRoute,
649
- DeltaOnChainOrderTypeReported,
650
- DeltaTokenSide,
651
- DeltaTransactionV2,
652
- DeltaOrderV2Response,
653
- DeltaPriceV2Params,
654
- GetDeltaPriceV2Functions,
655
- GetDeltaOrdersV2Functions,
656
- GetBridgeRoutesFunctions,
657
- IsTokenSupportedInDeltaV2Functions,
658
- BuildDeltaOrderV2Params,
659
- BuildDeltaOrderV2Functions,
660
- BuildExternalDeltaOrderV2Params,
661
- BuildExternalDeltaOrderV2Functions,
662
- BuildTWAPDeltaOrderV2Params,
663
- BuildTWAPSellDeltaOrderV2Params,
664
- BuildTWAPBuyDeltaOrderV2Params,
665
- BuildTWAPDeltaOrderV2Functions,
666
- DeltaOrderToPostV2,
667
- PostDeltaOrderV2Params,
668
- PostDeltaOrderV2Functions,
669
- PostExternalDeltaOrderV2Params,
670
- PostExternalDeltaOrderV2Functions,
671
- PostTWAPDeltaOrderV2Params,
672
- PostTWAPDeltaOrderV2Functions,
673
- CancelDeltaOrderV2Functions,
674
- AgentList as AgentInfo,
675
- GetAgentsListV2Functions,
676
560
  // types for Quote methods
677
561
  GetQuoteFunctions,
678
562
  QuoteParams,
@@ -358,7 +358,11 @@ function getTransactionAmounts(transactions: DeltaAuctionTransaction[]) {
358
358
  srcAmount: acc.srcAmount + BigInt(spentAmount),
359
359
  destAmount:
360
360
  acc.destAmount +
361
- BigInt(bridgeMetadata ? bridgeMetadata.outputAmount : receivedAmount),
361
+ BigInt(
362
+ bridgeMetadata?.outputAmount
363
+ ? bridgeMetadata.outputAmount
364
+ : receivedAmount
365
+ ),
362
366
  };
363
367
  },
364
368
  {
@@ -248,6 +248,7 @@ export type DeltaAuctionTransaction = {
248
248
 
249
249
  export type OnChainOrderMap = {
250
250
  Order: DeltaAuctionOrder;
251
+ FillableOrder: DeltaAuctionOrder;
251
252
  ExternalOrder: ExternalDeltaOrder;
252
253
  TWAPOrder: TWAPDeltaOrder;
253
254
  TWAPBuyOrder: TWAPBuyDeltaOrder;
@@ -261,6 +262,7 @@ type BaseBridgeAuctionFields = Pick<
261
262
 
262
263
  type BridgeAuctionFiledsMap = {
263
264
  Order: BaseBridgeAuctionFields;
265
+ FillableOrder: BaseBridgeAuctionFields;
264
266
  ExternalOrder: BaseBridgeAuctionFields;
265
267
  TWAPOrder: Record<keyof BaseBridgeAuctionFields, null>;
266
268
  TWAPBuyOrder: Record<keyof BaseBridgeAuctionFields, null>;
@@ -292,18 +294,18 @@ type DeltaAuctionBase = {
292
294
  type: DeltaOrderType;
293
295
  };
294
296
 
295
- export type DeltaAuction<
296
- T extends keyof OnChainOrderMap = keyof OnChainOrderMap,
297
- > = T extends T
298
- ? Prettify<
299
- DeltaAuctionBase & {
300
- onChainOrderType: T;
301
- order: OnChainOrderMap[T];
302
- } & BridgeAuctionFiledsMap[T]
303
- >
304
- : never;
297
+ export type DeltaAuction<T extends OnChainOrderType = OnChainOrderType> =
298
+ T extends T
299
+ ? Prettify<
300
+ DeltaAuctionBase & {
301
+ onChainOrderType: T;
302
+ order: OnChainOrderMap[T];
303
+ } & BridgeAuctionFiledsMap[T]
304
+ >
305
+ : never;
305
306
 
306
307
  export type DeltaAuctionDelta = DeltaAuction<'Order'>;
308
+ export type DeltaAuctionFillable = DeltaAuction<'FillableOrder'>;
307
309
  export type DeltaAuctionExternal = DeltaAuction<'ExternalOrder'>;
308
310
  export type DeltaAuctionTWAP = DeltaAuction<'TWAPOrder'>;
309
311
  export type DeltaAuctionTWAPBuy = DeltaAuction<'TWAPBuyOrder'>;
@@ -311,6 +313,7 @@ export type DeltaAuctionProductive = DeltaAuction<'ProductiveOrder'>;
311
313
 
312
314
  export type DeltaAuctionUnion =
313
315
  | DeltaAuctionDelta
316
+ | DeltaAuctionFillable
314
317
  | DeltaAuctionExternal
315
318
  | DeltaAuctionTWAP
316
319
  | DeltaAuctionTWAPBuy
@@ -319,8 +322,11 @@ export type DeltaAuctionUnion =
319
322
  export type DeltaOrderUnion = OnChainOrderMap[keyof OnChainOrderMap];
320
323
 
321
324
  export type BridgeMetadata = {
322
- /** @description Actual amount received on the destination chain. */
323
- outputAmount: string;
325
+ /** @description Field is present after bridge is executed.
326
+ * The actual amount received from the bridge, which may differ
327
+ * from the expectedOutputAmount due to bridge slippage or other factors.
328
+ * */
329
+ outputAmount?: string;
324
330
  /** @description Field is present iff: order was built via POST /v2/orders/build,
325
331
  * the route is cross-chain (route.bridge !== null and not an external handler),
326
332
  * and the order is posted before the per-order cache entry expires.
@@ -339,12 +345,7 @@ export type BridgeMetadata = {
339
345
  // refunded is basically failed
340
346
  export type BridgeStatus = 'pending' | 'filled' | 'expired' | 'refunded';
341
347
 
342
- export type OnChainOrderType =
343
- | 'Order'
344
- | 'ExternalOrder'
345
- | 'TWAPOrder'
346
- | 'TWAPBuyOrder'
347
- | 'ProductiveOrder';
348
+ export type OnChainOrderType = keyof OnChainOrderMap;
348
349
 
349
350
  export type TWAPOnChainOrderType = 'TWAPOrder' | 'TWAPBuyOrder';
350
351
 
@@ -1,9 +1,10 @@
1
1
  import { API_URL } from '../../constants';
2
2
  import type { ConstructFetchInput, RequestParameters } from '../../types';
3
- import type { BuiltDeltaOrderV2, DeltaRoute } from './types';
4
- export type { BuiltDeltaOrderV2 } from './types';
3
+ import type { DeltaAuctionOrder } from '../delta/helpers/types';
4
+ import type { BuiltDeltaOrder, DeltaRoute } from './types';
5
+ export type { BuiltDeltaOrder } from './types';
5
6
 
6
- export type BuildDeltaOrderV2Params = {
7
+ export type BuildDeltaOrderParams = {
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. */
@@ -29,7 +30,7 @@ export type BuildDeltaOrderV2Params = {
29
30
  /** @description Designates the Order as partially fillable instead of fill-or-kill. Default false. */
30
31
  partiallyFillable?: boolean;
31
32
 
32
- /** @description DeltaRoute from getDeltaPriceV2 — either priceV2.route or any priceV2.alternatives[i] */
33
+ /** @description DeltaRoute from getDeltaPrice — either price.route or any price.alternatives[i] */
33
34
  route: DeltaRoute;
34
35
  /** @description Order side. SELL or BUY. */
35
36
  side: 'SELL' | 'BUY';
@@ -39,28 +40,27 @@ export type BuildDeltaOrderV2Params = {
39
40
  limitAmount?: string;
40
41
  };
41
42
 
42
- type BuildDeltaOrderV2 = (
43
- buildOrderParams: BuildDeltaOrderV2Params,
43
+ type BuildDeltaOrder = (
44
+ buildOrderParams: BuildDeltaOrderParams,
44
45
  requestParams?: RequestParameters
45
- ) => Promise<BuiltDeltaOrderV2>;
46
+ ) => Promise<BuiltDeltaOrder<DeltaAuctionOrder>>;
46
47
 
47
- export type BuildDeltaOrderV2Functions = {
48
+ export type BuildDeltaOrderFunctions = {
48
49
  /** @description Build a Delta v2 order from a DeltaRoute via the server endpoint, ready to sign and post. */
49
- buildDeltaOrderV2: BuildDeltaOrderV2;
50
+ buildDeltaOrder: BuildDeltaOrder;
50
51
  };
51
52
 
52
- export const constructBuildDeltaOrderV2 = (
53
+ export const constructBuildDeltaOrder = (
53
54
  options: ConstructFetchInput
54
- ): BuildDeltaOrderV2Functions => {
55
- const { apiURL = API_URL, chainId, fetcher } = options;
55
+ ): BuildDeltaOrderFunctions => {
56
+ const { apiURL = API_URL, fetcher } = options;
56
57
  const buildUrl = `${apiURL}/delta/v2/orders/build` as const;
57
58
 
58
- const buildDeltaOrderV2: BuildDeltaOrderV2 = async (params, requestParams) =>
59
- fetcher<BuiltDeltaOrderV2>({
59
+ const buildDeltaOrder: BuildDeltaOrder = async (params, requestParams) =>
60
+ fetcher<BuiltDeltaOrder<DeltaAuctionOrder>>({
60
61
  url: buildUrl,
61
62
  method: 'POST',
62
63
  data: {
63
- chainId,
64
64
  side: params.side,
65
65
  route: params.route,
66
66
  owner: params.owner,
@@ -82,5 +82,5 @@ export const constructBuildDeltaOrderV2 = (
82
82
  requestParams,
83
83
  });
84
84
 
85
- return { buildDeltaOrderV2 };
85
+ return { buildDeltaOrder };
86
86
  };
@@ -1,9 +1,10 @@
1
1
  import { API_URL } from '../../constants';
2
2
  import type { ConstructFetchInput, RequestParameters } from '../../types';
3
- import type { BuiltDeltaOrderV2, DeltaRoute } from './types';
4
- export type { BuiltDeltaOrderV2 } from './types';
3
+ import type { ExternalDeltaOrder } from '../delta/helpers/types';
4
+ import type { BuiltDeltaOrder, DeltaRoute } from './types';
5
+ export type { BuiltDeltaOrder } from './types';
5
6
 
6
- export type BuildExternalDeltaOrderV2Params = {
7
+ export type BuildExternalDeltaOrderParams = {
7
8
  /** @description The address of the order owner */
8
9
  owner: string;
9
10
  /** @description The address of the external handler contract */
@@ -33,7 +34,7 @@ export type BuildExternalDeltaOrderV2Params = {
33
34
  /** @description Designates the Order as partially fillable. Default false. */
34
35
  partiallyFillable?: boolean;
35
36
 
36
- /** @description DeltaRoute from getDeltaPriceV2 */
37
+ /** @description DeltaRoute from getDeltaPrice */
37
38
  route: DeltaRoute;
38
39
  /** @description Order side. SELL or BUY. */
39
40
  side: 'SELL' | 'BUY';
@@ -43,31 +44,30 @@ export type BuildExternalDeltaOrderV2Params = {
43
44
  limitAmount?: string;
44
45
  };
45
46
 
46
- type BuildExternalDeltaOrderV2 = (
47
- buildOrderParams: BuildExternalDeltaOrderV2Params,
47
+ type BuildExternalDeltaOrder = (
48
+ buildOrderParams: BuildExternalDeltaOrderParams,
48
49
  requestParams?: RequestParameters
49
- ) => Promise<BuiltDeltaOrderV2>;
50
+ ) => Promise<BuiltDeltaOrder<ExternalDeltaOrder>>;
50
51
 
51
- export type BuildExternalDeltaOrderV2Functions = {
52
+ export type BuildExternalDeltaOrderFunctions = {
52
53
  /** @description Build a Delta v2 External Order from a DeltaRoute via the server endpoint, ready to sign and post. */
53
- buildExternalDeltaOrderV2: BuildExternalDeltaOrderV2;
54
+ buildExternalDeltaOrder: BuildExternalDeltaOrder;
54
55
  };
55
56
 
56
- export const constructBuildExternalDeltaOrderV2 = (
57
+ export const constructBuildExternalDeltaOrder = (
57
58
  options: ConstructFetchInput
58
- ): BuildExternalDeltaOrderV2Functions => {
59
- const { apiURL = API_URL, chainId, fetcher } = options;
59
+ ): BuildExternalDeltaOrderFunctions => {
60
+ const { apiURL = API_URL, fetcher } = options;
60
61
  const buildUrl = `${apiURL}/delta/v2/orders/build` as const;
61
62
 
62
- const buildExternalDeltaOrderV2: BuildExternalDeltaOrderV2 = async (
63
+ const buildExternalDeltaOrder: BuildExternalDeltaOrder = async (
63
64
  params,
64
65
  requestParams
65
66
  ) =>
66
- fetcher<BuiltDeltaOrderV2>({
67
+ fetcher<BuiltDeltaOrder<ExternalDeltaOrder>>({
67
68
  url: buildUrl,
68
69
  method: 'POST',
69
70
  data: {
70
- chainId,
71
71
  side: params.side,
72
72
  route: params.route,
73
73
  owner: params.owner,
@@ -91,5 +91,5 @@ export const constructBuildExternalDeltaOrderV2 = (
91
91
  requestParams,
92
92
  });
93
93
 
94
- return { buildExternalDeltaOrderV2 };
94
+ return { buildExternalDeltaOrder };
95
95
  };
@@ -1,9 +1,10 @@
1
1
  import { API_URL } from '../../constants';
2
2
  import type { ConstructFetchInput, RequestParameters } from '../../types';
3
- import type { BuiltDeltaOrderV2, DeltaRoute } from './types';
4
- export type { BuiltDeltaOrderV2 } from './types';
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 BuildTWAPDeltaOrderV2Base = {
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 getDeltaPriceV2 for a single slice */
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 BuildTWAPSellDeltaOrderV2Params = BuildTWAPDeltaOrderV2Base & {
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 BuildTWAPBuyDeltaOrderV2Params = BuildTWAPDeltaOrderV2Base & {
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 BuildTWAPDeltaOrderV2Params =
58
- | BuildTWAPSellDeltaOrderV2Params
59
- | BuildTWAPBuyDeltaOrderV2Params;
58
+ export type BuildTWAPDeltaOrderParams =
59
+ | BuildTWAPSellDeltaOrderParams
60
+ | BuildTWAPBuyDeltaOrderParams;
60
61
 
61
- type BuildTWAPDeltaOrderV2 = (
62
- buildOrderParams: BuildTWAPDeltaOrderV2Params,
62
+ type BuildTWAPDeltaOrder = (
63
+ buildOrderParams: BuildTWAPDeltaOrderParams,
63
64
  requestParams?: RequestParameters
64
- ) => Promise<BuiltDeltaOrderV2>;
65
+ ) => Promise<BuiltDeltaOrder<TWAPDeltaOrder | TWAPBuyDeltaOrder>>;
65
66
 
66
- export type BuildTWAPDeltaOrderV2Functions = {
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
- buildTWAPDeltaOrderV2: BuildTWAPDeltaOrderV2;
69
+ buildTWAPDeltaOrder: BuildTWAPDeltaOrder;
69
70
  };
70
71
 
71
- export const constructBuildTWAPDeltaOrderV2 = (
72
+ export const constructBuildTWAPDeltaOrder = (
72
73
  options: ConstructFetchInput
73
- ): BuildTWAPDeltaOrderV2Functions => {
74
- const { apiURL = API_URL, chainId, fetcher } = options;
74
+ ): BuildTWAPDeltaOrderFunctions => {
75
+ const { apiURL = API_URL, fetcher } = options;
75
76
  const buildUrl = `${apiURL}/delta/v2/orders/build` as const;
76
77
 
77
- const buildTWAPDeltaOrderV2: BuildTWAPDeltaOrderV2 = async (
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<BuiltDeltaOrderV2>({
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<BuiltDeltaOrderV2>({
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 { buildTWAPDeltaOrderV2 };
130
+ return { buildTWAPDeltaOrder };
131
131
  };
@@ -16,39 +16,39 @@ type CancelDeltaOrderRequestParams = {
16
16
  signature: string;
17
17
  };
18
18
 
19
- export type SignCancelDeltaOrderRequestV2 = (
19
+ export type SignCancelDeltaOrderRequest = (
20
20
  params: CancelDeltaOrderData,
21
21
  requestParams?: RequestParameters
22
22
  ) => Promise<string>;
23
23
 
24
- export type PostCancelDeltaOrderRequestV2 = (
24
+ export type PostCancelDeltaOrderRequest = (
25
25
  params: CancelDeltaOrderRequestParams,
26
26
  requestParams?: RequestParameters
27
27
  ) => Promise<SuccessResponse>;
28
28
 
29
- export type CancelDeltaOrderV2 = (
29
+ export type CancelDeltaOrder = (
30
30
  params: CancelDeltaOrderData,
31
31
  requestParams?: RequestParameters
32
32
  ) => Promise<SuccessResponse>;
33
33
 
34
- export type CancelDeltaOrderV2Functions = {
35
- signCancelDeltaOrderRequestV2: SignCancelDeltaOrderRequestV2;
36
- postCancelDeltaOrderRequestV2: PostCancelDeltaOrderRequestV2;
34
+ export type CancelDeltaOrderFunctions = {
35
+ signCancelDeltaOrderRequest: SignCancelDeltaOrderRequest;
36
+ postCancelDeltaOrderRequest: PostCancelDeltaOrderRequest;
37
37
  /** @description Cancel one or more Delta orders via the v2 endpoint */
38
- cancelDeltaOrdersV2: CancelDeltaOrderV2;
38
+ cancelDeltaOrders: CancelDeltaOrder;
39
39
  };
40
40
 
41
- export const constructCancelDeltaOrderV2 = (
41
+ export const constructCancelDeltaOrder = (
42
42
  options: Pick<
43
43
  ConstructProviderFetchInput<any, 'signTypedDataCall'>,
44
44
  'contractCaller' | 'fetcher' | 'apiURL' | 'chainId'
45
45
  >
46
- ): CancelDeltaOrderV2Functions => {
46
+ ): CancelDeltaOrderFunctions => {
47
47
  const apiURL = options.apiURL ?? API_URL;
48
48
 
49
49
  const { getDeltaContract } = constructGetDeltaContract(options);
50
50
 
51
- const signCancelDeltaOrderRequestV2: SignCancelDeltaOrderRequestV2 = async (
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 postCancelDeltaOrderRequestV2: PostCancelDeltaOrderRequestV2 = async (
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 cancelDeltaOrdersV2: CancelDeltaOrderV2 = async (
83
+ const cancelDeltaOrders: CancelDeltaOrder = async (
84
84
  { orderIds },
85
85
  requestParams
86
86
  ) => {
87
- const signature = await signCancelDeltaOrderRequestV2(
87
+ const signature = await signCancelDeltaOrderRequest(
88
88
  { orderIds },
89
89
  requestParams
90
90
  );
91
91
 
92
- return postCancelDeltaOrderRequestV2(
93
- { orderIds, signature },
94
- requestParams
95
- );
92
+ return postCancelDeltaOrderRequest({ orderIds, signature }, requestParams);
96
93
  };
97
94
 
98
95
  return {
99
- signCancelDeltaOrderRequestV2,
100
- postCancelDeltaOrderRequestV2,
101
- cancelDeltaOrdersV2,
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
+ };