@myx-trade/sdk 0.1.23 → 0.1.24

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
@@ -1533,9 +1533,10 @@ declare class Account {
1533
1533
  message: string;
1534
1534
  data?: undefined;
1535
1535
  }>;
1536
- deposit({ poolId, amount }: {
1536
+ deposit({ poolId, amount, tokenAddress }: {
1537
1537
  poolId: string;
1538
1538
  amount: string;
1539
+ tokenAddress: string;
1539
1540
  }): Promise<{
1540
1541
  code: number;
1541
1542
  data: any;
package/dist/index.d.ts CHANGED
@@ -1533,9 +1533,10 @@ declare class Account {
1533
1533
  message: string;
1534
1534
  data?: undefined;
1535
1535
  }>;
1536
- deposit({ poolId, amount }: {
1536
+ deposit({ poolId, amount, tokenAddress }: {
1537
1537
  poolId: string;
1538
1538
  amount: string;
1539
+ tokenAddress: string;
1539
1540
  }): Promise<{
1540
1541
  code: number;
1541
1542
  data: any;
package/dist/index.js CHANGED
@@ -1827,7 +1827,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
1827
1827
  // package.json
1828
1828
  var package_default = {
1829
1829
  name: "@myx-trade/sdk",
1830
- version: "0.1.23",
1830
+ version: "0.1.24",
1831
1831
  private: false,
1832
1832
  publishConfig: {
1833
1833
  access: "public"
@@ -18169,9 +18169,9 @@ var Account = class {
18169
18169
  config.signer
18170
18170
  );
18171
18171
  try {
18172
- console.log("withdraw", config.signer?.getAddress() ?? "", poolId, amount);
18173
18172
  const account = await config.signer?.getAddress() ?? "";
18174
- const rs = await accountContract.withdraw(poolId, amount, account);
18173
+ console.log("withdraw", account, amount, poolId);
18174
+ const rs = await accountContract.withdraw(poolId, account, amount);
18175
18175
  const receipt = await rs?.wait(1);
18176
18176
  return {
18177
18177
  code: 0,
@@ -18184,7 +18184,7 @@ var Account = class {
18184
18184
  };
18185
18185
  }
18186
18186
  }
18187
- async deposit({ poolId, amount }) {
18187
+ async deposit({ poolId, amount, tokenAddress }) {
18188
18188
  const config = this.configManager.getConfig();
18189
18189
  const contractAddress = getContractAddressByChainId(config.chainId);
18190
18190
  const accountContract = new import_ethers27.ethers.Contract(
@@ -18193,6 +18193,21 @@ var Account = class {
18193
18193
  config.signer
18194
18194
  );
18195
18195
  try {
18196
+ const needApproval = await this.utils.needsApproval(
18197
+ tokenAddress,
18198
+ amount,
18199
+ contractAddress.Account
18200
+ );
18201
+ if (needApproval) {
18202
+ const approvalResult = await this.utils.approveAuthorization({
18203
+ quoteAddress: tokenAddress,
18204
+ amount,
18205
+ spenderAddress: contractAddress.Account
18206
+ });
18207
+ if (approvalResult.code !== 0) {
18208
+ throw new Error(approvalResult.message);
18209
+ }
18210
+ }
18196
18211
  const account = await config.signer?.getAddress() ?? "";
18197
18212
  console.log("deposit", account, poolId, amount);
18198
18213
  const rs = await accountContract.deposit(account, poolId, amount);
package/dist/index.mjs CHANGED
@@ -1742,7 +1742,7 @@ var RotationProvider = class extends BaseProvider {
1742
1742
  // package.json
1743
1743
  var package_default = {
1744
1744
  name: "@myx-trade/sdk",
1745
- version: "0.1.23",
1745
+ version: "0.1.24",
1746
1746
  private: false,
1747
1747
  publishConfig: {
1748
1748
  access: "public"
@@ -18084,9 +18084,9 @@ var Account = class {
18084
18084
  config.signer
18085
18085
  );
18086
18086
  try {
18087
- console.log("withdraw", config.signer?.getAddress() ?? "", poolId, amount);
18088
18087
  const account = await config.signer?.getAddress() ?? "";
18089
- const rs = await accountContract.withdraw(poolId, amount, account);
18088
+ console.log("withdraw", account, amount, poolId);
18089
+ const rs = await accountContract.withdraw(poolId, account, amount);
18090
18090
  const receipt = await rs?.wait(1);
18091
18091
  return {
18092
18092
  code: 0,
@@ -18099,7 +18099,7 @@ var Account = class {
18099
18099
  };
18100
18100
  }
18101
18101
  }
18102
- async deposit({ poolId, amount }) {
18102
+ async deposit({ poolId, amount, tokenAddress }) {
18103
18103
  const config = this.configManager.getConfig();
18104
18104
  const contractAddress = getContractAddressByChainId(config.chainId);
18105
18105
  const accountContract = new ethers8.Contract(
@@ -18108,6 +18108,21 @@ var Account = class {
18108
18108
  config.signer
18109
18109
  );
18110
18110
  try {
18111
+ const needApproval = await this.utils.needsApproval(
18112
+ tokenAddress,
18113
+ amount,
18114
+ contractAddress.Account
18115
+ );
18116
+ if (needApproval) {
18117
+ const approvalResult = await this.utils.approveAuthorization({
18118
+ quoteAddress: tokenAddress,
18119
+ amount,
18120
+ spenderAddress: contractAddress.Account
18121
+ });
18122
+ if (approvalResult.code !== 0) {
18123
+ throw new Error(approvalResult.message);
18124
+ }
18125
+ }
18111
18126
  const account = await config.signer?.getAddress() ?? "";
18112
18127
  console.log("deposit", account, poolId, amount);
18113
18128
  const rs = await accountContract.deposit(account, poolId, amount);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myx-trade/sdk",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"