@1inch/fusion-sdk 2.3.8 → 2.3.9-rc.1

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 (46) hide show
  1. package/dist/cjs/abi/NativeOrderFactory.abi.json +217 -0
  2. package/dist/cjs/abi/NativeOrderImpl.abi.json +281 -0
  3. package/dist/cjs/api/quoter/quote/quote.js +29 -4
  4. package/dist/cjs/contracts/index.js +20 -0
  5. package/dist/cjs/contracts/native-order-factory.js +115 -0
  6. package/dist/cjs/contracts/native-order-impl.js +129 -0
  7. package/dist/cjs/contracts/proxy-factory.js +87 -0
  8. package/dist/cjs/contracts/types.js +4 -0
  9. package/dist/cjs/fusion-order/cancellation-auction.js +81 -0
  10. package/dist/cjs/fusion-order/fusion-order.js +71 -25
  11. package/dist/cjs/fusion-order/fusion-order.spec.js +73 -0
  12. package/dist/cjs/fusion-order/index.js +1 -0
  13. package/dist/cjs/fusion-order/types.js +4 -0
  14. package/dist/cjs/index.js +1 -0
  15. package/dist/cjs/sdk/sdk.js +83 -28
  16. package/dist/esm/abi/NativeOrderFactory.abi.json +217 -0
  17. package/dist/esm/abi/NativeOrderImpl.abi.json +281 -0
  18. package/dist/esm/api/quoter/quote/quote.js +24 -4
  19. package/dist/esm/contracts/index.js +3 -0
  20. package/dist/esm/contracts/native-order-factory.js +100 -0
  21. package/dist/esm/contracts/native-order-impl.js +114 -0
  22. package/dist/esm/contracts/proxy-factory.js +72 -0
  23. package/dist/esm/contracts/types.js +1 -0
  24. package/dist/esm/fusion-order/cancellation-auction.js +66 -0
  25. package/dist/esm/fusion-order/fusion-order.js +69 -23
  26. package/dist/esm/fusion-order/fusion-order.spec.js +73 -0
  27. package/dist/esm/fusion-order/index.js +1 -0
  28. package/dist/esm/fusion-order/types.js +11 -0
  29. package/dist/esm/index.js +1 -0
  30. package/dist/esm/package.json +1 -1
  31. package/dist/esm/sdk/sdk.js +83 -28
  32. package/dist/types/src/api/quoter/quote/quote.d.ts +3 -0
  33. package/dist/types/src/api/quoter/types.d.ts +2 -0
  34. package/dist/types/src/contracts/index.d.ts +3 -0
  35. package/dist/types/src/contracts/native-order-factory.d.ts +9 -0
  36. package/dist/types/src/contracts/native-order-impl.d.ts +10 -0
  37. package/dist/types/src/contracts/proxy-factory.d.ts +8 -0
  38. package/dist/types/src/contracts/types.d.ts +6 -0
  39. package/dist/types/src/fusion-order/cancellation-auction.d.ts +7 -0
  40. package/dist/types/src/fusion-order/fusion-order.d.ts +9 -27
  41. package/dist/types/src/fusion-order/index.d.ts +1 -0
  42. package/dist/types/src/fusion-order/types.d.ts +20 -0
  43. package/dist/types/src/index.d.ts +1 -0
  44. package/dist/types/src/sdk/sdk.d.ts +4 -0
  45. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  46. package/package.json +1 -1
package/dist/esm/index.js CHANGED
@@ -10,4 +10,5 @@ export * from './utils/time.js';
10
10
  export * from './validations.js';
11
11
  export * from './ws-api/index.js';
12
12
  export * from './errors.js';
13
+ export * from './contracts/index.js';
13
14
  export { QuoterRequest, RelayerRequest, QuoterCustomPresetRequest, PresetEnum, Preset, Quote, OrderStatus } from './api/index.js';
