@t2000/sdk 0.18.35 → 0.18.36

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
@@ -57988,6 +57988,13 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
57988
57988
  throw new T2000Error("ASSET_NOT_SUPPORTED", `${params.asset} is not available for investment`);
57989
57989
  }
57990
57990
  const bal = await queryBalance(this.client, this._address);
57991
+ const totalFunds = bal.available + bal.savings;
57992
+ if (params.usdAmount > totalFunds * 1.05) {
57993
+ throw new T2000Error(
57994
+ "INSUFFICIENT_BALANCE",
57995
+ `Insufficient funds. You have $${totalFunds.toFixed(2)} total (checking: $${bal.available.toFixed(2)}, savings: $${bal.savings.toFixed(2)}) but need $${params.usdAmount.toFixed(2)}.`
57996
+ );
57997
+ }
57991
57998
  if (bal.available < params.usdAmount) {
57992
57999
  await this._autoFundFromSavings(params.usdAmount - bal.available);
57993
58000
  }
@@ -58433,6 +58440,13 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
58433
58440
  }
58434
58441
  this.enforcer.check({ operation: "invest", amount: params.usdAmount });
58435
58442
  const bal = await queryBalance(this.client, this._address);
58443
+ const totalFunds = bal.available + bal.savings;
58444
+ if (params.usdAmount > totalFunds * 1.05) {
58445
+ throw new T2000Error(
58446
+ "INSUFFICIENT_BALANCE",
58447
+ `Insufficient funds. You have $${totalFunds.toFixed(2)} total (checking: $${bal.available.toFixed(2)}, savings: $${bal.savings.toFixed(2)}) but need $${params.usdAmount.toFixed(2)}.`
58448
+ );
58449
+ }
58436
58450
  if (bal.available < params.usdAmount && !params.dryRun) {
58437
58451
  await this._autoFundFromSavings(params.usdAmount - bal.available);
58438
58452
  }