@t2000/cli 0.17.14 → 0.17.16

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
@@ -323,6 +323,16 @@ function registerBalance(program2) {
323
323
  printSeparator();
324
324
  printKeyValue("Total", `${formatUsd2(bal.total)}`);
325
325
  }
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
+ }
335
+ }
326
336
  if (limits) {
327
337
  printBlank();
328
338
  printHeader("Limits");
@@ -743,6 +753,16 @@ function registerPositions(program2) {
743
753
  printJson(result);
744
754
  return;
745
755
  }
756
+ let rewardsByProtocol = {};
757
+ try {
758
+ const pending = await agent.getPendingRewards();
759
+ 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);
763
+ }
764
+ } catch {
765
+ }
746
766
  printBlank();
747
767
  if (result.positions.length === 0) {
748
768
  printInfo("No positions. Use `t2000 save <amount>` to start earning.");
@@ -753,12 +773,17 @@ function registerPositions(program2) {
753
773
  printLine(pc6.bold("Savings"));
754
774
  printDivider();
755
775
  for (const pos of saves) {
756
- printKeyValue(pos.protocol, `${formatUsd8(pos.amount)} ${pos.asset} @ ${pos.apy.toFixed(2)}% APY`);
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}`);
757
779
  }
758
780
  const totalSaved = saves.reduce((s, p) => s + p.amount, 0);
759
781
  if (saves.length > 1) {
760
782
  printKeyValue("Total", formatUsd8(totalSaved));
761
783
  }
784
+ if (Object.keys(rewardsByProtocol).length > 0) {
785
+ printLine(` ${pc6.dim("Run claim-rewards to collect reward tokens")}`);
786
+ }
762
787
  printBlank();
763
788
  }
764
789
  if (borrows.length > 0) {
@@ -1391,8 +1416,8 @@ function registerLock(program2) {
1391
1416
  if (!pin) {
1392
1417
  throw new Error("PIN required to unlock agent");
1393
1418
  }
1394
- const { T2000: T200026 } = await import("@t2000/sdk");
1395
- await T200026.create({ pin });
1419
+ const { T2000: T200027 } = await import("@t2000/sdk");
1420
+ await T200027.create({ pin });
1396
1421
  const enforcer = new SafeguardEnforcer2(CONFIG_DIR3);
1397
1422
  enforcer.load();
1398
1423
  enforcer.unlock();
@@ -1873,7 +1898,7 @@ function registerMcp(program2) {
1873
1898
  mcp.command("start", { isDefault: true }).description("Start MCP server (stdio transport)").option("--key <path>", "Key file path").action(async (opts) => {
1874
1899
  let mod;
1875
1900
  try {
1876
- mod = await import("./dist-S4OOC4XZ.js");
1901
+ mod = await import("./dist-3TGAP6PT.js");
1877
1902
  } catch {
1878
1903
  console.error(
1879
1904
  "MCP server not installed. Run:\n npm install -g @t2000/mcp"
@@ -2508,7 +2533,7 @@ function registerInvest(program2) {
2508
2533
  // src/commands/portfolio.ts
2509
2534
  import pc14 from "picocolors";
2510
2535
  import { T2000 as T200025, formatUsd as formatUsd16, formatAssetAmount as formatAssetAmount2 } from "@t2000/sdk";
2511
- function printPositionLine(pos) {
2536
+ function printPositionLine(pos, rewardsByProtocol) {
2512
2537
  if (pos.currentPrice === 0 && pos.totalAmount > 0) {
2513
2538
  printKeyValue(
2514
2539
  pos.asset,
@@ -2517,7 +2542,12 @@ function printPositionLine(pos) {
2517
2542
  } else {
2518
2543
  const pnlColor = pos.unrealizedPnL >= 0 ? pc14.green : pc14.red;
2519
2544
  const pnlSign = pos.unrealizedPnL >= 0 ? "+" : "";
2520
- const yieldSuffix = pos.earning && pos.earningApy ? ` ${pc14.cyan(`${pos.earningApy.toFixed(1)}% APY (${pos.earningProtocol})`)}` : "";
2545
+ let yieldSuffix = "";
2546
+ 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) : ""}`;
2550
+ }
2521
2551
  printKeyValue(
2522
2552
  pos.asset,
2523
2553
  `${formatAssetAmount2(pos.totalAmount, pos.asset)} Avg: ${formatUsd16(pos.avgPrice)} Now: ${formatUsd16(pos.currentPrice)} ${pnlColor(`${pnlSign}${formatUsd16(pos.unrealizedPnL)} (${pnlSign}${pos.unrealizedPnLPct.toFixed(1)}%)`)}${yieldSuffix}`
@@ -2534,6 +2564,16 @@ function registerPortfolio(program2) {
2534
2564
  printJson(portfolio);
2535
2565
  return;
2536
2566
  }
2567
+ let rewardsByProtocol = {};
2568
+ try {
2569
+ 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
+ }
2575
+ } catch {
2576
+ }
2537
2577
  printBlank();
2538
2578
  const hasDirectPositions = portfolio.positions.length > 0;
2539
2579
  const hasStrategyPositions = portfolio.strategyPositions && Object.keys(portfolio.strategyPositions).length > 0;
@@ -2554,7 +2594,7 @@ function registerPortfolio(program2) {
2554
2594
  printLine(` ${pc14.bold(pc14.cyan(`\u25B8 ${stratLabel}`))}`);
2555
2595
  printSeparator();
2556
2596
  for (const pos of positions) {
2557
- printPositionLine(pos);
2597
+ printPositionLine(pos, rewardsByProtocol);
2558
2598
  }
2559
2599
  const stratValue = positions.reduce((s, p) => s + p.currentValue, 0);
2560
2600
  printLine(` ${pc14.dim(`Subtotal: ${formatUsd16(stratValue)}`)}`);
@@ -2567,7 +2607,7 @@ function registerPortfolio(program2) {
2567
2607
  }
2568
2608
  printSeparator();
2569
2609
  for (const pos of portfolio.positions) {
2570
- printPositionLine(pos);
2610
+ printPositionLine(pos, rewardsByProtocol);
2571
2611
  }
2572
2612
  if (hasStrategyPositions) {
2573
2613
  const directValue = portfolio.positions.reduce((s, p) => s + p.currentValue, 0);
@@ -2596,6 +2636,44 @@ function registerPortfolio(program2) {
2596
2636
  });
2597
2637
  }
2598
2638
 
2639
+ // src/commands/claimRewards.ts
2640
+ import pc15 from "picocolors";
2641
+ import { T2000 as T200026 } from "@t2000/sdk";
2642
+ 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) => {
2644
+ try {
2645
+ const pin = await resolvePin();
2646
+ const agent = await T200026.create({ pin, keyPath: opts.key });
2647
+ const result = await agent.claimRewards();
2648
+ if (isJsonMode()) {
2649
+ printJson(result);
2650
+ return;
2651
+ }
2652
+ printBlank();
2653
+ if (result.rewards.length === 0) {
2654
+ printLine(` ${pc15.dim("No rewards to claim")}`);
2655
+ printBlank();
2656
+ return;
2657
+ }
2658
+ printLine(` ${pc15.green("\u2713")} Claimed protocol rewards`);
2659
+ printSeparator();
2660
+ for (const reward of result.rewards) {
2661
+ printKeyValue(
2662
+ `${reward.symbol}`,
2663
+ `${pc15.dim(`from ${reward.protocol}`)}`
2664
+ );
2665
+ }
2666
+ printSeparator();
2667
+ if (result.tx) {
2668
+ printKeyValue("Tx", `https://suiscan.xyz/mainnet/tx/${result.tx}`);
2669
+ }
2670
+ printBlank();
2671
+ } catch (error) {
2672
+ handleError(error);
2673
+ }
2674
+ });
2675
+ }
2676
+
2599
2677
  // src/program.ts
2600
2678
  var require2 = createRequire(import.meta.url);
2601
2679
  var { version: CLI_VERSION } = require2("../package.json");
@@ -2634,6 +2712,7 @@ function createProgram() {
2634
2712
  registerContacts(program2);
2635
2713
  registerInvest(program2);
2636
2714
  registerPortfolio(program2);
2715
+ registerClaimRewards(program2);
2637
2716
  return program2;
2638
2717
  }
2639
2718