@velora-dex/sdk 9.5.4-dev.0 → 9.5.4-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -0
- package/dist/examples/helpers/delta.d.ts +1 -1
- package/dist/examples/helpers/delta.d.ts.map +1 -1
- package/dist/examples/helpers/deltaV2.d.ts +3 -3
- package/dist/examples/helpers/deltaV2.d.ts.map +1 -1
- package/dist/examples/wagmi.d.ts.map +1 -1
- package/dist/index.d.ts +4 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/methods/delta/helpers/orders.d.ts +16 -1
- package/dist/methods/delta/helpers/orders.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts +48 -5
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/methods/deltaV2/{buildDeltaOrderV2.d.ts → buildDeltaOrder.d.ts} +10 -9
- package/dist/methods/deltaV2/buildDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/{buildExternalDeltaOrderV2.d.ts → buildExternalDeltaOrder.d.ts} +10 -9
- package/dist/methods/deltaV2/buildExternalDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/{buildTWAPDeltaOrderV2.d.ts → buildTWAPDeltaOrder.d.ts} +13 -12
- package/dist/methods/deltaV2/buildTWAPDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/cancelDeltaOrder.d.ts +21 -0
- package/dist/methods/deltaV2/cancelDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/getAgentsList.d.ts +10 -0
- package/dist/methods/deltaV2/getAgentsList.d.ts.map +1 -0
- package/dist/methods/deltaV2/getBridgeRoutes.d.ts +3 -3
- package/dist/methods/deltaV2/getBridgeRoutes.d.ts.map +1 -1
- package/dist/methods/deltaV2/getDeltaOrders.d.ts +40 -0
- package/dist/methods/deltaV2/getDeltaOrders.d.ts.map +1 -0
- package/dist/methods/deltaV2/{getDeltaPriceV2.d.ts → getDeltaPrice.d.ts} +7 -7
- package/dist/methods/deltaV2/getDeltaPrice.d.ts.map +1 -0
- package/dist/methods/deltaV2/helpers/orders.d.ts +191 -0
- package/dist/methods/deltaV2/helpers/orders.d.ts.map +1 -0
- package/dist/methods/deltaV2/index.d.ts +51 -38
- package/dist/methods/deltaV2/index.d.ts.map +1 -1
- package/dist/methods/deltaV2/isTokenSupportedInDelta.d.ts +8 -0
- package/dist/methods/deltaV2/isTokenSupportedInDelta.d.ts.map +1 -0
- package/dist/methods/deltaV2/{postDeltaOrderV2.d.ts → postDeltaOrder.d.ts} +9 -8
- package/dist/methods/deltaV2/postDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/postExternalDeltaOrder.d.ts +11 -0
- package/dist/methods/deltaV2/postExternalDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/postTWAPDeltaOrder.d.ts +17 -0
- package/dist/methods/deltaV2/postTWAPDeltaOrder.d.ts.map +1 -0
- package/dist/methods/deltaV2/types.d.ts +26 -20
- package/dist/methods/deltaV2/types.d.ts.map +1 -1
- package/dist/sdk/full.d.ts +1 -1
- package/dist/sdk/full.d.ts.map +1 -1
- package/dist/sdk/simple.d.ts +3 -9
- package/dist/sdk/simple.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +1602 -1281
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +1586 -1249
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.js +6 -1
- package/src/examples/deltaV2.ts +21 -25
- package/src/examples/helpers/delta.ts +6 -1
- package/src/examples/helpers/deltaV2.ts +9 -4
- package/src/index.js +167 -83
- package/src/index.ts +32 -143
- package/src/methods/delta/helpers/orders.ts +31 -1
- package/src/methods/delta/helpers/types.ts +59 -19
- package/src/methods/deltaV2/{buildDeltaOrderV2.ts → buildDeltaOrder.ts} +16 -16
- package/src/methods/deltaV2/{buildExternalDeltaOrderV2.ts → buildExternalDeltaOrder.ts} +16 -16
- package/src/methods/deltaV2/{buildTWAPDeltaOrderV2.ts → buildTWAPDeltaOrder.ts} +22 -22
- package/src/methods/deltaV2/{cancelDeltaOrderV2.ts → cancelDeltaOrder.ts} +17 -20
- package/src/methods/deltaV2/getAgentsList.ts +32 -0
- package/src/methods/deltaV2/getBridgeRoutes.ts +7 -7
- package/src/methods/deltaV2/getDeltaOrders.ts +149 -0
- package/src/methods/deltaV2/{getDeltaPriceV2.ts → getDeltaPrice.ts} +15 -15
- package/src/methods/deltaV2/helpers/orders.ts +363 -0
- package/src/methods/deltaV2/index.ts +148 -139
- package/src/methods/deltaV2/{isTokenSupportedInDeltaV2.ts → isTokenSupportedInDelta.ts} +7 -7
- package/src/methods/deltaV2/{postDeltaOrderV2.ts → postDeltaOrder.ts} +13 -16
- package/src/methods/deltaV2/postExternalDeltaOrder.ts +45 -0
- package/src/methods/deltaV2/{postTWAPDeltaOrderV2.ts → postTWAPDeltaOrder.ts} +14 -19
- package/src/methods/deltaV2/types.ts +35 -22
- package/src/sdk/full.ts +2 -2
- package/src/sdk/simple.ts +17 -43
- package/dist/methods/deltaV2/buildDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/buildExternalDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/buildTWAPDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/cancelDeltaOrderV2.d.ts +0 -21
- package/dist/methods/deltaV2/cancelDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/getAgentsListV2.d.ts +0 -10
- package/dist/methods/deltaV2/getAgentsListV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/getDeltaOrdersV2.d.ts +0 -33
- package/dist/methods/deltaV2/getDeltaOrdersV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/getDeltaPriceV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/isTokenSupportedInDeltaV2.d.ts +0 -8
- package/dist/methods/deltaV2/isTokenSupportedInDeltaV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/postDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/postExternalDeltaOrderV2.d.ts +0 -11
- package/dist/methods/deltaV2/postExternalDeltaOrderV2.d.ts.map +0 -1
- package/dist/methods/deltaV2/postTWAPDeltaOrderV2.d.ts +0 -16
- package/dist/methods/deltaV2/postTWAPDeltaOrderV2.d.ts.map +0 -1
- package/src/methods/deltaV2/getAgentsListV2.ts +0 -34
- package/src/methods/deltaV2/getDeltaOrdersV2.ts +0 -119
- package/src/methods/deltaV2/postExternalDeltaOrderV2.ts +0 -45
package/src/index.ts
CHANGED
|
@@ -147,6 +147,7 @@ import type {
|
|
|
147
147
|
BridgeStatus,
|
|
148
148
|
Bridge,
|
|
149
149
|
ExternalDeltaOrder,
|
|
150
|
+
ProductiveDeltaOrder,
|
|
150
151
|
TWAPDeltaOrder,
|
|
151
152
|
TWAPBuyDeltaOrder,
|
|
152
153
|
TWAPOnChainOrderType,
|
|
@@ -158,9 +159,11 @@ import type {
|
|
|
158
159
|
DeltaAmountsBuySlippage,
|
|
159
160
|
DeltaAmountsExplicit,
|
|
160
161
|
DeltaAuctionDelta,
|
|
162
|
+
DeltaAuctionFillable,
|
|
161
163
|
DeltaAuctionTWAP,
|
|
162
164
|
DeltaAuctionTWAPBuy,
|
|
163
165
|
DeltaAuctionExternal,
|
|
166
|
+
DeltaAuctionProductive,
|
|
164
167
|
DeltaOrderUnion,
|
|
165
168
|
DeltaAuctionUnion,
|
|
166
169
|
UnifiedDeltaOrderData,
|
|
@@ -289,84 +292,6 @@ import {
|
|
|
289
292
|
SignableCancelDeltaOrderData,
|
|
290
293
|
} from './methods/delta/helpers/buildCancelDeltaOrderData';
|
|
291
294
|
|
|
292
|
-
// Delta v2 modules
|
|
293
|
-
import {
|
|
294
|
-
BuildDeltaOrderV2Functions,
|
|
295
|
-
BuildDeltaOrderV2Params,
|
|
296
|
-
constructBuildDeltaOrderV2,
|
|
297
|
-
} from './methods/deltaV2/buildDeltaOrderV2';
|
|
298
|
-
import {
|
|
299
|
-
BuildExternalDeltaOrderV2Functions,
|
|
300
|
-
BuildExternalDeltaOrderV2Params,
|
|
301
|
-
constructBuildExternalDeltaOrderV2,
|
|
302
|
-
} from './methods/deltaV2/buildExternalDeltaOrderV2';
|
|
303
|
-
import {
|
|
304
|
-
BuildTWAPDeltaOrderV2Functions,
|
|
305
|
-
BuildTWAPDeltaOrderV2Params,
|
|
306
|
-
BuildTWAPSellDeltaOrderV2Params,
|
|
307
|
-
BuildTWAPBuyDeltaOrderV2Params,
|
|
308
|
-
constructBuildTWAPDeltaOrderV2,
|
|
309
|
-
} from './methods/deltaV2/buildTWAPDeltaOrderV2';
|
|
310
|
-
import {
|
|
311
|
-
constructPostDeltaOrderV2,
|
|
312
|
-
DeltaOrderToPostV2,
|
|
313
|
-
PostDeltaOrderV2Functions,
|
|
314
|
-
PostDeltaOrderV2Params,
|
|
315
|
-
} from './methods/deltaV2/postDeltaOrderV2';
|
|
316
|
-
import {
|
|
317
|
-
constructPostExternalDeltaOrderV2,
|
|
318
|
-
PostExternalDeltaOrderV2Functions,
|
|
319
|
-
PostExternalDeltaOrderV2Params,
|
|
320
|
-
} from './methods/deltaV2/postExternalDeltaOrderV2';
|
|
321
|
-
import {
|
|
322
|
-
constructPostTWAPDeltaOrderV2,
|
|
323
|
-
PostTWAPDeltaOrderV2Functions,
|
|
324
|
-
PostTWAPDeltaOrderV2Params,
|
|
325
|
-
} from './methods/deltaV2/postTWAPDeltaOrderV2';
|
|
326
|
-
import {
|
|
327
|
-
constructGetDeltaPriceV2,
|
|
328
|
-
DeltaPriceV2Params,
|
|
329
|
-
GetDeltaPriceV2Functions,
|
|
330
|
-
} from './methods/deltaV2/getDeltaPriceV2';
|
|
331
|
-
import {
|
|
332
|
-
constructGetDeltaOrdersV2,
|
|
333
|
-
GetDeltaOrdersV2Functions,
|
|
334
|
-
} from './methods/deltaV2/getDeltaOrdersV2';
|
|
335
|
-
import {
|
|
336
|
-
constructGetBridgeRoutes,
|
|
337
|
-
GetBridgeRoutesFunctions,
|
|
338
|
-
} from './methods/deltaV2/getBridgeRoutes';
|
|
339
|
-
import {
|
|
340
|
-
constructIsTokenSupportedInDeltaV2,
|
|
341
|
-
IsTokenSupportedInDeltaV2Functions,
|
|
342
|
-
} from './methods/deltaV2/isTokenSupportedInDeltaV2';
|
|
343
|
-
import {
|
|
344
|
-
CancelDeltaOrderV2Functions,
|
|
345
|
-
constructCancelDeltaOrderV2,
|
|
346
|
-
} from './methods/deltaV2/cancelDeltaOrderV2';
|
|
347
|
-
import {
|
|
348
|
-
AgentList,
|
|
349
|
-
constructGetAgentsListV2,
|
|
350
|
-
GetAgentsListV2Functions,
|
|
351
|
-
} from './methods/deltaV2/getAgentsListV2';
|
|
352
|
-
import type {
|
|
353
|
-
DeltaOrderStatusV2,
|
|
354
|
-
BuiltDeltaOrderV2,
|
|
355
|
-
DeltaPriceToken,
|
|
356
|
-
DeltaTokenAmount,
|
|
357
|
-
BridgeTag,
|
|
358
|
-
DeltaRouteBridge,
|
|
359
|
-
DeltaRouteBridgeContractParams,
|
|
360
|
-
DeltaRouteStep,
|
|
361
|
-
DeltaRoute,
|
|
362
|
-
DeltaPriceV2,
|
|
363
|
-
BridgeRoute,
|
|
364
|
-
DeltaOnChainOrderTypeReported,
|
|
365
|
-
DeltaTokenSide,
|
|
366
|
-
DeltaTransactionV2,
|
|
367
|
-
DeltaOrderV2Response,
|
|
368
|
-
} from './methods/deltaV2/types';
|
|
369
|
-
|
|
370
295
|
export { constructSwapSDK, SwapSDKMethods } from './methods/swap';
|
|
371
296
|
|
|
372
297
|
export {
|
|
@@ -386,18 +311,31 @@ export {
|
|
|
386
311
|
SubmitTWAPDeltaOrderParams,
|
|
387
312
|
} from './methods/delta';
|
|
388
313
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
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';
|
|
401
339
|
|
|
402
340
|
export type {
|
|
403
341
|
TransactionParams,
|
|
@@ -481,21 +419,6 @@ export {
|
|
|
481
419
|
constructPreSignTWAPDeltaOrder,
|
|
482
420
|
// Quote methods
|
|
483
421
|
constructGetQuote,
|
|
484
|
-
// Delta v2 runtime values (const-object enums etc.)
|
|
485
|
-
DeltaOrderStatusV2,
|
|
486
|
-
// Delta V2 methods
|
|
487
|
-
constructBuildDeltaOrderV2,
|
|
488
|
-
constructBuildExternalDeltaOrderV2,
|
|
489
|
-
constructBuildTWAPDeltaOrderV2,
|
|
490
|
-
constructPostDeltaOrderV2,
|
|
491
|
-
constructPostExternalDeltaOrderV2,
|
|
492
|
-
constructPostTWAPDeltaOrderV2,
|
|
493
|
-
constructGetDeltaPriceV2,
|
|
494
|
-
constructGetDeltaOrdersV2,
|
|
495
|
-
constructGetBridgeRoutes,
|
|
496
|
-
constructIsTokenSupportedInDeltaV2,
|
|
497
|
-
constructCancelDeltaOrderV2,
|
|
498
|
-
constructGetAgentsListV2,
|
|
499
422
|
// different helpers
|
|
500
423
|
constructGetPartnerFee,
|
|
501
424
|
constructGetBridgeInfo,
|
|
@@ -566,9 +489,11 @@ export type {
|
|
|
566
489
|
DeltaAuctionOrder,
|
|
567
490
|
DeltaAuction,
|
|
568
491
|
DeltaAuctionDelta,
|
|
492
|
+
DeltaAuctionFillable,
|
|
569
493
|
DeltaAuctionTWAP,
|
|
570
494
|
DeltaAuctionTWAPBuy,
|
|
571
495
|
DeltaAuctionExternal,
|
|
496
|
+
DeltaAuctionProductive,
|
|
572
497
|
DeltaOrderUnion,
|
|
573
498
|
DeltaAuctionUnion,
|
|
574
499
|
UnifiedDeltaOrderData,
|
|
@@ -604,6 +529,8 @@ export type {
|
|
|
604
529
|
DepositNativeAndPreSignDeltaOrderParams,
|
|
605
530
|
// External Delta types
|
|
606
531
|
ExternalDeltaOrder,
|
|
532
|
+
// Productive Delta types
|
|
533
|
+
ProductiveDeltaOrder,
|
|
607
534
|
TWAPDeltaOrder,
|
|
608
535
|
TWAPBuyDeltaOrder,
|
|
609
536
|
TWAPOnChainOrderType,
|
|
@@ -630,44 +557,6 @@ export type {
|
|
|
630
557
|
PostTWAPDeltaOrderFunctions,
|
|
631
558
|
PostTWAPDeltaOrderParams,
|
|
632
559
|
PreSignTWAPDeltaOrderFunctions,
|
|
633
|
-
// Delta v2 types
|
|
634
|
-
BuiltDeltaOrderV2,
|
|
635
|
-
DeltaPriceToken,
|
|
636
|
-
DeltaTokenAmount,
|
|
637
|
-
BridgeTag,
|
|
638
|
-
DeltaRouteBridge,
|
|
639
|
-
DeltaRouteBridgeContractParams,
|
|
640
|
-
DeltaRouteStep,
|
|
641
|
-
DeltaRoute,
|
|
642
|
-
DeltaPriceV2,
|
|
643
|
-
BridgeRoute,
|
|
644
|
-
DeltaOnChainOrderTypeReported,
|
|
645
|
-
DeltaTokenSide,
|
|
646
|
-
DeltaTransactionV2,
|
|
647
|
-
DeltaOrderV2Response,
|
|
648
|
-
DeltaPriceV2Params,
|
|
649
|
-
GetDeltaPriceV2Functions,
|
|
650
|
-
GetDeltaOrdersV2Functions,
|
|
651
|
-
GetBridgeRoutesFunctions,
|
|
652
|
-
IsTokenSupportedInDeltaV2Functions,
|
|
653
|
-
BuildDeltaOrderV2Params,
|
|
654
|
-
BuildDeltaOrderV2Functions,
|
|
655
|
-
BuildExternalDeltaOrderV2Params,
|
|
656
|
-
BuildExternalDeltaOrderV2Functions,
|
|
657
|
-
BuildTWAPDeltaOrderV2Params,
|
|
658
|
-
BuildTWAPSellDeltaOrderV2Params,
|
|
659
|
-
BuildTWAPBuyDeltaOrderV2Params,
|
|
660
|
-
BuildTWAPDeltaOrderV2Functions,
|
|
661
|
-
DeltaOrderToPostV2,
|
|
662
|
-
PostDeltaOrderV2Params,
|
|
663
|
-
PostDeltaOrderV2Functions,
|
|
664
|
-
PostExternalDeltaOrderV2Params,
|
|
665
|
-
PostExternalDeltaOrderV2Functions,
|
|
666
|
-
PostTWAPDeltaOrderV2Params,
|
|
667
|
-
PostTWAPDeltaOrderV2Functions,
|
|
668
|
-
CancelDeltaOrderV2Functions,
|
|
669
|
-
AgentList as AgentInfo,
|
|
670
|
-
GetAgentsListV2Functions,
|
|
671
560
|
// types for Quote methods
|
|
672
561
|
GetQuoteFunctions,
|
|
673
562
|
QuoteParams,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ExternalDeltaOrder,
|
|
12
12
|
OnChainOrderType,
|
|
13
13
|
OrderKind,
|
|
14
|
+
ProductiveDeltaOrder,
|
|
14
15
|
SwapSideUnion,
|
|
15
16
|
TWAPBuyDeltaOrder,
|
|
16
17
|
TWAPDeltaOrder,
|
|
@@ -65,6 +66,16 @@ function isDeltaOrder(order: DeltaOrderUnion): order is DeltaAuctionOrder {
|
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
/**
|
|
70
|
+
* @description Checks whether an order is a Productive Delta order
|
|
71
|
+
* (strategy-routed order without an explicit OrderKind).
|
|
72
|
+
*/
|
|
73
|
+
function isProductiveOrder(
|
|
74
|
+
order: DeltaOrderUnion
|
|
75
|
+
): order is ProductiveDeltaOrder {
|
|
76
|
+
return 'strategy' in order && typeof order.strategy === 'string';
|
|
77
|
+
}
|
|
78
|
+
|
|
68
79
|
/**
|
|
69
80
|
* @description Checks whether an auction is a TWAP auction.
|
|
70
81
|
*/
|
|
@@ -110,17 +121,28 @@ function isExternalAuction<T extends OnChainOrderType>(auction: {
|
|
|
110
121
|
return auction.onChainOrderType === 'ExternalOrder';
|
|
111
122
|
}
|
|
112
123
|
|
|
124
|
+
/**
|
|
125
|
+
* @description Checks whether an auction is a Productive auction.
|
|
126
|
+
*/
|
|
127
|
+
function isProductiveAuction<T extends OnChainOrderType>(auction: {
|
|
128
|
+
onChainOrderType: T;
|
|
129
|
+
}): auction is { onChainOrderType: 'ProductiveOrder' & T } {
|
|
130
|
+
return auction.onChainOrderType === 'ProductiveOrder';
|
|
131
|
+
}
|
|
132
|
+
|
|
113
133
|
const checks = {
|
|
114
134
|
isTWAPOrder,
|
|
115
135
|
isTWAPSellOrder,
|
|
116
136
|
isTWAPBuyOrder,
|
|
117
137
|
isExternalOrder,
|
|
118
138
|
isDeltaOrder,
|
|
139
|
+
isProductiveOrder,
|
|
119
140
|
isTWAPAuction,
|
|
120
141
|
isTWAPSellAuction,
|
|
121
142
|
isTWAPBuyAuction,
|
|
122
143
|
isDeltaAuction,
|
|
123
144
|
isExternalAuction,
|
|
145
|
+
isProductiveAuction,
|
|
124
146
|
isOrderCrosschain,
|
|
125
147
|
isExecutedAuction,
|
|
126
148
|
isPartiallyExecutedAuction,
|
|
@@ -271,6 +293,10 @@ function getAuctionSwapSide(auction: DeltaAuction): SwapSideUnion {
|
|
|
271
293
|
// TWAP orders have onChainOrderType instead of kind
|
|
272
294
|
return getSwapSideFromTwapOrderType(auction.onChainOrderType);
|
|
273
295
|
}
|
|
296
|
+
if (isProductiveAuction(auction)) {
|
|
297
|
+
// ProductiveOrders don't carry an explicit OrderKind; treated as SELL.
|
|
298
|
+
return 'SELL';
|
|
299
|
+
}
|
|
274
300
|
return getSwapSideFromDeltaOrder(auction.order);
|
|
275
301
|
}
|
|
276
302
|
|
|
@@ -332,7 +358,11 @@ function getTransactionAmounts(transactions: DeltaAuctionTransaction[]) {
|
|
|
332
358
|
srcAmount: acc.srcAmount + BigInt(spentAmount),
|
|
333
359
|
destAmount:
|
|
334
360
|
acc.destAmount +
|
|
335
|
-
BigInt(
|
|
361
|
+
BigInt(
|
|
362
|
+
bridgeMetadata?.outputAmount
|
|
363
|
+
? bridgeMetadata.outputAmount
|
|
364
|
+
: receivedAmount
|
|
365
|
+
),
|
|
336
366
|
};
|
|
337
367
|
},
|
|
338
368
|
{
|
|
@@ -123,6 +123,41 @@ export type ExternalDeltaOrder = {
|
|
|
123
123
|
data: string;
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
+
export type ProductiveDeltaOrder = {
|
|
127
|
+
/** @description The address of the order owner */
|
|
128
|
+
owner: string;
|
|
129
|
+
/** @description The address of the order beneficiary */
|
|
130
|
+
beneficiary: string;
|
|
131
|
+
/** @description The address of the src token */
|
|
132
|
+
srcToken: string;
|
|
133
|
+
/** @description The address of the dest token */
|
|
134
|
+
destToken: string;
|
|
135
|
+
/** @description The amount of src token to swap */
|
|
136
|
+
srcAmount: string;
|
|
137
|
+
/** @description The minimum amount of dest token to receive */
|
|
138
|
+
destAmount: string;
|
|
139
|
+
/** @description The expected amount of token to receive */
|
|
140
|
+
expectedAmount: string;
|
|
141
|
+
/** @description The deadline for the order */
|
|
142
|
+
deadline: number;
|
|
143
|
+
/** @description The nonce of the order */
|
|
144
|
+
nonce: string;
|
|
145
|
+
/** @description Metadata for the order, hex string */
|
|
146
|
+
metadata: string;
|
|
147
|
+
/** @description Encoded partner address, fee bps, and flags for the order. partnerAndFee = (partner << 96) | (partnerTakesSurplus << 8) | fee in bps (max fee is 2%) */
|
|
148
|
+
partnerAndFee: string;
|
|
149
|
+
/** @description Optional permit signature for the src token */
|
|
150
|
+
permit: string;
|
|
151
|
+
/** @description The strategy address. */
|
|
152
|
+
strategy: string;
|
|
153
|
+
/** @description The number of shares to execute for this order. */
|
|
154
|
+
shares: string;
|
|
155
|
+
/** @description Whether the order uses shares or raw amounts. */
|
|
156
|
+
useShares: boolean;
|
|
157
|
+
/** @description The bridge input */
|
|
158
|
+
bridge: Bridge;
|
|
159
|
+
};
|
|
160
|
+
|
|
126
161
|
type TWAPDeltaOrderBase = {
|
|
127
162
|
/** @description The address of the order owner */
|
|
128
163
|
owner: string;
|
|
@@ -213,9 +248,11 @@ export type DeltaAuctionTransaction = {
|
|
|
213
248
|
|
|
214
249
|
export type OnChainOrderMap = {
|
|
215
250
|
Order: DeltaAuctionOrder;
|
|
251
|
+
FillableOrder: DeltaAuctionOrder;
|
|
216
252
|
ExternalOrder: ExternalDeltaOrder;
|
|
217
253
|
TWAPOrder: TWAPDeltaOrder;
|
|
218
254
|
TWAPBuyOrder: TWAPBuyDeltaOrder;
|
|
255
|
+
ProductiveOrder: ProductiveDeltaOrder;
|
|
219
256
|
};
|
|
220
257
|
|
|
221
258
|
type BaseBridgeAuctionFields = Pick<
|
|
@@ -225,9 +262,11 @@ type BaseBridgeAuctionFields = Pick<
|
|
|
225
262
|
|
|
226
263
|
type BridgeAuctionFiledsMap = {
|
|
227
264
|
Order: BaseBridgeAuctionFields;
|
|
265
|
+
FillableOrder: BaseBridgeAuctionFields;
|
|
228
266
|
ExternalOrder: BaseBridgeAuctionFields;
|
|
229
267
|
TWAPOrder: Record<keyof BaseBridgeAuctionFields, null>;
|
|
230
268
|
TWAPBuyOrder: Record<keyof BaseBridgeAuctionFields, null>;
|
|
269
|
+
ProductiveOrder: BaseBridgeAuctionFields;
|
|
231
270
|
};
|
|
232
271
|
|
|
233
272
|
type DeltaAuctionBase = {
|
|
@@ -255,33 +294,39 @@ type DeltaAuctionBase = {
|
|
|
255
294
|
type: DeltaOrderType;
|
|
256
295
|
};
|
|
257
296
|
|
|
258
|
-
export type DeltaAuction<
|
|
259
|
-
T extends
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
: 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;
|
|
268
306
|
|
|
269
307
|
export type DeltaAuctionDelta = DeltaAuction<'Order'>;
|
|
308
|
+
export type DeltaAuctionFillable = DeltaAuction<'FillableOrder'>;
|
|
270
309
|
export type DeltaAuctionExternal = DeltaAuction<'ExternalOrder'>;
|
|
271
310
|
export type DeltaAuctionTWAP = DeltaAuction<'TWAPOrder'>;
|
|
272
311
|
export type DeltaAuctionTWAPBuy = DeltaAuction<'TWAPBuyOrder'>;
|
|
312
|
+
export type DeltaAuctionProductive = DeltaAuction<'ProductiveOrder'>;
|
|
273
313
|
|
|
274
314
|
export type DeltaAuctionUnion =
|
|
275
315
|
| DeltaAuctionDelta
|
|
316
|
+
| DeltaAuctionFillable
|
|
276
317
|
| DeltaAuctionExternal
|
|
277
318
|
| DeltaAuctionTWAP
|
|
278
|
-
| DeltaAuctionTWAPBuy
|
|
319
|
+
| DeltaAuctionTWAPBuy
|
|
320
|
+
| DeltaAuctionProductive;
|
|
279
321
|
|
|
280
322
|
export type DeltaOrderUnion = OnChainOrderMap[keyof OnChainOrderMap];
|
|
281
323
|
|
|
282
324
|
export type BridgeMetadata = {
|
|
283
|
-
/** @description
|
|
284
|
-
|
|
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;
|
|
285
330
|
/** @description Field is present iff: order was built via POST /v2/orders/build,
|
|
286
331
|
* the route is cross-chain (route.bridge !== null and not an external handler),
|
|
287
332
|
* and the order is posted before the per-order cache entry expires.
|
|
@@ -300,12 +345,7 @@ export type BridgeMetadata = {
|
|
|
300
345
|
// refunded is basically failed
|
|
301
346
|
export type BridgeStatus = 'pending' | 'filled' | 'expired' | 'refunded';
|
|
302
347
|
|
|
303
|
-
export type OnChainOrderType =
|
|
304
|
-
| 'Order'
|
|
305
|
-
| 'ExternalOrder'
|
|
306
|
-
| 'TWAPOrder'
|
|
307
|
-
| 'TWAPBuyOrder'
|
|
308
|
-
| 'ProductiveOrder';
|
|
348
|
+
export type OnChainOrderType = keyof OnChainOrderMap;
|
|
309
349
|
|
|
310
350
|
export type TWAPOnChainOrderType = 'TWAPOrder' | 'TWAPBuyOrder';
|
|
311
351
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { API_URL } from '../../constants';
|
|
2
2
|
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type { DeltaAuctionOrder } from '../delta/helpers/types';
|
|
4
|
+
import type { BuiltDeltaOrder, DeltaRoute } from './types';
|
|
5
|
+
export type { BuiltDeltaOrder } from './types';
|
|
5
6
|
|
|
6
|
-
export type
|
|
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
|
|
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
|
|
43
|
-
buildOrderParams:
|
|
43
|
+
type BuildDeltaOrder = (
|
|
44
|
+
buildOrderParams: BuildDeltaOrderParams,
|
|
44
45
|
requestParams?: RequestParameters
|
|
45
|
-
) => Promise<
|
|
46
|
+
) => Promise<BuiltDeltaOrder<DeltaAuctionOrder>>;
|
|
46
47
|
|
|
47
|
-
export type
|
|
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
|
-
|
|
50
|
+
buildDeltaOrder: BuildDeltaOrder;
|
|
50
51
|
};
|
|
51
52
|
|
|
52
|
-
export const
|
|
53
|
+
export const constructBuildDeltaOrder = (
|
|
53
54
|
options: ConstructFetchInput
|
|
54
|
-
):
|
|
55
|
-
const { apiURL = API_URL,
|
|
55
|
+
): BuildDeltaOrderFunctions => {
|
|
56
|
+
const { apiURL = API_URL, fetcher } = options;
|
|
56
57
|
const buildUrl = `${apiURL}/delta/v2/orders/build` as const;
|
|
57
58
|
|
|
58
|
-
const
|
|
59
|
-
fetcher<
|
|
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 {
|
|
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 {
|
|
4
|
-
|
|
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
|
|
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
|
|
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
|
|
47
|
-
buildOrderParams:
|
|
47
|
+
type BuildExternalDeltaOrder = (
|
|
48
|
+
buildOrderParams: BuildExternalDeltaOrderParams,
|
|
48
49
|
requestParams?: RequestParameters
|
|
49
|
-
) => Promise<
|
|
50
|
+
) => Promise<BuiltDeltaOrder<ExternalDeltaOrder>>;
|
|
50
51
|
|
|
51
|
-
export type
|
|
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
|
-
|
|
54
|
+
buildExternalDeltaOrder: BuildExternalDeltaOrder;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
|
-
export const
|
|
57
|
+
export const constructBuildExternalDeltaOrder = (
|
|
57
58
|
options: ConstructFetchInput
|
|
58
|
-
):
|
|
59
|
-
const { apiURL = API_URL,
|
|
59
|
+
): BuildExternalDeltaOrderFunctions => {
|
|
60
|
+
const { apiURL = API_URL, fetcher } = options;
|
|
60
61
|
const buildUrl = `${apiURL}/delta/v2/orders/build` as const;
|
|
61
62
|
|
|
62
|
-
const
|
|
63
|
+
const buildExternalDeltaOrder: BuildExternalDeltaOrder = async (
|
|
63
64
|
params,
|
|
64
65
|
requestParams
|
|
65
66
|
) =>
|
|
66
|
-
fetcher<
|
|
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 {
|
|
94
|
+
return { buildExternalDeltaOrder };
|
|
95
95
|
};
|