perp-cli 0.7.4 → 0.7.5

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.
Files changed (2) hide show
  1. package/dist/index.js +34 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ const _settings = loadSettings();
48
48
  const _defaultExchange = _settings.defaultExchange || "pacifica";
49
49
  program
50
50
  .name("perp")
51
- .description("Multi-DEX Perpetual Futures CLI (Pacifica, Hyperliquid, Lighter)")
51
+ .description("Multi-DEX Perpetual Futures CLI (Pacifica, Hyperliquid, Lighter, Aster)")
52
52
  .version(_pkg.version)
53
53
  .option("-e, --exchange <exchange>", `Exchange: pacifica, hyperliquid, lighter, aster (default: ${_defaultExchange})`, _defaultExchange)
54
54
  .option("-n, --network <network>", "Network: mainnet or testnet", "mainnet")
@@ -635,7 +635,7 @@ if (rawArgs.length === 0 || (!hasSubcommand && !rawArgs.includes("-h") && !rawAr
635
635
  chalk.cyan(" ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓"),
636
636
  chalk.cyan(" ┃") + chalk.white.bold(" perp-cli ") + chalk.gray(`v${_pkg.version}`) + " ".repeat(Math.max(0, 32 - _pkg.version.length)) + chalk.cyan("┃"),
637
637
  chalk.cyan(" ┃") + chalk.gray(" Multi-DEX Perpetual Futures ") + chalk.cyan("┃"),
638
- chalk.cyan(" ┃") + chalk.gray(" Pacifica · Hyperliquid · Lighter ") + chalk.cyan("┃"),
638
+ chalk.cyan(" ┃") + chalk.gray(" Pacifica · Hyperliquid · Lighter · Aster ") + chalk.cyan("┃"),
639
639
  chalk.cyan(" ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛"),
640
640
  ];
641
641
  console.log("\n" + banner.join("\n"));
@@ -660,7 +660,38 @@ if (rawArgs.length === 0 || (!hasSubcommand && !rawArgs.includes("-h") && !rawAr
660
660
  const adapter = await withTimeout(getAdapterForExchange(ex), 5000);
661
661
  const [balance, positions] = await withTimeout(Promise.all([adapter.getBalance(), adapter.getPositions()]), 5000);
662
662
  const posCount = positions.filter(p => Number(p.size) > 0).length;
663
- return { exchange: ex, ok: true, equity: Number(balance.equity), positions: posCount };
663
+ let spotValue = 0;
664
+ // Include non-USDC spot value for unified accounts (HL, LT)
665
+ try {
666
+ if (ex === "hyperliquid") {
667
+ const { HyperliquidSpotAdapter } = await import("./exchanges/hyperliquid-spot.js");
668
+ const hlSpot = new HyperliquidSpotAdapter(adapter);
669
+ await hlSpot.init();
670
+ const [raw, markets] = await Promise.all([hlSpot.getSpotBalances(), hlSpot.getSpotMarkets()]);
671
+ const priceMap = new Map(markets.map(m => [m.baseToken.toUpperCase(), Number(m.markPrice)]));
672
+ for (const b of raw) {
673
+ const base = b.token.replace(/-SPOT$/i, "").toUpperCase();
674
+ if (base === "USDC" || Number(b.total) <= 0)
675
+ continue;
676
+ spotValue += (priceMap.get(base) ?? 0) * Number(b.total);
677
+ }
678
+ }
679
+ else if (ex === "lighter") {
680
+ const { LighterAdapter } = await import("./exchanges/lighter.js");
681
+ const { LighterSpotAdapter } = await import("./exchanges/lighter-spot.js");
682
+ const ltSpot = new LighterSpotAdapter(adapter);
683
+ await ltSpot.init();
684
+ const [raw, markets] = await Promise.all([ltSpot.getSpotBalances(), ltSpot.getSpotMarkets()]);
685
+ const priceMap = new Map(markets.map(m => [m.baseToken.toUpperCase(), Number(m.markPrice)]));
686
+ for (const b of raw) {
687
+ if (b.token === "USDC" || b.token === "USDC_SPOT" || Number(b.total) <= 0)
688
+ continue;
689
+ spotValue += (priceMap.get(b.token.toUpperCase()) ?? 0) * Number(b.total);
690
+ }
691
+ }
692
+ }
693
+ catch { /* spot not available */ }
694
+ return { exchange: ex, ok: true, equity: Number(balance.equity) + spotValue, positions: posCount };
664
695
  }
665
696
  catch {
666
697
  return { exchange: ex, ok: false, equity: 0, positions: 0 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perp-cli",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "Multi-DEX Perpetual Futures CLI - Pacifica, Hyperliquid, Lighter",
5
5
  "bin": {
6
6
  "perp": "dist/index.js",