@t2000/cli 0.17.16 → 0.17.18

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
@@ -324,14 +324,7 @@ function registerBalance(program2) {
324
324
  printKeyValue("Total", `${formatUsd2(bal.total)}`);
325
325
  }
326
326
  if (bal.pendingRewards > 0) {
327
- try {
328
- const pending = await agent.getPendingRewards();
329
- if (pending.length > 0) {
330
- const tokens = [...new Set(pending.map((r) => r.symbol))].join(", ");
331
- printKeyValue("Rewards", `${pc3.yellow(tokens)} ${pc3.dim("(claimable \u2014 run claim-rewards)")}`);
332
- }
333
- } catch {
334
- }
327
+ printKeyValue("Rewards", `${pc3.yellow("claimable")} ${pc3.dim("(run claim-rewards)")}`);
335
328
  }
336
329
  if (limits) {
337
330
  printBlank();
@@ -753,13 +746,13 @@ function registerPositions(program2) {
753
746
  printJson(result);
754
747
  return;
755
748
  }
756
- let rewardsByProtocol = {};
749
+ let hasRewards = false;
750
+ const rewardsByKey = /* @__PURE__ */ new Map();
757
751
  try {
758
752
  const pending = await agent.getPendingRewards();
759
753
  for (const r of pending) {
760
- const key = r.protocol;
761
- if (!rewardsByProtocol[key]) rewardsByProtocol[key] = [];
762
- if (!rewardsByProtocol[key].includes(r.symbol)) rewardsByProtocol[key].push(r.symbol);
754
+ rewardsByKey.set(`${r.protocol}:${r.asset}`, true);
755
+ hasRewards = true;
763
756
  }
764
757
  } catch {
765
758
  }
@@ -773,16 +766,15 @@ function registerPositions(program2) {
773
766
  printLine(pc6.bold("Savings"));
774
767
  printDivider();
775
768
  for (const pos of saves) {
776
- const rewardTokens = rewardsByProtocol[pos.protocol];
777
- const rewardSuffix = rewardTokens ? ` ${pc6.yellow(`+${rewardTokens.join(", ")}`)}` : "";
778
- printKeyValue(pos.protocol, `${formatUsd8(pos.amount)} ${pos.asset} @ ${pos.apy.toFixed(2)}% APY${rewardSuffix}`);
769
+ const earning = rewardsByKey.has(`${pos.protocol}:${pos.asset}`) ? ` ${pc6.yellow("+rewards")}` : "";
770
+ printKeyValue(pos.protocol, `${formatUsd8(pos.amount)} ${pos.asset} @ ${pos.apy.toFixed(2)}% APY${earning}`);
779
771
  }
780
772
  const totalSaved = saves.reduce((s, p) => s + p.amount, 0);
781
773
  if (saves.length > 1) {
782
774
  printKeyValue("Total", formatUsd8(totalSaved));
783
775
  }
784
- if (Object.keys(rewardsByProtocol).length > 0) {
785
- printLine(` ${pc6.dim("Run claim-rewards to collect reward tokens")}`);
776
+ if (hasRewards) {
777
+ printLine(` ${pc6.dim("Run claim-rewards to collect and convert to USDC")}`);
786
778
  }
787
779
  printBlank();
788
780
  }
@@ -1898,7 +1890,7 @@ function registerMcp(program2) {
1898
1890
  mcp.command("start", { isDefault: true }).description("Start MCP server (stdio transport)").option("--key <path>", "Key file path").action(async (opts) => {
1899
1891
  let mod;
1900
1892
  try {
1901
- mod = await import("./dist-3TGAP6PT.js");
1893
+ mod = await import("./dist-F6YRISIO.js");
1902
1894
  } catch {
1903
1895
  console.error(
1904
1896
  "MCP server not installed. Run:\n npm install -g @t2000/mcp"
@@ -2533,7 +2525,7 @@ function registerInvest(program2) {
2533
2525
  // src/commands/portfolio.ts
2534
2526
  import pc14 from "picocolors";
2535
2527
  import { T2000 as T200025, formatUsd as formatUsd16, formatAssetAmount as formatAssetAmount2 } from "@t2000/sdk";
2536
- function printPositionLine(pos, rewardsByProtocol) {
2528
+ function printPositionLine(pos, rewardKeys) {
2537
2529
  if (pos.currentPrice === 0 && pos.totalAmount > 0) {
2538
2530
  printKeyValue(
2539
2531
  pos.asset,
@@ -2544,9 +2536,9 @@ function printPositionLine(pos, rewardsByProtocol) {
2544
2536
  const pnlSign = pos.unrealizedPnL >= 0 ? "+" : "";
2545
2537
  let yieldSuffix = "";
2546
2538
  if (pos.earning && pos.earningApy) {
2547
- const tokens = rewardsByProtocol?.[pos.earningProtocol ?? ""];
2548
- const rewardTag = tokens ? ` +${tokens.join(", ")}` : "";
2549
- yieldSuffix = ` ${pc14.cyan(`${pos.earningApy.toFixed(1)}% APY (${pos.earningProtocol})`)}${rewardTag ? pc14.yellow(rewardTag) : ""}`;
2539
+ const hasRewards = rewardKeys?.has(`${pos.earningProtocol}:${pos.asset}`);
2540
+ const rewardTag = hasRewards ? ` ${pc14.yellow("+rewards")}` : "";
2541
+ yieldSuffix = ` ${pc14.cyan(`${pos.earningApy.toFixed(1)}% APY (${pos.earningProtocol})`)}${rewardTag}`;
2550
2542
  }
2551
2543
  printKeyValue(
2552
2544
  pos.asset,
@@ -2564,14 +2556,10 @@ function registerPortfolio(program2) {
2564
2556
  printJson(portfolio);
2565
2557
  return;
2566
2558
  }
2567
- let rewardsByProtocol = {};
2559
+ const rewardKeys = /* @__PURE__ */ new Set();
2568
2560
  try {
2569
2561
  const pending = await agent.getPendingRewards();
2570
- for (const r of pending) {
2571
- const key = r.protocol;
2572
- if (!rewardsByProtocol[key]) rewardsByProtocol[key] = [];
2573
- if (!rewardsByProtocol[key].includes(r.symbol)) rewardsByProtocol[key].push(r.symbol);
2574
- }
2562
+ for (const r of pending) rewardKeys.add(`${r.protocol}:${r.asset}`);
2575
2563
  } catch {
2576
2564
  }
2577
2565
  printBlank();
@@ -2594,7 +2582,7 @@ function registerPortfolio(program2) {
2594
2582
  printLine(` ${pc14.bold(pc14.cyan(`\u25B8 ${stratLabel}`))}`);
2595
2583
  printSeparator();
2596
2584
  for (const pos of positions) {
2597
- printPositionLine(pos, rewardsByProtocol);
2585
+ printPositionLine(pos, rewardKeys);
2598
2586
  }
2599
2587
  const stratValue = positions.reduce((s, p) => s + p.currentValue, 0);
2600
2588
  printLine(` ${pc14.dim(`Subtotal: ${formatUsd16(stratValue)}`)}`);
@@ -2607,7 +2595,7 @@ function registerPortfolio(program2) {
2607
2595
  }
2608
2596
  printSeparator();
2609
2597
  for (const pos of portfolio.positions) {
2610
- printPositionLine(pos, rewardsByProtocol);
2598
+ printPositionLine(pos, rewardKeys);
2611
2599
  }
2612
2600
  if (hasStrategyPositions) {
2613
2601
  const directValue = portfolio.positions.reduce((s, p) => s + p.currentValue, 0);
@@ -2638,9 +2626,9 @@ function registerPortfolio(program2) {
2638
2626
 
2639
2627
  // src/commands/claimRewards.ts
2640
2628
  import pc15 from "picocolors";
2641
- import { T2000 as T200026 } from "@t2000/sdk";
2629
+ import { T2000 as T200026, formatUsd as formatUsd17 } from "@t2000/sdk";
2642
2630
  function registerClaimRewards(program2) {
2643
- program2.command("claim-rewards").description("Claim pending protocol rewards (vSUI, DEEP, SPRING_SUI)").option("--key <path>", "Key file path").action(async (opts) => {
2631
+ program2.command("claim-rewards").description("Claim pending protocol rewards").option("--key <path>", "Key file path").action(async (opts) => {
2644
2632
  try {
2645
2633
  const pin = await resolvePin();
2646
2634
  const agent = await T200026.create({ pin, keyPath: opts.key });
@@ -2655,15 +2643,13 @@ function registerClaimRewards(program2) {
2655
2643
  printBlank();
2656
2644
  return;
2657
2645
  }
2658
- printLine(` ${pc15.green("\u2713")} Claimed protocol rewards`);
2646
+ const protocols = [...new Set(result.rewards.map((r) => r.protocol))];
2647
+ printLine(` ${pc15.green("\u2713")} Claimed and converted rewards to USDC`);
2659
2648
  printSeparator();
2660
- for (const reward of result.rewards) {
2661
- printKeyValue(
2662
- `${reward.symbol}`,
2663
- `${pc15.dim(`from ${reward.protocol}`)}`
2664
- );
2649
+ if (result.usdcReceived > 0) {
2650
+ printKeyValue("Received", `${pc15.green(formatUsd17(result.usdcReceived))} USDC`);
2665
2651
  }
2666
- printSeparator();
2652
+ printKeyValue("Source", protocols.join(", "));
2667
2653
  if (result.tx) {
2668
2654
  printKeyValue("Tx", `https://suiscan.xyz/mainnet/tx/${result.tx}`);
2669
2655
  }