@t2000/sdk 0.16.12 → 0.16.14

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
@@ -3400,16 +3400,24 @@ To access invested funds: t2000 invest sell ${params.amount} ${asset}`,
3400
3400
  const suiPrice = bal.gasReserve.sui > 0 ? bal.gasReserve.usdEquiv / bal.gasReserve.sui : 0;
3401
3401
  const assetPrices = { SUI: suiPrice };
3402
3402
  const swapAdapter = this.registry.listSwap()[0];
3403
+ const investedAssets = /* @__PURE__ */ new Set();
3403
3404
  for (const pos of portfolioPositions) {
3404
- if (pos.asset !== "SUI" && pos.asset in INVESTMENT_ASSETS && !(pos.asset in assetPrices)) {
3405
- try {
3406
- if (swapAdapter) {
3407
- const quote = await swapAdapter.getQuote("USDC", pos.asset, 1);
3408
- assetPrices[pos.asset] = quote.expectedOutput > 0 ? 1 / quote.expectedOutput : 0;
3409
- }
3410
- } catch {
3411
- assetPrices[pos.asset] = 0;
3405
+ if (pos.asset in INVESTMENT_ASSETS) investedAssets.add(pos.asset);
3406
+ }
3407
+ for (const key of this.portfolio.getAllStrategyKeys()) {
3408
+ for (const sp of this.portfolio.getStrategyPositions(key)) {
3409
+ if (sp.asset in INVESTMENT_ASSETS) investedAssets.add(sp.asset);
3410
+ }
3411
+ }
3412
+ for (const asset of investedAssets) {
3413
+ if (asset === "SUI" || asset in assetPrices) continue;
3414
+ try {
3415
+ if (swapAdapter) {
3416
+ const quote = await swapAdapter.getQuote("USDC", asset, 1);
3417
+ assetPrices[asset] = quote.expectedOutput > 0 ? 1 / quote.expectedOutput : 0;
3412
3418
  }
3419
+ } catch {
3420
+ assetPrices[asset] = 0;
3413
3421
  }
3414
3422
  }
3415
3423
  let investmentValue = 0;
@@ -3439,21 +3447,15 @@ To access invested funds: t2000 invest sell ${params.amount} ${asset}`,
3439
3447
  investmentCostBasis += pos.costBasis;
3440
3448
  }
3441
3449
  }
3442
- let strategySuiTotal = 0;
3443
3450
  for (const key of this.portfolio.getAllStrategyKeys()) {
3444
3451
  for (const sp of this.portfolio.getStrategyPositions(key)) {
3445
3452
  if (!(sp.asset in INVESTMENT_ASSETS)) continue;
3453
+ if (sp.asset === "SUI") continue;
3446
3454
  const price = assetPrices[sp.asset] ?? 0;
3447
3455
  investmentValue += sp.totalAmount * price;
3448
3456
  investmentCostBasis += sp.costBasis;
3449
- if (sp.asset === "SUI") strategySuiTotal += sp.totalAmount;
3450
3457
  }
3451
3458
  }
3452
- if (strategySuiTotal > 0) {
3453
- const suiPrice2 = assetPrices["SUI"] ?? 0;
3454
- const gasSui = Math.max(0, bal.gasReserve.sui - strategySuiTotal);
3455
- bal.gasReserve = { sui: gasSui, usdEquiv: gasSui * suiPrice2 };
3456
- }
3457
3459
  bal.investment = investmentValue;
3458
3460
  bal.investmentPnL = investmentValue - investmentCostBasis;
3459
3461
  } catch {