@myx-trade/sdk 0.1.23 → 0.1.25

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.25",
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,8 +18184,10 @@ 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
+ const account = await config.signer?.getAddress() ?? "";
18190
+ console.log("deposit", account, poolId, amount);
18189
18191
  const contractAddress = getContractAddressByChainId(config.chainId);
18190
18192
  const accountContract = new import_ethers27.ethers.Contract(
18191
18193
  contractAddress.Account,
@@ -18193,8 +18195,21 @@ var Account = class {
18193
18195
  config.signer
18194
18196
  );
18195
18197
  try {
18196
- const account = await config.signer?.getAddress() ?? "";
18197
- console.log("deposit", account, poolId, amount);
18198
+ const needApproval = await this.utils.needsApproval(
18199
+ tokenAddress,
18200
+ amount,
18201
+ contractAddress.Account
18202
+ );
18203
+ if (needApproval) {
18204
+ const approvalResult = await this.utils.approveAuthorization({
18205
+ quoteAddress: tokenAddress,
18206
+ amount: import_ethers27.ethers.MaxUint256.toString(),
18207
+ spenderAddress: contractAddress.Account
18208
+ });
18209
+ if (approvalResult.code !== 0) {
18210
+ throw new Error(approvalResult.message);
18211
+ }
18212
+ }
18198
18213
  const rs = await accountContract.deposit(account, poolId, amount);
18199
18214
  const receipt = await rs?.wait(1);
18200
18215
  return {
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.25",
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,8 +18099,10 @@ 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
+ const account = await config.signer?.getAddress() ?? "";
18105
+ console.log("deposit", account, poolId, amount);
18104
18106
  const contractAddress = getContractAddressByChainId(config.chainId);
18105
18107
  const accountContract = new ethers8.Contract(
18106
18108
  contractAddress.Account,
@@ -18108,8 +18110,21 @@ var Account = class {
18108
18110
  config.signer
18109
18111
  );
18110
18112
  try {
18111
- const account = await config.signer?.getAddress() ?? "";
18112
- console.log("deposit", account, poolId, amount);
18113
+ const needApproval = await this.utils.needsApproval(
18114
+ tokenAddress,
18115
+ amount,
18116
+ contractAddress.Account
18117
+ );
18118
+ if (needApproval) {
18119
+ const approvalResult = await this.utils.approveAuthorization({
18120
+ quoteAddress: tokenAddress,
18121
+ amount: ethers8.MaxUint256.toString(),
18122
+ spenderAddress: contractAddress.Account
18123
+ });
18124
+ if (approvalResult.code !== 0) {
18125
+ throw new Error(approvalResult.message);
18126
+ }
18127
+ }
18113
18128
  const rs = await accountContract.deposit(account, poolId, amount);
18114
18129
  const receipt = await rs?.wait(1);
18115
18130
  return {
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.25",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"