@myx-trade/sdk 0.1.140 → 0.1.142

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
@@ -1508,7 +1508,7 @@ declare class Seamless {
1508
1508
  onCheckRelayer(account: string, relayer: string, chainId: number): Promise<boolean>;
1509
1509
  getUSDPermitParams(deadline: number, chainId: number): Promise<{
1510
1510
  token: string | ethers$1.Addressable;
1511
- owner: Promise<string> | undefined;
1511
+ owner: string;
1512
1512
  spender: string;
1513
1513
  value: bigint;
1514
1514
  deadline: number;
package/dist/index.d.ts CHANGED
@@ -1508,7 +1508,7 @@ declare class Seamless {
1508
1508
  onCheckRelayer(account: string, relayer: string, chainId: number): Promise<boolean>;
1509
1509
  getUSDPermitParams(deadline: number, chainId: number): Promise<{
1510
1510
  token: string | ethers$1.Addressable;
1511
- owner: Promise<string> | undefined;
1511
+ owner: string;
1512
1512
  spender: string;
1513
1513
  value: bigint;
1514
1514
  deadline: number;
package/dist/index.js CHANGED
@@ -1821,7 +1821,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
1821
1821
  // package.json
1822
1822
  var package_default = {
1823
1823
  name: "@myx-trade/sdk",
1824
- version: "0.1.140",
1824
+ version: "0.1.142",
1825
1825
  private: false,
1826
1826
  publishConfig: {
1827
1827
  access: "public"
@@ -12712,7 +12712,6 @@ var getPoolInfo2 = async (chainId, poolId, marketPrice = 0n) => {
12712
12712
  poolEntryPrice: request.oi.poolEntryPrice
12713
12713
  }
12714
12714
  };
12715
- console.log(info);
12716
12715
  return info;
12717
12716
  } catch (error) {
12718
12717
  console.error(error);
@@ -13271,13 +13270,10 @@ var MyxWebSocketClient = class {
13271
13270
  */
13272
13271
  subscribe(subscription, callback) {
13273
13272
  const subscriptionList = Array.isArray(subscription) ? subscription : [subscription];
13274
- console.log("sinscribes:", subscriptionList);
13275
- this.logger.debug("subscriptionList:", subscriptionList);
13276
13273
  const newSubscriptionIds = [];
13277
13274
  const processedIds = /* @__PURE__ */ new Set();
13278
13275
  subscriptionList.forEach((subscriptionItem) => {
13279
13276
  const subscriptionId = generateListenerId(subscriptionItem);
13280
- this.logger.debug("subscriptionId:", subscriptionId);
13281
13277
  if (processedIds.has(subscriptionId)) {
13282
13278
  return;
13283
13279
  }
@@ -13285,9 +13281,6 @@ var MyxWebSocketClient = class {
13285
13281
  if (this.subscriptions.has(subscriptionId)) {
13286
13282
  const existingSubscription = this.subscriptions.get(subscriptionId);
13287
13283
  existingSubscription.callbacks.add(callback);
13288
- this.logger.debug(
13289
- `add callback to existing subscription: ${subscriptionId}`
13290
- );
13291
13284
  } else {
13292
13285
  const subscriptionObj = {
13293
13286
  id: subscriptionId,
@@ -13590,7 +13583,6 @@ var SubScription = class {
13590
13583
  * tickers subscription methods
13591
13584
  */
13592
13585
  subscribeTickers(globalIds, callback) {
13593
- this.logger.debug(`subscribe tickers ${globalIds}`);
13594
13586
  const globalIdsList = Array.isArray(globalIds) ? globalIds : [globalIds];
13595
13587
  this.wsClient.subscribe(
13596
13588
  globalIdsList.map((globalId) => ({
@@ -13601,7 +13593,6 @@ var SubScription = class {
13601
13593
  );
13602
13594
  }
13603
13595
  unsubscribeTickers(globalIds, callback) {
13604
- this.logger.debug(`unsubscribe tickers ${globalIds}`);
13605
13596
  const globalIdsList = Array.isArray(globalIds) ? globalIds : [globalIds];
13606
13597
  this.wsClient.unsubscribe(
13607
13598
  globalIdsList.map((globalId) => ({
@@ -14306,6 +14297,7 @@ var Order = class {
14306
14297
  params.executionFeeToken,
14307
14298
  params.collateralAmount
14308
14299
  );
14300
+ const totalCollateralAmount = BigInt(params.collateralAmount) + BigInt(tradingFee);
14309
14301
  const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({ poolId: params.poolId, chainId: params.chainId, address: params.address });
14310
14302
  const needAmount = BigInt(tradingFee) + BigInt(params.collateralAmount) + totalNetWorkFee;
14311
14303
  let depositAmount = BigInt(0);
@@ -14324,7 +14316,7 @@ var Order = class {
14324
14316
  triggerType: params.triggerType,
14325
14317
  operation: OperationType.INCREASE,
14326
14318
  direction: params.direction,
14327
- collateralAmount: params.collateralAmount,
14319
+ collateralAmount: totalCollateralAmount.toString(),
14328
14320
  size: params.size,
14329
14321
  price: params.price,
14330
14322
  timeInForce: TIME_IN_FORCE,
@@ -21395,7 +21387,10 @@ var Seamless = class {
21395
21387
  }
21396
21388
  async getUSDPermitParams(deadline, chainId) {
21397
21389
  const config = this.configManager.getConfig();
21398
- const masterAddress = config.signer?.getAddress();
21390
+ if (!config.signer) {
21391
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Signer is required for permit");
21392
+ }
21393
+ const masterAddress = await config.signer.getAddress();
21399
21394
  const brokerAddress = config.brokerAddress;
21400
21395
  const contractAddress = getContractAddressByChainId(chainId);
21401
21396
  const erc20Contract = new import_ethers27.ethers.Contract(
@@ -21403,17 +21398,16 @@ var Seamless = class {
21403
21398
  ERC20Token_default,
21404
21399
  config.signer
21405
21400
  );
21406
- const walletProvider = await getWalletProvider(chainId);
21407
21401
  try {
21408
21402
  const nonces = await erc20Contract.nonces(masterAddress);
21409
21403
  const brokerSignPermit = await signPermit(
21410
- // @ts-ignore
21411
- walletProvider,
21404
+ config.signer,
21405
+ // 使用 signer 而不是 provider
21412
21406
  erc20Contract,
21413
21407
  masterAddress,
21414
21408
  brokerAddress,
21415
- import_ethers27.ethers.MaxUint256,
21416
- nonces,
21409
+ import_ethers27.ethers.MaxUint256.toString(),
21410
+ nonces.toString(),
21417
21411
  deadline.toString(),
21418
21412
  chainId
21419
21413
  );
@@ -21427,10 +21421,8 @@ var Seamless = class {
21427
21421
  r: brokerSignPermit.r,
21428
21422
  s: brokerSignPermit.s
21429
21423
  };
21430
- console.log("brokerSeamlessUSDPermitParams-->", brokerSeamlessUSDPermitParams);
21431
21424
  return [brokerSeamlessUSDPermitParams];
21432
21425
  } catch (error) {
21433
- this.logger.error("getUSDPermitParams error-->", error);
21434
21426
  throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key generated");
21435
21427
  }
21436
21428
  }
package/dist/index.mjs CHANGED
@@ -1731,7 +1731,7 @@ var RotationProvider = class extends BaseProvider {
1731
1731
  // package.json
1732
1732
  var package_default = {
1733
1733
  name: "@myx-trade/sdk",
1734
- version: "0.1.140",
1734
+ version: "0.1.142",
1735
1735
  private: false,
1736
1736
  publishConfig: {
1737
1737
  access: "public"
@@ -12622,7 +12622,6 @@ var getPoolInfo2 = async (chainId, poolId, marketPrice = 0n) => {
12622
12622
  poolEntryPrice: request.oi.poolEntryPrice
12623
12623
  }
12624
12624
  };
12625
- console.log(info);
12626
12625
  return info;
12627
12626
  } catch (error) {
12628
12627
  console.error(error);
@@ -13181,13 +13180,10 @@ var MyxWebSocketClient = class {
13181
13180
  */
13182
13181
  subscribe(subscription, callback) {
13183
13182
  const subscriptionList = Array.isArray(subscription) ? subscription : [subscription];
13184
- console.log("sinscribes:", subscriptionList);
13185
- this.logger.debug("subscriptionList:", subscriptionList);
13186
13183
  const newSubscriptionIds = [];
13187
13184
  const processedIds = /* @__PURE__ */ new Set();
13188
13185
  subscriptionList.forEach((subscriptionItem) => {
13189
13186
  const subscriptionId = generateListenerId(subscriptionItem);
13190
- this.logger.debug("subscriptionId:", subscriptionId);
13191
13187
  if (processedIds.has(subscriptionId)) {
13192
13188
  return;
13193
13189
  }
@@ -13195,9 +13191,6 @@ var MyxWebSocketClient = class {
13195
13191
  if (this.subscriptions.has(subscriptionId)) {
13196
13192
  const existingSubscription = this.subscriptions.get(subscriptionId);
13197
13193
  existingSubscription.callbacks.add(callback);
13198
- this.logger.debug(
13199
- `add callback to existing subscription: ${subscriptionId}`
13200
- );
13201
13194
  } else {
13202
13195
  const subscriptionObj = {
13203
13196
  id: subscriptionId,
@@ -13500,7 +13493,6 @@ var SubScription = class {
13500
13493
  * tickers subscription methods
13501
13494
  */
13502
13495
  subscribeTickers(globalIds, callback) {
13503
- this.logger.debug(`subscribe tickers ${globalIds}`);
13504
13496
  const globalIdsList = Array.isArray(globalIds) ? globalIds : [globalIds];
13505
13497
  this.wsClient.subscribe(
13506
13498
  globalIdsList.map((globalId) => ({
@@ -13511,7 +13503,6 @@ var SubScription = class {
13511
13503
  );
13512
13504
  }
13513
13505
  unsubscribeTickers(globalIds, callback) {
13514
- this.logger.debug(`unsubscribe tickers ${globalIds}`);
13515
13506
  const globalIdsList = Array.isArray(globalIds) ? globalIds : [globalIds];
13516
13507
  this.wsClient.unsubscribe(
13517
13508
  globalIdsList.map((globalId) => ({
@@ -14216,6 +14207,7 @@ var Order = class {
14216
14207
  params.executionFeeToken,
14217
14208
  params.collateralAmount
14218
14209
  );
14210
+ const totalCollateralAmount = BigInt(params.collateralAmount) + BigInt(tradingFee);
14219
14211
  const availableAccountMarginBalance = await this.account.getAvailableMarginBalance({ poolId: params.poolId, chainId: params.chainId, address: params.address });
14220
14212
  const needAmount = BigInt(tradingFee) + BigInt(params.collateralAmount) + totalNetWorkFee;
14221
14213
  let depositAmount = BigInt(0);
@@ -14234,7 +14226,7 @@ var Order = class {
14234
14226
  triggerType: params.triggerType,
14235
14227
  operation: OperationType.INCREASE,
14236
14228
  direction: params.direction,
14237
- collateralAmount: params.collateralAmount,
14229
+ collateralAmount: totalCollateralAmount.toString(),
14238
14230
  size: params.size,
14239
14231
  price: params.price,
14240
14232
  timeInForce: TIME_IN_FORCE,
@@ -21305,7 +21297,10 @@ var Seamless = class {
21305
21297
  }
21306
21298
  async getUSDPermitParams(deadline, chainId) {
21307
21299
  const config = this.configManager.getConfig();
21308
- const masterAddress = config.signer?.getAddress();
21300
+ if (!config.signer) {
21301
+ throw new MyxSDKError("INVALID_SIGNER" /* InvalidSigner */, "Signer is required for permit");
21302
+ }
21303
+ const masterAddress = await config.signer.getAddress();
21309
21304
  const brokerAddress = config.brokerAddress;
21310
21305
  const contractAddress = getContractAddressByChainId(chainId);
21311
21306
  const erc20Contract = new ethers9.Contract(
@@ -21313,17 +21308,16 @@ var Seamless = class {
21313
21308
  ERC20Token_default,
21314
21309
  config.signer
21315
21310
  );
21316
- const walletProvider = await getWalletProvider(chainId);
21317
21311
  try {
21318
21312
  const nonces = await erc20Contract.nonces(masterAddress);
21319
21313
  const brokerSignPermit = await signPermit(
21320
- // @ts-ignore
21321
- walletProvider,
21314
+ config.signer,
21315
+ // 使用 signer 而不是 provider
21322
21316
  erc20Contract,
21323
21317
  masterAddress,
21324
21318
  brokerAddress,
21325
- ethers9.MaxUint256,
21326
- nonces,
21319
+ ethers9.MaxUint256.toString(),
21320
+ nonces.toString(),
21327
21321
  deadline.toString(),
21328
21322
  chainId
21329
21323
  );
@@ -21337,10 +21331,8 @@ var Seamless = class {
21337
21331
  r: brokerSignPermit.r,
21338
21332
  s: brokerSignPermit.s
21339
21333
  };
21340
- console.log("brokerSeamlessUSDPermitParams-->", brokerSeamlessUSDPermitParams);
21341
21334
  return [brokerSeamlessUSDPermitParams];
21342
21335
  } catch (error) {
21343
- this.logger.error("getUSDPermitParams error-->", error);
21344
21336
  throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key generated");
21345
21337
  }
21346
21338
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.140",
3
+ "version": "0.1.142",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"