@t2000/sdk 0.18.5 → 0.18.6

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
@@ -4846,7 +4846,7 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
4846
4846
  });
4847
4847
  const walletAmount = Number(assetBalance.totalBalance) / 10 ** assetInfo.decimals;
4848
4848
  const gasReserve = params.asset === "SUI" ? GAS_RESERVE_MIN : 0;
4849
- const depositAmount = Math.max(0, walletAmount - gasReserve);
4849
+ const depositAmount = Math.min(pos.totalAmount, Math.max(0, walletAmount - gasReserve));
4850
4850
  if (pos.earning && depositAmount <= 0) {
4851
4851
  return {
4852
4852
  success: true,
@@ -5767,7 +5767,12 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
5767
5767
  }
5768
5768
  }
5769
5769
  }
5770
- const bestRate = allRates.reduce(
5770
+ const stableSet = new Set(STABLE_ASSETS);
5771
+ const stableRates = allRates.filter((r) => stableSet.has(r.asset));
5772
+ if (stableRates.length === 0) {
5773
+ throw new T2000Error("PROTOCOL_UNAVAILABLE", "No stablecoin lending rates available for rebalance");
5774
+ }
5775
+ const bestRate = stableRates.reduce(
5771
5776
  (best, r) => r.rates.saveApy > best.rates.saveApy ? r : best
5772
5777
  );
5773
5778
  const current = savePositions.reduce(