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