@t2000/sdk 0.17.1 → 0.17.2

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.js CHANGED
@@ -4437,10 +4437,6 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
4437
4437
  if (!pos || pos.totalAmount <= 0) {
4438
4438
  throw new T2000Error("INSUFFICIENT_INVESTMENT", `No ${params.asset} position to earn on`);
4439
4439
  }
4440
- if (pos.earning) {
4441
- throw new T2000Error("INVEST_ALREADY_EARNING", `${params.asset} is already earning via ${pos.earningProtocol}`);
4442
- }
4443
- const { adapter, rate } = await this.registry.bestSaveRate(params.asset);
4444
4440
  const assetInfo = SUPPORTED_ASSETS[params.asset];
4445
4441
  const assetBalance = await this.client.getBalance({
4446
4442
  owner: this._address,
@@ -4449,9 +4445,13 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
4449
4445
  const walletAmount = Number(assetBalance.totalBalance) / 10 ** assetInfo.decimals;
4450
4446
  const gasReserve = params.asset === "SUI" ? GAS_RESERVE_MIN : 0;
4451
4447
  const depositAmount = Math.max(0, walletAmount - gasReserve);
4448
+ if (pos.earning && depositAmount <= 0) {
4449
+ throw new T2000Error("INVEST_ALREADY_EARNING", `${params.asset} is already earning via ${pos.earningProtocol}`);
4450
+ }
4452
4451
  if (depositAmount <= 0) {
4453
4452
  throw new T2000Error("INSUFFICIENT_BALANCE", `No ${params.asset} available to deposit (wallet: ${walletAmount}, gas reserve: ${gasReserve})`);
4454
4453
  }
4454
+ const { adapter, rate } = await this.registry.bestSaveRate(params.asset);
4455
4455
  const gasResult = await executeWithGas(this.client, this.keypair, async () => {
4456
4456
  const { tx } = await adapter.buildSaveTx(this._address, depositAmount, params.asset);
4457
4457
  return tx;