perp-cli 0.7.3 → 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.
- package/dist/commands/arb.js +1 -1
- package/dist/commands/bot.js +2 -3
- package/dist/index.js +34 -3
- package/dist/utils.js +6 -1
- package/package.json +1 -1
package/dist/commands/arb.js
CHANGED
|
@@ -263,7 +263,7 @@ function printFundingExchangeStatus(snapshot) {
|
|
|
263
263
|
console.log(chalk.gray(` Exchange status: ${statuses.join(" ")}\n`));
|
|
264
264
|
}
|
|
265
265
|
function printDetailedComparison(comparison) {
|
|
266
|
-
const exAbbr = (e) => e === "pacifica" ? "PAC" : e === "hyperliquid" ? "HL" : "LT";
|
|
266
|
+
const exAbbr = (e) => e === "pacifica" ? "PAC" : e === "hyperliquid" ? "HL" : e === "lighter" ? "LT" : e === "aster" ? "AST" : e.toUpperCase();
|
|
267
267
|
console.log(chalk.cyan.bold(` ${comparison.symbol} Funding Rate Comparison\n`));
|
|
268
268
|
console.log(` Mark Price: $${formatUsd(comparison.bestMarkPrice)}\n`);
|
|
269
269
|
for (const r of comparison.rates) {
|
package/dist/commands/bot.js
CHANGED
|
@@ -446,8 +446,7 @@ export function registerBotCommands(program, getAdapter, getAdapterFor, isJson)
|
|
|
446
446
|
if (sym === "ALL" && symbolRequiredStrategies.includes(strategyName)) {
|
|
447
447
|
console.error(chalk.red(`\n Error: The '${strategyName}' strategy requires a <symbol> argument.`));
|
|
448
448
|
console.error(chalk.gray(` Usage: perp bot run ${strategyName} <symbol>\n`));
|
|
449
|
-
process.
|
|
450
|
-
return;
|
|
449
|
+
return process.exit(1);
|
|
451
450
|
}
|
|
452
451
|
// Load or build config
|
|
453
452
|
let config;
|
|
@@ -505,7 +504,7 @@ export function registerBotCommands(program, getAdapter, getAdapterFor, isJson)
|
|
|
505
504
|
for (const s of available)
|
|
506
505
|
console.error(chalk.gray(` - ${s}`));
|
|
507
506
|
console.error();
|
|
508
|
-
return;
|
|
507
|
+
return process.exit(1);
|
|
509
508
|
}
|
|
510
509
|
const adapter = await getAdapter();
|
|
511
510
|
config.exchange = adapter.name;
|
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
|
|
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
|
-
|
|
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/dist/utils.js
CHANGED
|
@@ -10,9 +10,14 @@ export function formatUsd(value) {
|
|
|
10
10
|
const num = Number(value);
|
|
11
11
|
if (isNaN(num))
|
|
12
12
|
return String(value);
|
|
13
|
+
// Use more decimals for sub-cent values so they don't show as $0.00
|
|
14
|
+
const absNum = Math.abs(num);
|
|
15
|
+
const maxDecimals = absNum > 0 && absNum < 0.01 ? 6
|
|
16
|
+
: absNum < 1 ? 4
|
|
17
|
+
: 2;
|
|
13
18
|
return num.toLocaleString("en-US", {
|
|
14
19
|
minimumFractionDigits: 2,
|
|
15
|
-
maximumFractionDigits:
|
|
20
|
+
maximumFractionDigits: maxDecimals,
|
|
16
21
|
});
|
|
17
22
|
}
|
|
18
23
|
export function formatPnl(value) {
|