@velora-dex/sdk 9.5.0 → 9.5.2-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import type { EnumerateLiteral } from '../../../types';
2
2
  import { SwapSide } from '../../../constants';
3
+ import { Prettify } from 'ts-essentials';
3
4
 
4
5
  export type SwapSideUnion = EnumerateLiteral<typeof SwapSide>;
5
6
 
@@ -39,7 +40,7 @@ export type DeltaAmountsWithSlippage =
39
40
  | DeltaAmountsBuySlippage
40
41
  | DeltaAmountsExplicit;
41
42
 
42
- enum OrderKind {
43
+ export enum OrderKind {
43
44
  Sell = 0,
44
45
  Buy = 1,
45
46
  }
@@ -202,6 +203,12 @@ export type DeltaAuctionTransaction = {
202
203
  partnerFee: string;
203
204
  agent: string;
204
205
  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;
205
212
  };
206
213
 
207
214
  export type OnChainOrderMap = {
@@ -211,6 +218,18 @@ export type OnChainOrderMap = {
211
218
  TWAPBuyOrder: TWAPBuyDeltaOrder;
212
219
  };
213
220
 
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
+
214
233
  type DeltaAuctionBase = {
215
234
  id: string;
216
235
  deltaVersion: string; // 1.0 or 2.0 currently
@@ -237,19 +256,34 @@ type DeltaAuctionBase = {
237
256
 
238
257
  export type DeltaAuction<T extends OnChainOrderType = OnChainOrderType> =
239
258
  T extends T
240
- ? DeltaAuctionBase & {
241
- onChainOrderType: T;
242
- order: OnChainOrderMap[T];
243
- }
259
+ ? Prettify<
260
+ DeltaAuctionBase & {
261
+ onChainOrderType: T;
262
+ order: OnChainOrderMap[T];
263
+ } & BridgeAuctionFiledsMap[T]
264
+ >
244
265
  : never;
245
266
 
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
+
246
280
  export type BridgeMetadata = {
247
281
  /** @description The amount that user should expect to get */
248
282
  outputAmount: string;
249
283
  /** @description The cross-chain deadline. If deadline passes, the bridgeStatus would be expired */
250
- fillDeadline: number;
284
+ fillDeadline?: number; // available for Across protocol
251
285
  /** @description The deposit id */
252
- depositId: number;
286
+ depositId?: number; // available for Across protocol
253
287
  /** @description The transaction hash on the destination chain that fulfilled the order. When bridgeStatus='filled' */
254
288
  fillTx?: string;
255
289
  /** @description The transaction hash on the source chain that refunded the deposit. When bridgeStatus='refunded' */
@@ -286,3 +320,35 @@ export type BridgePriceInfo = {
286
320
  bestReturn: boolean;
287
321
  recommended: boolean;
288
322
  };
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
+ };
package/src/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};