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