@myx-trade/sdk 0.1.221 → 0.1.224

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
@@ -1648,7 +1648,7 @@ declare class Account {
1648
1648
  message: string;
1649
1649
  data?: undefined;
1650
1650
  }>;
1651
- setUserFeeData(address: string, deadline: number, params: {
1651
+ setUserFeeData(address: string, chainId: number, deadline: number, params: {
1652
1652
  tier: number;
1653
1653
  referrer: string;
1654
1654
  totalReferralRebatePct: number;
@@ -3339,7 +3339,7 @@ declare class BaseMyxClient {
3339
3339
 
3340
3340
  declare class Referrals extends BaseMyxClient {
3341
3341
  constructor(client: MyxClient);
3342
- claimRebate(): Promise<ethers.ContractTransactionReceipt | null>;
3342
+ claimRebate(tokenAddress: Address$2): Promise<ethers.ContractTransactionReceipt | null>;
3343
3343
  }
3344
3344
 
3345
3345
  declare class MyxClient {
package/dist/index.d.ts CHANGED
@@ -1648,7 +1648,7 @@ declare class Account {
1648
1648
  message: string;
1649
1649
  data?: undefined;
1650
1650
  }>;
1651
- setUserFeeData(address: string, deadline: number, params: {
1651
+ setUserFeeData(address: string, chainId: number, deadline: number, params: {
1652
1652
  tier: number;
1653
1653
  referrer: string;
1654
1654
  totalReferralRebatePct: number;
@@ -3339,7 +3339,7 @@ declare class BaseMyxClient {
3339
3339
 
3340
3340
  declare class Referrals extends BaseMyxClient {
3341
3341
  constructor(client: MyxClient);
3342
- claimRebate(): Promise<ethers.ContractTransactionReceipt | null>;
3342
+ claimRebate(tokenAddress: Address$2): Promise<ethers.ContractTransactionReceipt | null>;
3343
3343
  }
3344
3344
 
3345
3345
  declare class MyxClient {
package/dist/index.js CHANGED
@@ -1807,7 +1807,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
1807
1807
  // package.json
1808
1808
  var package_default = {
1809
1809
  name: "@myx-trade/sdk",
1810
- version: "0.1.221",
1810
+ version: "0.1.224",
1811
1811
  private: false,
1812
1812
  publishConfig: {
1813
1813
  access: "public"
@@ -21389,20 +21389,10 @@ var Account = class {
21389
21389
  };
21390
21390
  }
21391
21391
  }
21392
- async setUserFeeData(address, deadline, params, signature) {
21392
+ async setUserFeeData(address, chainId, deadline, params, signature) {
21393
21393
  const config = this.configManager.getConfig();
21394
- const brokerContract = new import_ethers26.ethers.Contract(
21395
- config.brokerAddress,
21396
- Broker_default,
21397
- config.signer
21398
- );
21399
- const nonce = await brokerContract.userNonces(address);
21400
- if (parseInt(nonce.toString()) + 1 !== parseInt(params.nonce.toString())) {
21401
- throw new MyxSDKError(
21402
- "REQUEST_FAILED" /* RequestFailed */,
21403
- "Invalid nonce, please try again"
21404
- );
21405
- }
21394
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
21395
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
21406
21396
  if (deadline < (0, import_dayjs3.default)().unix()) {
21407
21397
  throw new MyxSDKError(
21408
21398
  "REQUEST_FAILED" /* RequestFailed */,
@@ -21422,12 +21412,53 @@ var Account = class {
21422
21412
  signature
21423
21413
  };
21424
21414
  try {
21425
- const rs = await brokerContract.setUserFeeData(feeData);
21426
- const receipt = await rs?.wait(1);
21427
- return {
21428
- code: 0,
21429
- data: receipt
21430
- };
21415
+ if (config.seamlessMode && authorized && seamlessWallet) {
21416
+ const isEnoughGas = await this.utils.checkSeamlessGas(address);
21417
+ if (!isEnoughGas) {
21418
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
21419
+ }
21420
+ const forwarderContract = await getForwarderContract(chainId);
21421
+ const accountContract = new import_ethers26.ethers.Contract(
21422
+ config.brokerAddress,
21423
+ Account_default,
21424
+ seamlessWallet
21425
+ );
21426
+ const functionHash = accountContract.interface.encodeFunctionData("setUserFeeData", [feeData]);
21427
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
21428
+ const forwardTxParams = {
21429
+ from: seamlessWallet.address ?? "",
21430
+ to: config.brokerAddress,
21431
+ value: "0",
21432
+ gas: "350000",
21433
+ deadline: (0, import_dayjs3.default)().add(60, "minute").unix(),
21434
+ data: functionHash,
21435
+ nonce: nonce.toString()
21436
+ };
21437
+ const rs = await this.client.seamless.forwarderTx(forwardTxParams, chainId, seamlessWallet);
21438
+ return {
21439
+ code: 0,
21440
+ data: rs
21441
+ };
21442
+ } else {
21443
+ const brokerContract = new import_ethers26.ethers.Contract(
21444
+ config.brokerAddress,
21445
+ Broker_default,
21446
+ config.signer
21447
+ );
21448
+ const nonce = await brokerContract.userNonces(address);
21449
+ if (parseInt(nonce.toString()) + 1 !== parseInt(params.nonce.toString())) {
21450
+ throw new MyxSDKError(
21451
+ "REQUEST_FAILED" /* RequestFailed */,
21452
+ "Invalid nonce, please try again"
21453
+ );
21454
+ }
21455
+ const rs = await brokerContract.setUserFeeData(feeData);
21456
+ const receipt = await rs?.wait(1);
21457
+ return {
21458
+ code: 0,
21459
+ data: receipt
21460
+ };
21461
+ }
21431
21462
  } catch (error) {
21432
21463
  return {
21433
21464
  code: -1,
@@ -22161,12 +22192,11 @@ var Referrals = class extends BaseMyxClient {
22161
22192
  constructor(client2) {
22162
22193
  super(client2);
22163
22194
  }
22164
- async claimRebate() {
22165
- const usdcAddress = this.getAddressConfig().USDC;
22195
+ async claimRebate(tokenAddress) {
22166
22196
  const brokerContract = await this.connectContract(
22167
22197
  await this.getBrokerContract()
22168
22198
  );
22169
- const tx = await brokerContract.claimRebate(usdcAddress);
22199
+ const tx = await brokerContract.claimRebate(tokenAddress);
22170
22200
  const receipt = await tx.wait();
22171
22201
  return receipt;
22172
22202
  }
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.221",
1734
+ version: "0.1.224",
1735
1735
  private: false,
1736
1736
  publishConfig: {
1737
1737
  access: "public"
@@ -21313,20 +21313,10 @@ var Account = class {
21313
21313
  };
21314
21314
  }
21315
21315
  }
21316
- async setUserFeeData(address, deadline, params, signature) {
21316
+ async setUserFeeData(address, chainId, deadline, params, signature) {
21317
21317
  const config = this.configManager.getConfig();
21318
- const brokerContract = new ethers8.Contract(
21319
- config.brokerAddress,
21320
- Broker_default,
21321
- config.signer
21322
- );
21323
- const nonce = await brokerContract.userNonces(address);
21324
- if (parseInt(nonce.toString()) + 1 !== parseInt(params.nonce.toString())) {
21325
- throw new MyxSDKError(
21326
- "REQUEST_FAILED" /* RequestFailed */,
21327
- "Invalid nonce, please try again"
21328
- );
21329
- }
21318
+ const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
21319
+ const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
21330
21320
  if (deadline < dayjs3().unix()) {
21331
21321
  throw new MyxSDKError(
21332
21322
  "REQUEST_FAILED" /* RequestFailed */,
@@ -21346,12 +21336,53 @@ var Account = class {
21346
21336
  signature
21347
21337
  };
21348
21338
  try {
21349
- const rs = await brokerContract.setUserFeeData(feeData);
21350
- const receipt = await rs?.wait(1);
21351
- return {
21352
- code: 0,
21353
- data: receipt
21354
- };
21339
+ if (config.seamlessMode && authorized && seamlessWallet) {
21340
+ const isEnoughGas = await this.utils.checkSeamlessGas(address);
21341
+ if (!isEnoughGas) {
21342
+ throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
21343
+ }
21344
+ const forwarderContract = await getForwarderContract(chainId);
21345
+ const accountContract = new ethers8.Contract(
21346
+ config.brokerAddress,
21347
+ Account_default,
21348
+ seamlessWallet
21349
+ );
21350
+ const functionHash = accountContract.interface.encodeFunctionData("setUserFeeData", [feeData]);
21351
+ const nonce = await forwarderContract.nonces(seamlessWallet.address);
21352
+ const forwardTxParams = {
21353
+ from: seamlessWallet.address ?? "",
21354
+ to: config.brokerAddress,
21355
+ value: "0",
21356
+ gas: "350000",
21357
+ deadline: dayjs3().add(60, "minute").unix(),
21358
+ data: functionHash,
21359
+ nonce: nonce.toString()
21360
+ };
21361
+ const rs = await this.client.seamless.forwarderTx(forwardTxParams, chainId, seamlessWallet);
21362
+ return {
21363
+ code: 0,
21364
+ data: rs
21365
+ };
21366
+ } else {
21367
+ const brokerContract = new ethers8.Contract(
21368
+ config.brokerAddress,
21369
+ Broker_default,
21370
+ config.signer
21371
+ );
21372
+ const nonce = await brokerContract.userNonces(address);
21373
+ if (parseInt(nonce.toString()) + 1 !== parseInt(params.nonce.toString())) {
21374
+ throw new MyxSDKError(
21375
+ "REQUEST_FAILED" /* RequestFailed */,
21376
+ "Invalid nonce, please try again"
21377
+ );
21378
+ }
21379
+ const rs = await brokerContract.setUserFeeData(feeData);
21380
+ const receipt = await rs?.wait(1);
21381
+ return {
21382
+ code: 0,
21383
+ data: receipt
21384
+ };
21385
+ }
21355
21386
  } catch (error) {
21356
21387
  return {
21357
21388
  code: -1,
@@ -22085,12 +22116,11 @@ var Referrals = class extends BaseMyxClient {
22085
22116
  constructor(client2) {
22086
22117
  super(client2);
22087
22118
  }
22088
- async claimRebate() {
22089
- const usdcAddress = this.getAddressConfig().USDC;
22119
+ async claimRebate(tokenAddress) {
22090
22120
  const brokerContract = await this.connectContract(
22091
22121
  await this.getBrokerContract()
22092
22122
  );
22093
- const tx = await brokerContract.claimRebate(usdcAddress);
22123
+ const tx = await brokerContract.claimRebate(tokenAddress);
22094
22124
  const receipt = await tx.wait();
22095
22125
  return receipt;
22096
22126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.221",
3
+ "version": "0.1.224",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"