perp-cli 0.3.5 → 0.3.6
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.
|
@@ -62,6 +62,23 @@ export class LighterAdapter {
|
|
|
62
62
|
? this._accountIndexInit
|
|
63
63
|
: json.accounts[0].account_index;
|
|
64
64
|
}
|
|
65
|
+
// Auto-generate API key if we have PK but no API key and account exists
|
|
66
|
+
if (!this._apiKey && this._accountIndex >= 0) {
|
|
67
|
+
try {
|
|
68
|
+
const { privateKey: apiKey } = await this.setupApiKey();
|
|
69
|
+
this._apiKey = apiKey;
|
|
70
|
+
// Save to .env for future use
|
|
71
|
+
try {
|
|
72
|
+
const { setEnvVar } = await import("../commands/init.js");
|
|
73
|
+
setEnvVar("LIGHTER_API_KEY", apiKey);
|
|
74
|
+
setEnvVar("LIGHTER_ACCOUNT_INDEX", String(this._accountIndex));
|
|
75
|
+
}
|
|
76
|
+
catch { /* non-critical — env save may fail in some contexts */ }
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// Auto-setup failed (no gas, network issue, etc.) — continue in read-only mode
|
|
80
|
+
}
|
|
81
|
+
}
|
|
65
82
|
// Initialize signer for trading if we have an API key
|
|
66
83
|
if (this._apiKey) {
|
|
67
84
|
const { LighterSignerClient } = require("lighter-sdk");
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ const _defaultExchange = _settings.defaultExchange || "pacifica";
|
|
|
48
48
|
program
|
|
49
49
|
.name("perp")
|
|
50
50
|
.description("Multi-DEX Perpetual Futures CLI (Pacifica, Hyperliquid, Lighter)")
|
|
51
|
-
.version("0.3.
|
|
51
|
+
.version("0.3.6")
|
|
52
52
|
.option("-e, --exchange <exchange>", `Exchange: pacifica, hyperliquid, lighter (default: ${_defaultExchange})`, _defaultExchange)
|
|
53
53
|
.option("-n, --network <network>", "Network: mainnet or testnet", "mainnet")
|
|
54
54
|
.option("-k, --private-key <key>", "Private key")
|
|
@@ -383,7 +383,7 @@ if (rawArgs.length === 0 || (!hasSubcommand && !rawArgs.includes("-h") && !rawAr
|
|
|
383
383
|
process.env.LIGHTER_PRIVATE_KEY);
|
|
384
384
|
if (!status.hasWallets && !hasEnvKey && !settings.defaultExchange) {
|
|
385
385
|
// Fresh install — onboarding
|
|
386
|
-
console.log(chalk.cyan.bold("\n Welcome to perp-cli!") + chalk.gray(" v0.3.
|
|
386
|
+
console.log(chalk.cyan.bold("\n Welcome to perp-cli!") + chalk.gray(" v0.3.6\n"));
|
|
387
387
|
console.log(" Multi-DEX perpetual futures CLI for Pacifica, Hyperliquid, and Lighter.\n");
|
|
388
388
|
console.log(` Get started: ${chalk.cyan("perp init")}`);
|
|
389
389
|
console.log(chalk.gray(`\n Or explore without a wallet:`));
|
|
@@ -396,7 +396,7 @@ if (rawArgs.length === 0 || (!hasSubcommand && !rawArgs.includes("-h") && !rawAr
|
|
|
396
396
|
// Configured — show status overview
|
|
397
397
|
const defaultEx = settings.defaultExchange || "pacifica";
|
|
398
398
|
const activeEntries = Object.entries(status.active);
|
|
399
|
-
console.log(chalk.cyan.bold("\n perp-cli") + chalk.gray(" v0.3.
|
|
399
|
+
console.log(chalk.cyan.bold("\n perp-cli") + chalk.gray(" v0.3.6\n"));
|
|
400
400
|
console.log(` Default exchange: ${chalk.cyan(defaultEx)}`);
|
|
401
401
|
if (activeEntries.length > 0) {
|
|
402
402
|
console.log(chalk.white.bold("\n Wallets:"));
|
package/dist/mcp-server.js
CHANGED
|
@@ -56,7 +56,7 @@ function err(error, meta) {
|
|
|
56
56
|
return JSON.stringify({ ok: false, error, meta }, null, 2);
|
|
57
57
|
}
|
|
58
58
|
// ── MCP Server ──
|
|
59
|
-
const server = new McpServer({ name: "perp-cli", version: "0.3.
|
|
59
|
+
const server = new McpServer({ name: "perp-cli", version: "0.3.6" }, { capabilities: { tools: {}, resources: {} } });
|
|
60
60
|
// ============================================================
|
|
61
61
|
// Market Data tools (read-only, no private key needed)
|
|
62
62
|
// ============================================================
|
package/package.json
CHANGED
package/skills/perp-cli/SKILL.md
CHANGED
|
@@ -82,22 +82,14 @@ perp --json arb rates
|
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
### Lighter API Key Setup
|
|
85
|
-
Lighter
|
|
85
|
+
Lighter uses a separate API key for trading, but **this is handled automatically**.
|
|
86
|
+
When `LIGHTER_PRIVATE_KEY` is set (env var or `wallet set`), the CLI auto-generates and saves the API key on first use.
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
# wallet set automatically generates & registers API key + saves to .env
|
|
89
|
-
perp --json wallet set lt 0xEVM_KEY
|
|
90
|
-
# → saves LIGHTER_PRIVATE_KEY, LIGHTER_API_KEY, LIGHTER_ACCOUNT_INDEX to ~/.perp/.env
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
If auto-setup failed (e.g. no ETH for gas), retry manually:
|
|
88
|
+
If auto-setup fails (e.g. no ETH for gas on Lighter chain), retry manually:
|
|
94
89
|
```bash
|
|
95
90
|
perp --json -e lighter manage setup-api-key
|
|
96
|
-
# → generates API key, registers on-chain, auto-saves to ~/.perp/.env
|
|
97
91
|
```
|
|
98
92
|
|
|
99
|
-
**Note:** On-chain registration requires a small amount of ETH on the Lighter chain for gas.
|
|
100
|
-
|
|
101
93
|
### Using the Same EVM Key for Multiple Exchanges
|
|
102
94
|
One EVM private key works for both Hyperliquid and Lighter:
|
|
103
95
|
```bash
|