perp-cli 0.6.3 → 0.6.4

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.
@@ -965,12 +965,28 @@ export function registerAccountCommands(program, getAdapter, isJson, getAdapterF
965
965
  "",
966
966
  ]);
967
967
  console.log(makeTable(["Exchange", "Equity", "Available", "Margin Used", "uPnL", "Status"], balRows));
968
- // ── Positions ──
968
+ // ── Positions + Funding ──
969
+ // Fetch funding per exchange in parallel
970
+ const fundingByExSym = new Map();
971
+ await Promise.allSettled(exchanges.map(async (exName) => {
972
+ try {
973
+ const adapter = await getAdapterForExchange(exName);
974
+ const payments = await adapter.getFundingPayments(200);
975
+ for (const p of payments) {
976
+ const sym = p.symbol.replace("-PERP", "").toUpperCase();
977
+ const key = `${exName}:${sym}`;
978
+ fundingByExSym.set(key, (fundingByExSym.get(key) ?? 0) + Number(p.payment));
979
+ }
980
+ }
981
+ catch { /* skip */ }
982
+ }));
969
983
  if (summary.positions.length > 0) {
970
984
  console.log(chalk.white.bold("\n Open Positions"));
971
985
  const posRows = summary.positions.map(p => {
972
986
  const sideColor = p.side === "long" ? chalk.green : chalk.red;
973
987
  const notional = Math.abs(Number(p.size) * Number(p.markPrice));
988
+ const sym = p.symbol.replace("-PERP", "").toUpperCase();
989
+ const funding = fundingByExSym.get(`${p.exchange}:${sym}`) ?? 0;
974
990
  return [
975
991
  chalk.white.bold(p.symbol),
976
992
  chalk.gray(p.exchange),
@@ -979,17 +995,19 @@ export function registerAccountCommands(program, getAdapter, isJson, getAdapterF
979
995
  `$${formatUsd(p.entryPrice)}`,
980
996
  `$${formatUsd(p.markPrice)}`,
981
997
  formatPnl(p.unrealizedPnl),
998
+ formatPnl(funding),
982
999
  `$${formatUsd(notional)}`,
983
1000
  `${p.leverage}x`,
984
1001
  ];
985
1002
  });
986
- console.log(makeTable(["Symbol", "Exchange", "Side", "Size", "Entry", "Mark", "uPnL", "Notional", "Lev"], posRows));
1003
+ console.log(makeTable(["Symbol", "Exchange", "Side", "Size", "Entry", "Mark", "uPnL", "Funding", "Notional", "Lev"], posRows));
987
1004
  }
988
1005
  else {
989
1006
  console.log(chalk.gray("\n No open positions.\n"));
990
1007
  }
991
1008
  // ── Spot Holdings ──
992
1009
  const spotRows = [];
1010
+ let totalSpotValue = 0;
993
1011
  for (const exName of exchanges) {
994
1012
  try {
995
1013
  const adapter = await getAdapterForExchange(exName);
@@ -1008,6 +1026,7 @@ export function registerAccountCommands(program, getAdapter, isJson, getAdapterF
1008
1026
  const value = price * Number(b.total);
1009
1027
  if (value < 1)
1010
1028
  continue; // skip dust
1029
+ totalSpotValue += value;
1011
1030
  spotRows.push([
1012
1031
  chalk.white.bold(base),
1013
1032
  chalk.gray("hyperliquid"),
@@ -1032,6 +1051,7 @@ export function registerAccountCommands(program, getAdapter, isJson, getAdapterF
1032
1051
  const value = price * Number(b.total);
1033
1052
  if (value < 1)
1034
1053
  continue;
1054
+ totalSpotValue += value;
1035
1055
  spotRows.push([
1036
1056
  chalk.white.bold(b.token),
1037
1057
  chalk.gray("lighter"),
@@ -1048,6 +1068,14 @@ export function registerAccountCommands(program, getAdapter, isJson, getAdapterF
1048
1068
  console.log(chalk.white.bold("\n Spot Holdings"));
1049
1069
  console.log(makeTable(["Token", "Exchange", "Amount", "Price", "Value"], spotRows));
1050
1070
  }
1071
+ // ── Total (perp + spot) ──
1072
+ if (totalSpotValue > 0) {
1073
+ const totalValue = summary.totalEquity + totalSpotValue;
1074
+ console.log(chalk.white.bold(" Total Account Value"));
1075
+ console.log(` Perp Equity: $${formatUsd(summary.totalEquity)}`);
1076
+ console.log(` Spot Value: $${formatUsd(totalSpotValue)}`);
1077
+ console.log(` ${chalk.cyan.bold(`Total: $${formatUsd(totalValue)}`)}`);
1078
+ }
1051
1079
  // ── Risk Metrics ──
1052
1080
  console.log(chalk.white.bold("\n Risk Metrics"));
1053
1081
  const levelColor = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perp-cli",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "Multi-DEX Perpetual Futures CLI - Pacifica, Hyperliquid, Lighter",
5
5
  "bin": {
6
6
  "perp": "dist/index.js",