@@ -1 +1 @@
1
- {"name":"@1inch/fusion-sdk","version":"2.3.8","type":"module"}
1
+ {"name":"@1inch/fusion-sdk","version":"2.3.9-rc.1","type":"module"}
@@ -331,50 +331,55 @@ export var FusionSDK = /*#__PURE__*/ function() {
331
331
  },
332
332
  {
333
333
  key: "submitOrder",
334
- value: function submitOrder(order, quoteId) {
334
+ value: /**
335
+ * Submit order to relayer
336
+ *
337
+ * Note, that orders from native assets must be submitted with `submitNativeOrder`
338
+ *
339
+ * @see FusionSDK.submitNativeOrder
340
+ */ function submitOrder(order, quoteId) {
335
341
  var _this = this;
336
342
  return _async_to_generator(function() {
337
- var orderStruct, signature, relayerRequest;
343
+ var signature;
338
344
  return _ts_generator(this, function(_state) {
339
345
  switch(_state.label){
340
346
  case 0:
341
- if (!_this.config.blockchainProvider) {
342
- throw new Error('blockchainProvider has not set to config');
343
- }
344
- orderStruct = order.build();
345
347
  return [
346
348
  4,
347
- _this.config.blockchainProvider.signTypedData(orderStruct.maker, order.getTypedData(_this.config.network))
349
+ _this.signOrder(order)
348
350
  ];
349
351
  case 1:
350
352
  signature = _state.sent();
351
- relayerRequest = RelayerRequest.new({
352
- order: orderStruct,
353
- signature: signature,
354
- quoteId: quoteId,
355
- extension: order.extension.encode()
356
- });
357
- return [
358
- 4,
359
- _this.api.submitOrder(relayerRequest)
360
- ];
361
- case 2:
362
- _state.sent();
363
353
  return [
364
354
  2,
365
- {
366
- order: orderStruct,
367
- signature: signature,
368
- quoteId: quoteId,
369
- orderHash: order.getOrderHash(_this.config.network),
370
- extension: relayerRequest.extension
371
- }
355
+ _this._submitOrder(order, quoteId, signature)
372
356
  ];
373
357
  }
374
358
  });
375
359
  })();
376
360
  }
377
361
  },
362
+ {
363
+ key: "submitNativeOrder",
364
+ value: /**
365
+ * Submit order to relayer
366
+ *
367
+ * Note, that orders from native assets must be submitted on-chain as well
368
+ * @see NativeOrdersFactory.create
369
+ */ function submitNativeOrder(order, maker, quoteId) {
370
+ var _this = this;
371
+ return _async_to_generator(function() {
372
+ var signature;
373
+ return _ts_generator(this, function(_state) {
374
+ signature = _this.signNativeOrder(order, maker);
375
+ return [
376
+ 2,
377
+ _this._submitOrder(order, quoteId, signature)
378
+ ];
379
+ });
380
+ })();
381
+ }
382
+ },
378
383
  {
379
384
  key: "placeOrder",
380
385
  value: function placeOrder(params) {
@@ -432,7 +437,13 @@ export var FusionSDK = /*#__PURE__*/ function() {
432
437
  },
433
438
  {
434
439
  key: "signOrder",
435
- value: function signOrder(order) {
440
+ value: /**
441
+ * Sign order using `blockchainProvider` from config
442
+ *
443
+ * Use FusionSDK.signNativeOrder for signing orders from native asset
444
+ *
445
+ * @see FusionSDK.signNativeOrder
446
+ */ function signOrder(order) {
436
447
  var _this = this;
437
448
  return _async_to_generator(function() {
438
449
  var orderStruct, data;
@@ -450,6 +461,49 @@ export var FusionSDK = /*#__PURE__*/ function() {
450
461
  })();
451
462
  }
452
463
  },
464
+ {
465
+ key: "signNativeOrder",
466
+ value: function signNativeOrder(order, maker) {
467
+ return order.nativeSignature(maker);
468
+ }
469
+ },
470
+ {
471
+ key: "_submitOrder",
472
+ value: function _submitOrder(order, quoteId, signature) {
473
+ var _this = this;
474
+ return _async_to_generator(function() {
475
+ var orderStruct, relayerRequest;
476
+ return _ts_generator(this, function(_state) {
477
+ switch(_state.label){
478
+ case 0:
479
+ orderStruct = order.build();
480
+ relayerRequest = RelayerRequest.new({
481
+ order: orderStruct,
482
+ signature: signature,
483
+ quoteId: quoteId,
484
+ extension: order.extension.encode()
485
+ });
486
+ return [
487
+ 4,
488
+ _this.api.submitOrder(relayerRequest)
489
+ ];
490
+ case 1:
491
+ _state.sent();
492
+ return [
493
+ 2,
494
+ {
495
+ order: orderStruct,
496
+ signature: signature,
497
+ quoteId: quoteId,
498
+ orderHash: order.getOrderHash(_this.config.network),
499
+ extension: relayerRequest.extension
500
+ }
501
+ ];
502
+ }
503
+ });
504
+ })();
505
+ }
506
+ },
453
507
  {
454
508
  key: "getQuoteResult",
455
509
  value: function getQuoteResult(params) {
@@ -488,4 +542,5 @@ export var FusionSDK = /*#__PURE__*/ function() {
488
542
  }
489
543
  ]);
490
544
  return FusionSDK;
491
- }();
545
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
546
+ ();
@@ -4,9 +4,11 @@ import { Cost, PresetEnum, QuoterResponse } from '../types.js';
4
4
  import { Preset } from '../preset.js';
5
5
  import { FusionOrder } from '../../../fusion-order/index.js';
6
6
  import { QuoterRequest } from '../quoter.request.js';
7
+ import { ProxyFactory } from '../../../index.js';
7
8
  export declare class Quote {
8
9
  private readonly params;
9
10
  readonly settlementAddress: Address;
11
+ readonly nativeOrderFactory?: ProxyFactory;
10
12
  readonly fromTokenAmount: bigint;
11
13
  readonly presets: {
12
14
  [PresetEnum.fast]: Preset;
@@ -29,4 +31,5 @@ export declare class Quote {
29
31
  createFusionOrder(paramsData: Omit<FusionOrderParamsData, 'permit' | 'isPermit2'>): FusionOrder;
30
32
  getPreset(type?: PresetEnum): Preset;
31
33
  private getWhitelist;
34
+ private _createOrder;
32
35
  }
@@ -33,6 +33,8 @@ export type QuoterResponse = {
33
33
  prices: Cost;
34
34
  volume: Cost;
35
35
  settlementAddress: string;
36
+ nativeOrderFactoryAddress?: string;
37
+ nativeOrderImplAddress?: string;
36
38
  whitelist: string[];
37
39
  quoteId: string | null;
38
40
  autoK: number;
@@ -0,0 +1,3 @@
1
+ export * from './native-order-factory.js';
2
+ export * from './native-order-impl.js';
3
+ export * from './proxy-factory.js';
@@ -0,0 +1,9 @@
1
+ import { Address } from '@1inch/limit-order-sdk';
2
+ import { CallInfo } from './types.js';
3
+ import { FusionOrder } from '../fusion-order/index.js';
4
+ export declare class NativeOrdersFactory {
5
+ address: Address;
6
+ private readonly iface;
7
+ constructor(address: Address);
8
+ create(maker: Address, order: FusionOrder): CallInfo;
9
+ }
@@ -0,0 +1,10 @@
1
+ import { Address } from '@1inch/limit-order-sdk';
2
+ import { CallInfo } from './types.js';
3
+ import { FusionOrder } from '../fusion-order/index.js';
4
+ export declare class NativeOrdersImpl {
5
+ address: Address;
6
+ private readonly iface;
7
+ constructor(address: Address);
8
+ cancel(maker: Address, order: FusionOrder): CallInfo;
9
+ cancelExpiredOrderByResolver(maker: Address, order: FusionOrder): CallInfo;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { Address } from '@1inch/limit-order-sdk';
2
+ export declare class ProxyFactory {
3
+ readonly factory: Address;
4
+ readonly implementation: Address;
5
+ constructor(factory: Address, implementation: Address);
6
+ static calcProxyBytecodeHash(impl: Address): string;
7
+ getProxyAddress(salt: string): Address;
8
+ }
@@ -0,0 +1,6 @@
1
+ import { Address } from '@1inch/limit-order-sdk';
2
+ export type CallInfo = {
3
+ data: string;
4
+ to: Address;
5
+ value: bigint;
6
+ };
@@ -0,0 +1,7 @@
1
+ export declare class CancellationAuction {
2
+ readonly duration: bigint;
3
+ readonly maxRewardBps: bigint;
4
+ static ZERO: CancellationAuction;
5
+ constructor(duration: bigint, maxRewardBps: bigint);
6
+ build(): bigint;
7
+ }
@@ -1,27 +1,19 @@
1
1
  import { Address, EIP712TypedData, Extension, LimitOrderV4Struct, OrderInfoData } from '@1inch/limit-order-sdk';
2
+ import { ProxyFactory } from 'contracts/proxy-factory.js';
2
3
  import { FusionExtension } from './fusion-extension.js';
3
4
  import { AuctionDetails } from './auction-details/index.js';
4
5
  import { Whitelist } from './whitelist/whitelist.js';
5
6
  import { SurplusParams } from './surplus-params.js';
6
- import { Fees } from './fees/index.js';
7
+ import type { Details, Extra } from './types.js';
7
8
  import { AuctionCalculator } from '../amount-calculator/auction-calculator/index.js';
9
+ import { NetworkEnum } from '../constants.js';
8
10
  import { AmountCalculator } from '../amount-calculator/amount-calculator.js';
9
11
  export declare class FusionOrder {
10
12
  readonly settlementExtensionContract: Address;
11
13
  private static defaultExtra;
12
14
  readonly fusionExtension: FusionExtension;
13
15
  private inner;
14
- protected constructor(settlementExtensionContract: Address, orderInfo: OrderInfoData, auctionDetails: AuctionDetails, whitelist: Whitelist, surplusParams?: SurplusParams, extra?: {
15
- unwrapWETH?: boolean;
16
- nonce?: bigint;
17
- permit?: string;
18
- allowPartialFills?: boolean;
19
- allowMultipleFills?: boolean;
20
- orderExpirationDelay?: bigint;
21
- enablePermit2?: boolean;
22
- source?: string;
23
- fees?: Fees;
24
- }, extension?: FusionExtension);
16
+ protected constructor(settlementExtensionContract: Address, orderInfo: OrderInfoData, auctionDetails: AuctionDetails, whitelist: Whitelist, surplusParams?: SurplusParams, extra?: Extra, extension?: FusionExtension);
25
17
  get extension(): Extension;
26
18
  get maker(): Address;
27
19
  get takerAsset(): Address;
@@ -38,21 +30,9 @@ export declare class FusionOrder {
38
30
  get multipleFillsAllowed(): boolean;
39
31
  get nonce(): bigint;
40
32
  get salt(): bigint;
41
- static new(settlementExtension: Address, orderInfo: OrderInfoData, details: {
42
- auction: AuctionDetails;
43
- whitelist: Whitelist;
44
- surplus?: SurplusParams;
45
- }, extra?: {
46
- unwrapWETH?: boolean;
47
- nonce?: bigint;
48
- permit?: string;
49
- allowPartialFills?: boolean;
50
- allowMultipleFills?: boolean;
51
- orderExpirationDelay?: bigint;
52
- enablePermit2?: boolean;
53
- source?: string;
54
- fees?: Fees;
55
- }): FusionOrder;
33
+ static new(settlementExtension: Address, orderInfo: OrderInfoData, details: Details, extra?: Extra): FusionOrder;
34
+ static isNativeOrder(chainId: number, ethOrderFactory: ProxyFactory, order: LimitOrderV4Struct, signature: string): boolean;
35
+ static fromNative(chainId: NetworkEnum, ethOrdersFactory: ProxyFactory, settlementExtension: Address, orderInfo: Omit<OrderInfoData, 'makerAsset'>, details: Details, extra?: Extra): FusionOrder;
56
36
  static fromDataAndExtension(order: LimitOrderV4Struct, extension: Extension): FusionOrder;
57
37
  build(): LimitOrderV4Struct;
58
38
  getOrderHash(chainId: number): string;
@@ -70,4 +50,6 @@ export declare class FusionOrder {
70
50
  isExclusiveResolver(wallet: Address): boolean;
71
51
  isExclusivityPeriod(time?: bigint): boolean;
72
52
  getAmountCalculator(): AmountCalculator;
53
+ isNative(chainId: number, ethOrderFactory: ProxyFactory, signature: string): boolean;
54
+ nativeSignature(maker: Address): string;
73
55
  }
@@ -5,3 +5,4 @@ export * from './fusion-extension.js';
5
5
  export * from './fees/index.js';
6
6
  export { CHAIN_TO_WRAPPER } from './constants.js';
7
7
  export * from './surplus-params.js';
8
+ export * from './cancellation-auction.js';
@@ -0,0 +1,20 @@
1
+ import { AuctionDetails } from './auction-details/auction-details.js';
2
+ import { Fees } from './fees/index.js';
3
+ import { SurplusParams } from './surplus-params.js';
4
+ import { Whitelist } from './whitelist/whitelist.js';
5
+ export type Extra = {
6
+ unwrapWETH?: boolean;
7
+ nonce?: bigint;
8
+ permit?: string;
9
+ allowPartialFills?: boolean;
10
+ allowMultipleFills?: boolean;
11
+ orderExpirationDelay?: bigint;
12
+ enablePermit2?: boolean;
13
+ source?: string;
14
+ fees?: Fees;
15
+ };
16
+ export type Details = {
17
+ auction: AuctionDetails;
18
+ whitelist: Whitelist;
19
+ surplus?: SurplusParams;
20
+ };
@@ -10,4 +10,5 @@ export * from './utils/time.js';
10
10
  export * from './validations.js';
11
11
  export * from './ws-api/index.js';
12
12
  export * from './errors.js';
13
+ export * from './contracts/index.js';
13
14
  export { QuoterRequest, type QuoterResponse, RelayerRequest, QuoterCustomPresetRequest, PresetEnum, Preset, Quote, type OrderStatusResponse, OrderStatus } from './api/index.js';
@@ -1,3 +1,4 @@
1
+ import { Address } from '@1inch/limit-order-sdk';
1
2
  import { FusionSDKConfigParams, OrderInfo, OrderParams, PreparedOrder, QuoteParams, QuoteCustomPresetParams } from './types.js';
2
3
  import { FusionApi, Quote } from '../api/index.js';
3
4
  import { ActiveOrdersRequestParams, ActiveOrdersResponse, OrdersByMakerParams, OrdersByMakerResponse, OrderStatusResponse } from '../api/orders/index.js';
@@ -13,8 +14,11 @@ export declare class FusionSDK {
13
14
  getQuoteWithCustomPreset(params: QuoteParams, body: QuoteCustomPresetParams): Promise<Quote>;
14
15
  createOrder(params: OrderParams): Promise<PreparedOrder>;
15
16
  submitOrder(order: FusionOrder, quoteId: string): Promise<OrderInfo>;
17
+ submitNativeOrder(order: FusionOrder, maker: Address, quoteId: string): Promise<OrderInfo>;
16
18
  placeOrder(params: OrderParams): Promise<OrderInfo>;
17
19
  buildCancelOrderCallData(orderHash: string): Promise<string>;
18
20
  signOrder(order: FusionOrder): Promise<string>;
21
+ signNativeOrder(order: FusionOrder, maker: Address): string;
22
+ private _submitOrder;
19
23
  private getQuoteResult;
20
24
  }