@myx-trade/sdk 0.1.106 → 0.1.108

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/dist/index.d.mts CHANGED
@@ -1213,7 +1213,7 @@ declare class ConfigManager {
1213
1213
  private accessTokenExpiry?;
1214
1214
  constructor(config: MyxClientConfig);
1215
1215
  clear(): void;
1216
- startSeamlessMode(open: boolean): void;
1216
+ startSeamlessMode(open: boolean): MyxClientConfig;
1217
1217
  updateSeamlessWallet({ wallet, authorized, masterAddress }: {
1218
1218
  wallet?: ethers$1.Wallet;
1219
1219
  authorized?: boolean;
@@ -1318,11 +1318,12 @@ declare class Utils {
1318
1318
  getOrderIdFromTransaction(receipt: any): string | null;
1319
1319
  private getApproveQuoteAmount;
1320
1320
  needsApproval(chainId: number, quoteAddress: string, requiredAmount: string, spenderAddress?: string): Promise<boolean>;
1321
- approveAuthorization({ chainId, quoteAddress, amount, spenderAddress, }: {
1321
+ approveAuthorization({ chainId, quoteAddress, amount, spenderAddress, signer }: {
1322
1322
  chainId: number;
1323
1323
  quoteAddress: string;
1324
1324
  amount?: string;
1325
1325
  spenderAddress?: string;
1326
+ signer?: ethers$1.Signer;
1326
1327
  }): Promise<{
1327
1328
  code: number;
1328
1329
  message: any;
@@ -1658,6 +1659,17 @@ declare class Order {
1658
1659
  data?: undefined;
1659
1660
  }>;
1660
1661
  closeAllPositions(chainId: number, params: PlaceOrderParams[]): Promise<{
1662
+ code: number;
1663
+ message: string;
1664
+ data: ApiResponse<any>;
1665
+ transactionHash?: undefined;
1666
+ blockNumber?: undefined;
1667
+ gasUsed?: undefined;
1668
+ status?: undefined;
1669
+ confirmations?: undefined;
1670
+ timestamp?: undefined;
1671
+ receipt?: undefined;
1672
+ } | {
1661
1673
  code: number;
1662
1674
  message: string;
1663
1675
  data: string | null;
@@ -1681,6 +1693,10 @@ declare class Order {
1681
1693
  receipt?: undefined;
1682
1694
  }>;
1683
1695
  createDecreaseOrder(params: PlaceOrderParams): Promise<{
1696
+ code: number;
1697
+ message: string;
1698
+ data: ApiResponse<any>;
1699
+ } | {
1684
1700
  code: number;
1685
1701
  message: string;
1686
1702
  data: {
@@ -1700,6 +1716,10 @@ declare class Order {
1700
1716
  data?: undefined;
1701
1717
  }>;
1702
1718
  createPositionTpSlOrder(params: PositionTpSlOrderParams): Promise<{
1719
+ code: number;
1720
+ message: string;
1721
+ data: ApiResponse<any>;
1722
+ } | {
1703
1723
  code: number;
1704
1724
  message: string;
1705
1725
  data: {
@@ -1719,8 +1739,13 @@ declare class Order {
1719
1739
  data?: undefined;
1720
1740
  }>;
1721
1741
  cancelAllOrders(orderIds: string[], chainId: ChainId): Promise<{
1742
+ code: number;
1743
+ message: string;
1744
+ data: ApiResponse<any>;
1745
+ } | {
1722
1746
  code: number;
1723
1747
  message: any;
1748
+ data?: undefined;
1724
1749
  }>;
1725
1750
  cancelOrder(orderId: string, chainId: ChainId): Promise<{
1726
1751
  code: number;
package/dist/index.d.ts CHANGED
@@ -1213,7 +1213,7 @@ declare class ConfigManager {
1213
1213
  private accessTokenExpiry?;
1214
1214
  constructor(config: MyxClientConfig);
1215
1215
  clear(): void;
1216
- startSeamlessMode(open: boolean): void;
1216
+ startSeamlessMode(open: boolean): MyxClientConfig;
1217
1217
  updateSeamlessWallet({ wallet, authorized, masterAddress }: {
1218
1218
  wallet?: ethers$1.Wallet;
1219
1219
  authorized?: boolean;
@@ -1318,11 +1318,12 @@ declare class Utils {
1318
1318
  getOrderIdFromTransaction(receipt: any): string | null;
1319
1319
  private getApproveQuoteAmount;
1320
1320
  needsApproval(chainId: number, quoteAddress: string, requiredAmount: string, spenderAddress?: string): Promise<boolean>;
1321
- approveAuthorization({ chainId, quoteAddress, amount, spenderAddress, }: {
1321
+ approveAuthorization({ chainId, quoteAddress, amount, spenderAddress, signer }: {
1322
1322
  chainId: number;
1323
1323
  quoteAddress: string;
1324
1324
  amount?: string;
1325
1325
  spenderAddress?: string;
1326
+ signer?: ethers$1.Signer;
1326
1327
  }): Promise<{
1327
1328
  code: number;
1328
1329
  message: any;
@@ -1658,6 +1659,17 @@ declare class Order {
1658
1659
  data?: undefined;
1659
1660
  }>;
1660
1661
  closeAllPositions(chainId: number, params: PlaceOrderParams[]): Promise<{
1662
+ code: number;
1663
+ message: string;
1664
+ data: ApiResponse<any>;
1665
+ transactionHash?: undefined;
1666
+ blockNumber?: undefined;
1667
+ gasUsed?: undefined;
1668
+ status?: undefined;
1669
+ confirmations?: undefined;
1670
+ timestamp?: undefined;
1671
+ receipt?: undefined;
1672
+ } | {
1661
1673
  code: number;
1662
1674
  message: string;
1663
1675
  data: string | null;
@@ -1681,6 +1693,10 @@ declare class Order {
1681
1693
  receipt?: undefined;
1682
1694
  }>;
1683
1695
  createDecreaseOrder(params: PlaceOrderParams): Promise<{
1696
+ code: number;
1697
+ message: string;
1698
+ data: ApiResponse<any>;
1699
+ } | {
1684
1700
  code: number;
1685
1701
  message: string;
1686
1702
  data: {
@@ -1700,6 +1716,10 @@ declare class Order {
1700
1716
  data?: undefined;
1701
1717
  }>;
1702
1718
  createPositionTpSlOrder(params: PositionTpSlOrderParams): Promise<{
1719
+ code: number;
1720
+ message: string;
1721
+ data: ApiResponse<any>;
1722
+ } | {
1703
1723
  code: number;
1704
1724
  message: string;
1705
1725
  data: {
@@ -1719,8 +1739,13 @@ declare class Order {
1719
1739
  data?: undefined;
1720
1740
  }>;
1721
1741
  cancelAllOrders(orderIds: string[], chainId: ChainId): Promise<{
1742
+ code: number;
1743
+ message: string;
1744
+ data: ApiResponse<any>;
1745
+ } | {
1722
1746
  code: number;
1723
1747
  message: any;
1748
+ data?: undefined;
1724
1749
  }>;
1725
1750
  cancelOrder(orderId: string, chainId: ChainId): Promise<{
1726
1751
  code: number;
package/dist/index.js CHANGED
@@ -1822,7 +1822,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
1822
1822
  // package.json
1823
1823
  var package_default = {
1824
1824
  name: "@myx-trade/sdk",
1825
- version: "0.1.106",
1825
+ version: "0.1.108",
1826
1826
  private: false,
1827
1827
  publishConfig: {
1828
1828
  access: "public"
@@ -13740,12 +13740,11 @@ var ConfigManager = class {
13740
13740
  };
13741
13741
  }
13742
13742
  startSeamlessMode(open) {
13743
- console.log("startSeamlessMode-->", this.config, open);
13744
13743
  this.config = {
13745
13744
  ...this.config,
13746
13745
  seamlessMode: open
13747
13746
  };
13748
- console.log("startSeamlessMode-->", this.config);
13747
+ return this.config;
13749
13748
  }
13750
13749
  updateSeamlessWallet({ wallet, authorized, masterAddress }) {
13751
13750
  this.config = {
@@ -14377,9 +14376,6 @@ var Order = class {
14377
14376
  async createIncreaseOrder(params) {
14378
14377
  try {
14379
14378
  const config = this.configManager.getConfig();
14380
- if (!config.signer) {
14381
- throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14382
- }
14383
14379
  const networkFee = await this.utils.getNetworkFee(
14384
14380
  params.executionFeeToken,
14385
14381
  params.chainId
@@ -14438,13 +14434,20 @@ var Order = class {
14438
14434
  slSize: params.slSize ?? "0",
14439
14435
  slPrice: params.slPrice ?? "0"
14440
14436
  };
14441
- this.logger.info("createIncreaseOrder position params--->", data);
14442
14437
  const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
14443
14438
  const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
14444
- this.logger.info("seamlessWallet-->", seamlessWallet);
14445
- this.logger.info("authorized-->", authorized);
14446
- this.logger.info("config.seamlessMode-->", config.seamlessMode);
14447
14439
  if (config.seamlessMode && authorized && seamlessWallet) {
14440
+ if (needsApproval) {
14441
+ const approvalResult = await this.utils.approveAuthorization({
14442
+ chainId: params.chainId,
14443
+ quoteAddress: params.executionFeeToken,
14444
+ amount: import_ethers24.ethers.MaxUint256.toString(),
14445
+ signer: seamlessWallet
14446
+ });
14447
+ if (approvalResult.code !== 0) {
14448
+ throw new Error(approvalResult.message);
14449
+ }
14450
+ }
14448
14451
  const isEnoughGas = await this.utils.checkSeamlessGas(params.address);
14449
14452
  if (!isEnoughGas) {
14450
14453
  throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
@@ -14465,7 +14468,6 @@ var Order = class {
14465
14468
  { ...depositData },
14466
14469
  data
14467
14470
  ]);
14468
- this.logger.info("createIncreaseOrder placeOrderWithSalt function hash --->", functionHash);
14469
14471
  } else {
14470
14472
  functionHash = brokerContract2.interface.encodeFunctionData("placeOrderWithPosition", [
14471
14473
  params.positionId.toString(),
@@ -14492,6 +14494,19 @@ var Order = class {
14492
14494
  data: rs
14493
14495
  };
14494
14496
  }
14497
+ if (!config.signer) {
14498
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14499
+ }
14500
+ if (needsApproval) {
14501
+ const approvalResult = await this.utils.approveAuthorization({
14502
+ chainId: params.chainId,
14503
+ quoteAddress: params.executionFeeToken,
14504
+ amount: import_ethers24.ethers.MaxUint256.toString()
14505
+ });
14506
+ if (approvalResult.code !== 0) {
14507
+ throw new Error(approvalResult.message);
14508
+ }
14509
+ }
14495
14510
  const brokerContract = await getBrokerSingerContract(
14496
14511
  params.chainId,
14497
14512
  this.configManager.getConfig().brokerAddress
@@ -14566,10 +14581,6 @@ var Order = class {
14566
14581
  if (!config.signer) {
14567
14582
  throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14568
14583
  }
14569
- const brokerContract = await getBrokerSingerContract(
14570
- chainId,
14571
- this.configManager.getConfig().brokerAddress
14572
- );
14573
14584
  const networkFee = await this.utils.getNetworkFee(
14574
14585
  params[0].executionFeeToken,
14575
14586
  chainId
@@ -14580,16 +14591,6 @@ var Order = class {
14580
14591
  params[0].executionFeeToken,
14581
14592
  depositAmount.toString()
14582
14593
  );
14583
- if (needsApproval) {
14584
- const approvalResult = await this.utils.approveAuthorization({
14585
- chainId,
14586
- quoteAddress: params[0].executionFeeToken,
14587
- amount: import_ethers24.ethers.MaxUint256.toString()
14588
- });
14589
- if (approvalResult.code !== 0) {
14590
- throw new Error(approvalResult.message);
14591
- }
14592
- }
14593
14594
  const depositData = {
14594
14595
  token: params[0].executionFeeToken,
14595
14596
  amount: depositAmount.toString()
@@ -14618,6 +14619,63 @@ var Order = class {
14618
14619
  };
14619
14620
  });
14620
14621
  this.logger.info("closeAllPositions params--->", depositData, positionIds, dataMap);
14622
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
14623
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
14624
+ if (config.seamlessMode && authorized && seamlessWallet) {
14625
+ if (needsApproval) {
14626
+ const approvalResult = await this.utils.approveAuthorization({
14627
+ chainId,
14628
+ quoteAddress: params[0].executionFeeToken,
14629
+ amount: import_ethers24.ethers.MaxUint256.toString(),
14630
+ signer: seamlessWallet
14631
+ });
14632
+ if (approvalResult.code !== 0) {
14633
+ throw new Error(approvalResult.message);
14634
+ }
14635
+ }
14636
+ const isEnoughGas = await this.utils.checkSeamlessGas(params[0].address);
14637
+ if (!isEnoughGas) {
14638
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
14639
+ }
14640
+ const forwarderContract = await getForwarderContract(chainId);
14641
+ const brokerContract2 = await getSeamlessBrokerContract(
14642
+ this.configManager.getConfig().brokerAddress,
14643
+ seamlessWallet
14644
+ );
14645
+ const functionHash = brokerContract2.interface.encodeFunctionData("placeOrdersWithPosition", [depositData, positionIds, dataMap]);
14646
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
14647
+ const forwardTxParams = {
14648
+ from: seamlessWallet.address ?? "",
14649
+ to: this.configManager.getConfig().brokerAddress,
14650
+ value: "0",
14651
+ gas: "350000",
14652
+ deadline: (0, import_dayjs.default)().add(60, "minute").unix(),
14653
+ data: functionHash,
14654
+ nonce: nonce.toString()
14655
+ };
14656
+ this.logger.info("cancel all positions forward tx params --->", forwardTxParams);
14657
+ const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet);
14658
+ console.log("rs-->", rs);
14659
+ return {
14660
+ code: 0,
14661
+ message: "cancel all positions success",
14662
+ data: rs
14663
+ };
14664
+ }
14665
+ const brokerContract = await getBrokerSingerContract(
14666
+ chainId,
14667
+ this.configManager.getConfig().brokerAddress
14668
+ );
14669
+ if (needsApproval) {
14670
+ const approvalResult = await this.utils.approveAuthorization({
14671
+ chainId,
14672
+ quoteAddress: params[0].executionFeeToken,
14673
+ amount: import_ethers24.ethers.MaxUint256.toString()
14674
+ });
14675
+ if (approvalResult.code !== 0) {
14676
+ throw new Error(approvalResult.message);
14677
+ }
14678
+ }
14621
14679
  const gasLimit = await brokerContract.placeOrdersWithPosition.estimateGas(depositData, positionIds, dataMap);
14622
14680
  const transaction = await brokerContract.placeOrdersWithPosition(depositData, positionIds, dataMap, {
14623
14681
  gasLimit: gasLimit * 120n / 100n
@@ -14651,9 +14709,6 @@ var Order = class {
14651
14709
  async createDecreaseOrder(params) {
14652
14710
  try {
14653
14711
  const config = this.configManager.getConfig();
14654
- if (!config.signer) {
14655
- throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14656
- }
14657
14712
  const brokerContract = await getBrokerSingerContract(
14658
14713
  params.chainId,
14659
14714
  this.configManager.getConfig().brokerAddress
@@ -14691,6 +14746,65 @@ var Order = class {
14691
14746
  params.executionFeeToken,
14692
14747
  networkFee.toString()
14693
14748
  );
14749
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
14750
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
14751
+ if (config.seamlessMode && authorized && seamlessWallet) {
14752
+ if (needsApproval) {
14753
+ const approvalResult = await this.utils.approveAuthorization({
14754
+ chainId: params.chainId,
14755
+ quoteAddress: params.executionFeeToken,
14756
+ amount: import_ethers24.ethers.MaxUint256.toString(),
14757
+ signer: seamlessWallet
14758
+ });
14759
+ if (approvalResult.code !== 0) {
14760
+ throw new Error(approvalResult.message);
14761
+ }
14762
+ }
14763
+ const isEnoughGas = await this.utils.checkSeamlessGas(params.address);
14764
+ if (!isEnoughGas) {
14765
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
14766
+ }
14767
+ const forwarderContract = await getForwarderContract(params.chainId);
14768
+ const brokerContract2 = await getSeamlessBrokerContract(
14769
+ this.configManager.getConfig().brokerAddress,
14770
+ seamlessWallet
14771
+ );
14772
+ let functionHash = "";
14773
+ if (!params.positionId) {
14774
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrderWithSalt", [
14775
+ "1",
14776
+ { ...depositData },
14777
+ data
14778
+ ]);
14779
+ } else {
14780
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrderWithPosition", [
14781
+ params.positionId.toString(),
14782
+ { ...depositData },
14783
+ data
14784
+ ]);
14785
+ }
14786
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
14787
+ const forwardTxParams = {
14788
+ from: seamlessWallet.address ?? "",
14789
+ to: this.configManager.getConfig().brokerAddress,
14790
+ value: "0",
14791
+ gas: "350000",
14792
+ deadline: (0, import_dayjs.default)().add(60, "minute").unix(),
14793
+ data: functionHash,
14794
+ nonce: nonce.toString()
14795
+ };
14796
+ this.logger.info("create decrease order forward tx params --->", forwardTxParams);
14797
+ const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet);
14798
+ console.log("rs-->", rs);
14799
+ return {
14800
+ code: 0,
14801
+ message: "create decrease order success",
14802
+ data: rs
14803
+ };
14804
+ }
14805
+ if (!config.signer) {
14806
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14807
+ }
14694
14808
  if (needsApproval) {
14695
14809
  const approvalResult = await this.utils.approveAuthorization({
14696
14810
  chainId: params.chainId,
@@ -14767,7 +14881,7 @@ var Order = class {
14767
14881
  async createPositionTpSlOrder(params) {
14768
14882
  try {
14769
14883
  const config = this.configManager.getConfig();
14770
- if (!config.signer) {
14884
+ if (!config.signer && !config.seamlessMode) {
14771
14885
  throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14772
14886
  }
14773
14887
  const brokerContract = await getBrokerSingerContract(
@@ -14828,6 +14942,62 @@ var Order = class {
14828
14942
  params.executionFeeToken,
14829
14943
  depositAmount.toString()
14830
14944
  );
14945
+ const authorized2 = this.configManager.getConfig().seamlessAccount?.authorized;
14946
+ const seamlessWallet2 = this.configManager.getConfig().seamlessAccount?.wallet;
14947
+ if (config.seamlessMode && authorized2 && seamlessWallet2) {
14948
+ if (needsApproval2) {
14949
+ const approvalResult = await this.utils.approveAuthorization({
14950
+ chainId: params.chainId,
14951
+ quoteAddress: params.executionFeeToken,
14952
+ amount: import_ethers24.ethers.MaxUint256.toString(),
14953
+ signer: seamlessWallet2
14954
+ });
14955
+ if (approvalResult.code !== 0) {
14956
+ throw new Error(approvalResult.message);
14957
+ }
14958
+ }
14959
+ const isEnoughGas = await this.utils.checkSeamlessGas(params.address);
14960
+ if (!isEnoughGas) {
14961
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
14962
+ }
14963
+ const forwarderContract = await getForwarderContract(params.chainId);
14964
+ const brokerContract2 = await getSeamlessBrokerContract(
14965
+ this.configManager.getConfig().brokerAddress,
14966
+ seamlessWallet2
14967
+ );
14968
+ let functionHash = "";
14969
+ if (!params.positionId) {
14970
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrdersWithSalt", [
14971
+ { token: params.executionFeeToken, amount: depositAmount.toString() },
14972
+ ["1", "1"],
14973
+ data2
14974
+ ]);
14975
+ } else {
14976
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrdersWithPosition", [
14977
+ { token: params.executionFeeToken, amount: depositAmount.toString() },
14978
+ [params.positionId.toString(), params.positionId.toString()],
14979
+ data2
14980
+ ]);
14981
+ }
14982
+ const nonce = await forwarderContract.nonces(seamlessWallet2.address);
14983
+ const forwardTxParams = {
14984
+ from: seamlessWallet2.address ?? "",
14985
+ to: this.configManager.getConfig().brokerAddress,
14986
+ value: "0",
14987
+ gas: "350000",
14988
+ deadline: (0, import_dayjs.default)().add(60, "minute").unix(),
14989
+ data: functionHash,
14990
+ nonce: nonce.toString()
14991
+ };
14992
+ this.logger.info("createPositionTpSlOrder forward tx params --->", forwardTxParams);
14993
+ const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet2);
14994
+ console.log("rs-->", rs);
14995
+ return {
14996
+ code: 0,
14997
+ message: "createPositionTpSlOrder success",
14998
+ data: rs
14999
+ };
15000
+ }
14831
15001
  if (needsApproval2) {
14832
15002
  const approvalResult = await this.utils.approveAuthorization({
14833
15003
  chainId: params.chainId,
@@ -14911,6 +15081,62 @@ var Order = class {
14911
15081
  params.executionFeeToken,
14912
15082
  networkFee.toString()
14913
15083
  );
15084
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
15085
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
15086
+ if (config.seamlessMode && authorized && seamlessWallet) {
15087
+ if (needsApproval) {
15088
+ const approvalResult = await this.utils.approveAuthorization({
15089
+ chainId: params.chainId,
15090
+ quoteAddress: params.executionFeeToken,
15091
+ amount: import_ethers24.ethers.MaxUint256.toString(),
15092
+ signer: seamlessWallet
15093
+ });
15094
+ if (approvalResult.code !== 0) {
15095
+ throw new Error(approvalResult.message);
15096
+ }
15097
+ }
15098
+ const isEnoughGas = await this.utils.checkSeamlessGas(params.address);
15099
+ if (!isEnoughGas) {
15100
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
15101
+ }
15102
+ const forwarderContract = await getForwarderContract(params.chainId);
15103
+ const brokerContract2 = await getSeamlessBrokerContract(
15104
+ this.configManager.getConfig().brokerAddress,
15105
+ seamlessWallet
15106
+ );
15107
+ let functionHash = "";
15108
+ if (!params.positionId) {
15109
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrderWithSalt", [
15110
+ "1",
15111
+ depositData,
15112
+ data
15113
+ ]);
15114
+ } else {
15115
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrderWithPosition", [
15116
+ params.positionId.toString(),
15117
+ depositData,
15118
+ data
15119
+ ]);
15120
+ }
15121
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
15122
+ const forwardTxParams = {
15123
+ from: seamlessWallet.address ?? "",
15124
+ to: this.configManager.getConfig().brokerAddress,
15125
+ value: "0",
15126
+ gas: "350000",
15127
+ deadline: (0, import_dayjs.default)().add(60, "minute").unix(),
15128
+ data: functionHash,
15129
+ nonce: nonce.toString()
15130
+ };
15131
+ this.logger.info("createPositionTpSlOrder forward tx params --->", forwardTxParams);
15132
+ const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet);
15133
+ console.log("rs-->", rs);
15134
+ return {
15135
+ code: 0,
15136
+ message: "createPositionTpSlOrder success",
15137
+ data: rs
15138
+ };
15139
+ }
14914
15140
  if (needsApproval) {
14915
15141
  const approvalResult = await this.utils.approveAuthorization({
14916
15142
  chainId: params.chainId,
@@ -14983,6 +15209,38 @@ var Order = class {
14983
15209
  async cancelAllOrders(orderIds, chainId) {
14984
15210
  try {
14985
15211
  const config = this.configManager.getConfig();
15212
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
15213
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
15214
+ if (config.seamlessMode && authorized && seamlessWallet) {
15215
+ const isEnoughGas = await this.utils.checkSeamlessGas(config.seamlessAccount?.masterAddress);
15216
+ if (!isEnoughGas) {
15217
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
15218
+ }
15219
+ const forwarderContract = await getForwarderContract(chainId);
15220
+ const brokerContract2 = await getSeamlessBrokerContract(
15221
+ this.configManager.getConfig().brokerAddress,
15222
+ seamlessWallet
15223
+ );
15224
+ let functionHash = brokerContract2.interface.encodeFunctionData("cancelOrders", [orderIds]);
15225
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
15226
+ const forwardTxParams = {
15227
+ from: seamlessWallet.address ?? "",
15228
+ to: this.configManager.getConfig().brokerAddress,
15229
+ value: "0",
15230
+ gas: "350000",
15231
+ deadline: (0, import_dayjs.default)().add(60, "minute").unix(),
15232
+ data: functionHash,
15233
+ nonce: nonce.toString()
15234
+ };
15235
+ this.logger.info("create decrease order forward tx params --->", forwardTxParams);
15236
+ const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet);
15237
+ console.log("rs-->", rs);
15238
+ return {
15239
+ code: 0,
15240
+ message: "create decrease order success",
15241
+ data: rs
15242
+ };
15243
+ }
14986
15244
  if (!config.signer) {
14987
15245
  throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14988
15246
  }
@@ -19874,7 +20132,8 @@ var Utils = class {
19874
20132
  chainId,
19875
20133
  quoteAddress,
19876
20134
  amount,
19877
- spenderAddress
20135
+ spenderAddress,
20136
+ signer
19878
20137
  }) {
19879
20138
  try {
19880
20139
  const erc20Abi = [
@@ -19884,7 +20143,7 @@ var Utils = class {
19884
20143
  const usdcContract = new import_ethers25.ethers.Contract(
19885
20144
  quoteAddress,
19886
20145
  erc20Abi,
19887
- config.signer
20146
+ signer ?? config.signer
19888
20147
  );
19889
20148
  const approveAmount = amount ?? import_ethers25.ethers.MaxUint256;
19890
20149
  const spender = spenderAddress ?? getContractAddressByChainId(chainId).Account;
@@ -21364,7 +21623,7 @@ var Seamless = class {
21364
21623
  };
21365
21624
  }
21366
21625
  async startSeamlessMode({ open }) {
21367
- this.configManager.startSeamlessMode(open);
21626
+ const config = this.configManager.startSeamlessMode(open);
21368
21627
  return {
21369
21628
  code: 0,
21370
21629
  data: {
package/dist/index.mjs CHANGED
@@ -1732,7 +1732,7 @@ var RotationProvider = class extends BaseProvider {
1732
1732
  // package.json
1733
1733
  var package_default = {
1734
1734
  name: "@myx-trade/sdk",
1735
- version: "0.1.106",
1735
+ version: "0.1.108",
1736
1736
  private: false,
1737
1737
  publishConfig: {
1738
1738
  access: "public"
@@ -13650,12 +13650,11 @@ var ConfigManager = class {
13650
13650
  };
13651
13651
  }
13652
13652
  startSeamlessMode(open) {
13653
- console.log("startSeamlessMode-->", this.config, open);
13654
13653
  this.config = {
13655
13654
  ...this.config,
13656
13655
  seamlessMode: open
13657
13656
  };
13658
- console.log("startSeamlessMode-->", this.config);
13657
+ return this.config;
13659
13658
  }
13660
13659
  updateSeamlessWallet({ wallet, authorized, masterAddress }) {
13661
13660
  this.config = {
@@ -14287,9 +14286,6 @@ var Order = class {
14287
14286
  async createIncreaseOrder(params) {
14288
14287
  try {
14289
14288
  const config = this.configManager.getConfig();
14290
- if (!config.signer) {
14291
- throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14292
- }
14293
14289
  const networkFee = await this.utils.getNetworkFee(
14294
14290
  params.executionFeeToken,
14295
14291
  params.chainId
@@ -14348,13 +14344,20 @@ var Order = class {
14348
14344
  slSize: params.slSize ?? "0",
14349
14345
  slPrice: params.slPrice ?? "0"
14350
14346
  };
14351
- this.logger.info("createIncreaseOrder position params--->", data);
14352
14347
  const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
14353
14348
  const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
14354
- this.logger.info("seamlessWallet-->", seamlessWallet);
14355
- this.logger.info("authorized-->", authorized);
14356
- this.logger.info("config.seamlessMode-->", config.seamlessMode);
14357
14349
  if (config.seamlessMode && authorized && seamlessWallet) {
14350
+ if (needsApproval) {
14351
+ const approvalResult = await this.utils.approveAuthorization({
14352
+ chainId: params.chainId,
14353
+ quoteAddress: params.executionFeeToken,
14354
+ amount: ethers6.MaxUint256.toString(),
14355
+ signer: seamlessWallet
14356
+ });
14357
+ if (approvalResult.code !== 0) {
14358
+ throw new Error(approvalResult.message);
14359
+ }
14360
+ }
14358
14361
  const isEnoughGas = await this.utils.checkSeamlessGas(params.address);
14359
14362
  if (!isEnoughGas) {
14360
14363
  throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
@@ -14375,7 +14378,6 @@ var Order = class {
14375
14378
  { ...depositData },
14376
14379
  data
14377
14380
  ]);
14378
- this.logger.info("createIncreaseOrder placeOrderWithSalt function hash --->", functionHash);
14379
14381
  } else {
14380
14382
  functionHash = brokerContract2.interface.encodeFunctionData("placeOrderWithPosition", [
14381
14383
  params.positionId.toString(),
@@ -14402,6 +14404,19 @@ var Order = class {
14402
14404
  data: rs
14403
14405
  };
14404
14406
  }
14407
+ if (!config.signer) {
14408
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14409
+ }
14410
+ if (needsApproval) {
14411
+ const approvalResult = await this.utils.approveAuthorization({
14412
+ chainId: params.chainId,
14413
+ quoteAddress: params.executionFeeToken,
14414
+ amount: ethers6.MaxUint256.toString()
14415
+ });
14416
+ if (approvalResult.code !== 0) {
14417
+ throw new Error(approvalResult.message);
14418
+ }
14419
+ }
14405
14420
  const brokerContract = await getBrokerSingerContract(
14406
14421
  params.chainId,
14407
14422
  this.configManager.getConfig().brokerAddress
@@ -14476,10 +14491,6 @@ var Order = class {
14476
14491
  if (!config.signer) {
14477
14492
  throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14478
14493
  }
14479
- const brokerContract = await getBrokerSingerContract(
14480
- chainId,
14481
- this.configManager.getConfig().brokerAddress
14482
- );
14483
14494
  const networkFee = await this.utils.getNetworkFee(
14484
14495
  params[0].executionFeeToken,
14485
14496
  chainId
@@ -14490,16 +14501,6 @@ var Order = class {
14490
14501
  params[0].executionFeeToken,
14491
14502
  depositAmount.toString()
14492
14503
  );
14493
- if (needsApproval) {
14494
- const approvalResult = await this.utils.approveAuthorization({
14495
- chainId,
14496
- quoteAddress: params[0].executionFeeToken,
14497
- amount: ethers6.MaxUint256.toString()
14498
- });
14499
- if (approvalResult.code !== 0) {
14500
- throw new Error(approvalResult.message);
14501
- }
14502
- }
14503
14504
  const depositData = {
14504
14505
  token: params[0].executionFeeToken,
14505
14506
  amount: depositAmount.toString()
@@ -14528,6 +14529,63 @@ var Order = class {
14528
14529
  };
14529
14530
  });
14530
14531
  this.logger.info("closeAllPositions params--->", depositData, positionIds, dataMap);
14532
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
14533
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
14534
+ if (config.seamlessMode && authorized && seamlessWallet) {
14535
+ if (needsApproval) {
14536
+ const approvalResult = await this.utils.approveAuthorization({
14537
+ chainId,
14538
+ quoteAddress: params[0].executionFeeToken,
14539
+ amount: ethers6.MaxUint256.toString(),
14540
+ signer: seamlessWallet
14541
+ });
14542
+ if (approvalResult.code !== 0) {
14543
+ throw new Error(approvalResult.message);
14544
+ }
14545
+ }
14546
+ const isEnoughGas = await this.utils.checkSeamlessGas(params[0].address);
14547
+ if (!isEnoughGas) {
14548
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
14549
+ }
14550
+ const forwarderContract = await getForwarderContract(chainId);
14551
+ const brokerContract2 = await getSeamlessBrokerContract(
14552
+ this.configManager.getConfig().brokerAddress,
14553
+ seamlessWallet
14554
+ );
14555
+ const functionHash = brokerContract2.interface.encodeFunctionData("placeOrdersWithPosition", [depositData, positionIds, dataMap]);
14556
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
14557
+ const forwardTxParams = {
14558
+ from: seamlessWallet.address ?? "",
14559
+ to: this.configManager.getConfig().brokerAddress,
14560
+ value: "0",
14561
+ gas: "350000",
14562
+ deadline: dayjs().add(60, "minute").unix(),
14563
+ data: functionHash,
14564
+ nonce: nonce.toString()
14565
+ };
14566
+ this.logger.info("cancel all positions forward tx params --->", forwardTxParams);
14567
+ const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet);
14568
+ console.log("rs-->", rs);
14569
+ return {
14570
+ code: 0,
14571
+ message: "cancel all positions success",
14572
+ data: rs
14573
+ };
14574
+ }
14575
+ const brokerContract = await getBrokerSingerContract(
14576
+ chainId,
14577
+ this.configManager.getConfig().brokerAddress
14578
+ );
14579
+ if (needsApproval) {
14580
+ const approvalResult = await this.utils.approveAuthorization({
14581
+ chainId,
14582
+ quoteAddress: params[0].executionFeeToken,
14583
+ amount: ethers6.MaxUint256.toString()
14584
+ });
14585
+ if (approvalResult.code !== 0) {
14586
+ throw new Error(approvalResult.message);
14587
+ }
14588
+ }
14531
14589
  const gasLimit = await brokerContract.placeOrdersWithPosition.estimateGas(depositData, positionIds, dataMap);
14532
14590
  const transaction = await brokerContract.placeOrdersWithPosition(depositData, positionIds, dataMap, {
14533
14591
  gasLimit: gasLimit * 120n / 100n
@@ -14561,9 +14619,6 @@ var Order = class {
14561
14619
  async createDecreaseOrder(params) {
14562
14620
  try {
14563
14621
  const config = this.configManager.getConfig();
14564
- if (!config.signer) {
14565
- throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14566
- }
14567
14622
  const brokerContract = await getBrokerSingerContract(
14568
14623
  params.chainId,
14569
14624
  this.configManager.getConfig().brokerAddress
@@ -14601,6 +14656,65 @@ var Order = class {
14601
14656
  params.executionFeeToken,
14602
14657
  networkFee.toString()
14603
14658
  );
14659
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
14660
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
14661
+ if (config.seamlessMode && authorized && seamlessWallet) {
14662
+ if (needsApproval) {
14663
+ const approvalResult = await this.utils.approveAuthorization({
14664
+ chainId: params.chainId,
14665
+ quoteAddress: params.executionFeeToken,
14666
+ amount: ethers6.MaxUint256.toString(),
14667
+ signer: seamlessWallet
14668
+ });
14669
+ if (approvalResult.code !== 0) {
14670
+ throw new Error(approvalResult.message);
14671
+ }
14672
+ }
14673
+ const isEnoughGas = await this.utils.checkSeamlessGas(params.address);
14674
+ if (!isEnoughGas) {
14675
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
14676
+ }
14677
+ const forwarderContract = await getForwarderContract(params.chainId);
14678
+ const brokerContract2 = await getSeamlessBrokerContract(
14679
+ this.configManager.getConfig().brokerAddress,
14680
+ seamlessWallet
14681
+ );
14682
+ let functionHash = "";
14683
+ if (!params.positionId) {
14684
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrderWithSalt", [
14685
+ "1",
14686
+ { ...depositData },
14687
+ data
14688
+ ]);
14689
+ } else {
14690
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrderWithPosition", [
14691
+ params.positionId.toString(),
14692
+ { ...depositData },
14693
+ data
14694
+ ]);
14695
+ }
14696
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
14697
+ const forwardTxParams = {
14698
+ from: seamlessWallet.address ?? "",
14699
+ to: this.configManager.getConfig().brokerAddress,
14700
+ value: "0",
14701
+ gas: "350000",
14702
+ deadline: dayjs().add(60, "minute").unix(),
14703
+ data: functionHash,
14704
+ nonce: nonce.toString()
14705
+ };
14706
+ this.logger.info("create decrease order forward tx params --->", forwardTxParams);
14707
+ const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet);
14708
+ console.log("rs-->", rs);
14709
+ return {
14710
+ code: 0,
14711
+ message: "create decrease order success",
14712
+ data: rs
14713
+ };
14714
+ }
14715
+ if (!config.signer) {
14716
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14717
+ }
14604
14718
  if (needsApproval) {
14605
14719
  const approvalResult = await this.utils.approveAuthorization({
14606
14720
  chainId: params.chainId,
@@ -14677,7 +14791,7 @@ var Order = class {
14677
14791
  async createPositionTpSlOrder(params) {
14678
14792
  try {
14679
14793
  const config = this.configManager.getConfig();
14680
- if (!config.signer) {
14794
+ if (!config.signer && !config.seamlessMode) {
14681
14795
  throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14682
14796
  }
14683
14797
  const brokerContract = await getBrokerSingerContract(
@@ -14738,6 +14852,62 @@ var Order = class {
14738
14852
  params.executionFeeToken,
14739
14853
  depositAmount.toString()
14740
14854
  );
14855
+ const authorized2 = this.configManager.getConfig().seamlessAccount?.authorized;
14856
+ const seamlessWallet2 = this.configManager.getConfig().seamlessAccount?.wallet;
14857
+ if (config.seamlessMode && authorized2 && seamlessWallet2) {
14858
+ if (needsApproval2) {
14859
+ const approvalResult = await this.utils.approveAuthorization({
14860
+ chainId: params.chainId,
14861
+ quoteAddress: params.executionFeeToken,
14862
+ amount: ethers6.MaxUint256.toString(),
14863
+ signer: seamlessWallet2
14864
+ });
14865
+ if (approvalResult.code !== 0) {
14866
+ throw new Error(approvalResult.message);
14867
+ }
14868
+ }
14869
+ const isEnoughGas = await this.utils.checkSeamlessGas(params.address);
14870
+ if (!isEnoughGas) {
14871
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
14872
+ }
14873
+ const forwarderContract = await getForwarderContract(params.chainId);
14874
+ const brokerContract2 = await getSeamlessBrokerContract(
14875
+ this.configManager.getConfig().brokerAddress,
14876
+ seamlessWallet2
14877
+ );
14878
+ let functionHash = "";
14879
+ if (!params.positionId) {
14880
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrdersWithSalt", [
14881
+ { token: params.executionFeeToken, amount: depositAmount.toString() },
14882
+ ["1", "1"],
14883
+ data2
14884
+ ]);
14885
+ } else {
14886
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrdersWithPosition", [
14887
+ { token: params.executionFeeToken, amount: depositAmount.toString() },
14888
+ [params.positionId.toString(), params.positionId.toString()],
14889
+ data2
14890
+ ]);
14891
+ }
14892
+ const nonce = await forwarderContract.nonces(seamlessWallet2.address);
14893
+ const forwardTxParams = {
14894
+ from: seamlessWallet2.address ?? "",
14895
+ to: this.configManager.getConfig().brokerAddress,
14896
+ value: "0",
14897
+ gas: "350000",
14898
+ deadline: dayjs().add(60, "minute").unix(),
14899
+ data: functionHash,
14900
+ nonce: nonce.toString()
14901
+ };
14902
+ this.logger.info("createPositionTpSlOrder forward tx params --->", forwardTxParams);
14903
+ const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet2);
14904
+ console.log("rs-->", rs);
14905
+ return {
14906
+ code: 0,
14907
+ message: "createPositionTpSlOrder success",
14908
+ data: rs
14909
+ };
14910
+ }
14741
14911
  if (needsApproval2) {
14742
14912
  const approvalResult = await this.utils.approveAuthorization({
14743
14913
  chainId: params.chainId,
@@ -14821,6 +14991,62 @@ var Order = class {
14821
14991
  params.executionFeeToken,
14822
14992
  networkFee.toString()
14823
14993
  );
14994
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
14995
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
14996
+ if (config.seamlessMode && authorized && seamlessWallet) {
14997
+ if (needsApproval) {
14998
+ const approvalResult = await this.utils.approveAuthorization({
14999
+ chainId: params.chainId,
15000
+ quoteAddress: params.executionFeeToken,
15001
+ amount: ethers6.MaxUint256.toString(),
15002
+ signer: seamlessWallet
15003
+ });
15004
+ if (approvalResult.code !== 0) {
15005
+ throw new Error(approvalResult.message);
15006
+ }
15007
+ }
15008
+ const isEnoughGas = await this.utils.checkSeamlessGas(params.address);
15009
+ if (!isEnoughGas) {
15010
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
15011
+ }
15012
+ const forwarderContract = await getForwarderContract(params.chainId);
15013
+ const brokerContract2 = await getSeamlessBrokerContract(
15014
+ this.configManager.getConfig().brokerAddress,
15015
+ seamlessWallet
15016
+ );
15017
+ let functionHash = "";
15018
+ if (!params.positionId) {
15019
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrderWithSalt", [
15020
+ "1",
15021
+ depositData,
15022
+ data
15023
+ ]);
15024
+ } else {
15025
+ functionHash = brokerContract2.interface.encodeFunctionData("placeOrderWithPosition", [
15026
+ params.positionId.toString(),
15027
+ depositData,
15028
+ data
15029
+ ]);
15030
+ }
15031
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
15032
+ const forwardTxParams = {
15033
+ from: seamlessWallet.address ?? "",
15034
+ to: this.configManager.getConfig().brokerAddress,
15035
+ value: "0",
15036
+ gas: "350000",
15037
+ deadline: dayjs().add(60, "minute").unix(),
15038
+ data: functionHash,
15039
+ nonce: nonce.toString()
15040
+ };
15041
+ this.logger.info("createPositionTpSlOrder forward tx params --->", forwardTxParams);
15042
+ const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet);
15043
+ console.log("rs-->", rs);
15044
+ return {
15045
+ code: 0,
15046
+ message: "createPositionTpSlOrder success",
15047
+ data: rs
15048
+ };
15049
+ }
14824
15050
  if (needsApproval) {
14825
15051
  const approvalResult = await this.utils.approveAuthorization({
14826
15052
  chainId: params.chainId,
@@ -14893,6 +15119,38 @@ var Order = class {
14893
15119
  async cancelAllOrders(orderIds, chainId) {
14894
15120
  try {
14895
15121
  const config = this.configManager.getConfig();
15122
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
15123
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
15124
+ if (config.seamlessMode && authorized && seamlessWallet) {
15125
+ const isEnoughGas = await this.utils.checkSeamlessGas(config.seamlessAccount?.masterAddress);
15126
+ if (!isEnoughGas) {
15127
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
15128
+ }
15129
+ const forwarderContract = await getForwarderContract(chainId);
15130
+ const brokerContract2 = await getSeamlessBrokerContract(
15131
+ this.configManager.getConfig().brokerAddress,
15132
+ seamlessWallet
15133
+ );
15134
+ let functionHash = brokerContract2.interface.encodeFunctionData("cancelOrders", [orderIds]);
15135
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
15136
+ const forwardTxParams = {
15137
+ from: seamlessWallet.address ?? "",
15138
+ to: this.configManager.getConfig().brokerAddress,
15139
+ value: "0",
15140
+ gas: "350000",
15141
+ deadline: dayjs().add(60, "minute").unix(),
15142
+ data: functionHash,
15143
+ nonce: nonce.toString()
15144
+ };
15145
+ this.logger.info("create decrease order forward tx params --->", forwardTxParams);
15146
+ const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet);
15147
+ console.log("rs-->", rs);
15148
+ return {
15149
+ code: 0,
15150
+ message: "create decrease order success",
15151
+ data: rs
15152
+ };
15153
+ }
14896
15154
  if (!config.signer) {
14897
15155
  throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Invalid signer");
14898
15156
  }
@@ -19784,7 +20042,8 @@ var Utils = class {
19784
20042
  chainId,
19785
20043
  quoteAddress,
19786
20044
  amount,
19787
- spenderAddress
20045
+ spenderAddress,
20046
+ signer
19788
20047
  }) {
19789
20048
  try {
19790
20049
  const erc20Abi = [
@@ -19794,7 +20053,7 @@ var Utils = class {
19794
20053
  const usdcContract = new ethers7.Contract(
19795
20054
  quoteAddress,
19796
20055
  erc20Abi,
19797
- config.signer
20056
+ signer ?? config.signer
19798
20057
  );
19799
20058
  const approveAmount = amount ?? ethers7.MaxUint256;
19800
20059
  const spender = spenderAddress ?? getContractAddressByChainId(chainId).Account;
@@ -21274,7 +21533,7 @@ var Seamless = class {
21274
21533
  };
21275
21534
  }
21276
21535
  async startSeamlessMode({ open }) {
21277
- this.configManager.startSeamlessMode(open);
21536
+ const config = this.configManager.startSeamlessMode(open);
21278
21537
  return {
21279
21538
  code: 0,
21280
21539
  data: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.106",
3
+ "version": "0.1.108",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"