jaspervault_cli 1.0.16 → 1.0.17
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/src/commands/init.js +30 -13
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/order.js +11 -2
- package/dist/src/commands/order.js.map +1 -1
- package/dist/src/commands/sl.js +7 -1
- package/dist/src/commands/sl.js.map +1 -1
- package/dist/src/commands/tp.js +7 -1
- package/dist/src/commands/tp.js.map +1 -1
- package/dist/src/services/order-signer.js +2 -1
- package/dist/src/services/order-signer.js.map +1 -1
- package/dist/src/templates/skill-body.d.ts +8 -3
- package/dist/src/templates/skill-body.js +268 -175
- package/dist/src/templates/skill-body.js.map +1 -1
- package/dist/src/types.d.ts +2 -0
- package/dist/src/utils/ppo.d.ts +12 -0
- package/dist/src/utils/ppo.js +45 -0
- package/dist/src/utils/ppo.js.map +1 -0
- package/package.json +1 -1
|
@@ -4,7 +4,6 @@ import { homedir } from 'node:os';
|
|
|
4
4
|
import { BANNER, buildSkillContent } from '../templates/skill-body.js';
|
|
5
5
|
export const PLATFORMS = ['openclaw', 'cursor', 'claude', 'all'];
|
|
6
6
|
const SKILL_DIR = 'jasper-vault-cli';
|
|
7
|
-
const SKILL_FILE = 'SKILL.md';
|
|
8
7
|
function getTargetPath(platform, global) {
|
|
9
8
|
const home = homedir();
|
|
10
9
|
const cwd = process.cwd();
|
|
@@ -47,7 +46,7 @@ export function registerInitCommand(program) {
|
|
|
47
46
|
.description('Install JasperVault skill to AI platform (OpenClaw, Cursor, Claude Code)')
|
|
48
47
|
.requiredOption('--ai <platform>', `Target platform: ${PLATFORMS.join(', ')}`)
|
|
49
48
|
.option('--global', 'Install to user home directory (cursor/claude only)')
|
|
50
|
-
.option('--force', 'Overwrite existing skill
|
|
49
|
+
.option('--force', 'Overwrite existing skill files without prompting')
|
|
51
50
|
.action(async (opts) => {
|
|
52
51
|
const platform = opts.ai;
|
|
53
52
|
if (!PLATFORMS.includes(platform)) {
|
|
@@ -60,23 +59,42 @@ export function registerInitCommand(program) {
|
|
|
60
59
|
process.stdout.write(BANNER + '\n\n');
|
|
61
60
|
const results = [];
|
|
62
61
|
for (const targetDir of targetPaths) {
|
|
63
|
-
const filePath = path.join(targetDir, SKILL_FILE);
|
|
64
62
|
const skillPlatform = platform === 'all' ? getPlatformFromPath(targetDir) : platform;
|
|
65
63
|
const platDisplay = getPlatformDisplayName(skillPlatform);
|
|
66
64
|
try {
|
|
65
|
+
const skillMdPath = path.join(targetDir, 'SKILL.md');
|
|
67
66
|
const exists = await fs
|
|
68
|
-
.access(
|
|
67
|
+
.access(skillMdPath)
|
|
69
68
|
.then(() => true)
|
|
70
69
|
.catch(() => false);
|
|
71
70
|
if (exists && !force) {
|
|
72
|
-
process.stderr.write(`Error: Skill already exists at ${
|
|
71
|
+
process.stderr.write(`Error: Skill already exists at ${targetDir}\n` +
|
|
73
72
|
'Use --force to overwrite.\n');
|
|
74
73
|
process.exit(1);
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
const files = buildSkillContent(skillPlatform);
|
|
76
|
+
let fileCount = 0;
|
|
77
|
+
for (const [relPath, content] of Object.entries(files)) {
|
|
78
|
+
const filePath = path.join(targetDir, relPath);
|
|
79
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
80
|
+
await fs.writeFile(filePath, content, 'utf8');
|
|
81
|
+
fileCount++;
|
|
82
|
+
}
|
|
83
|
+
// Make scripts executable
|
|
84
|
+
const scriptsDir = path.join(targetDir, 'scripts');
|
|
85
|
+
const scriptsDirExists = await fs
|
|
86
|
+
.access(scriptsDir)
|
|
87
|
+
.then(() => true)
|
|
88
|
+
.catch(() => false);
|
|
89
|
+
if (scriptsDirExists) {
|
|
90
|
+
const scriptFiles = await fs.readdir(scriptsDir);
|
|
91
|
+
for (const sf of scriptFiles) {
|
|
92
|
+
if (sf.endsWith('.sh')) {
|
|
93
|
+
await fs.chmod(path.join(scriptsDir, sf), 0o755);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
results.push({ path: targetDir, platform: platDisplay, fileCount });
|
|
80
98
|
}
|
|
81
99
|
catch (err) {
|
|
82
100
|
process.stderr.write(`Error installing to ${platDisplay}: ${err.message}\n`);
|
|
@@ -85,13 +103,12 @@ export function registerInitCommand(program) {
|
|
|
85
103
|
}
|
|
86
104
|
process.stdout.write('\n ✓ Skill installed successfully!\n\n' +
|
|
87
105
|
results
|
|
88
|
-
.map((r) => ` Platform: ${r.platform}\n Location: ${r.path}`)
|
|
106
|
+
.map((r) => ` Platform: ${r.platform}\n Location: ${r.path}\n Files: ${r.fileCount} (SKILL.md + references/ + scripts/)`)
|
|
89
107
|
.join('\n\n') +
|
|
90
108
|
'\n\n Next steps:\n' +
|
|
91
|
-
' 1. First-time setup:
|
|
109
|
+
' 1. First-time setup: jv vault init-wc --network jaspervault\n' +
|
|
92
110
|
' 2. (Optional) Override API URL for local debugging: export JV_API_URL=http://localhost:3000\n' +
|
|
93
|
-
' 3.
|
|
94
|
-
' 4. Start using jv commands or let your AI agent call them\n');
|
|
111
|
+
' 3. Start using jv commands or let your AI agent call them\n');
|
|
95
112
|
});
|
|
96
113
|
}
|
|
97
114
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AAG1E,MAAM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AC;gBAED,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;YACtE,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,WAAW,KAAM,GAAa,CAAC,OAAO,IAAI,CAAC,CAAC;gBACxF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,yCAAyC;YACvC,OAAO;iBACJ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,QAAQ,kBAAkB,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,SAAS,sCAAsC,CAAC;iBACjI,IAAI,CAAC,MAAM,CAAC;YACf,qBAAqB;YACrB,oEAAoE;YACpE,oGAAoG;YACpG,iEAAiE,CACpE,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { loadDelegationKey } from '../services/key-manager.js';
|
|
|
8
8
|
import { loadVaultProfile, getPositionAccountFromProfile } from '../services/vault-profile.js';
|
|
9
9
|
import { buildSignData, signSignData, fetchWriterIndices, buildManagedOrder, } from '../services/order-signer.js';
|
|
10
10
|
import { fetchCurrentPrice, calculateQuantity } from '../services/price-service.js';
|
|
11
|
+
import { parsePpoOptions } from '../utils/ppo.js';
|
|
11
12
|
export function registerOrderCommand(program) {
|
|
12
13
|
const order = program
|
|
13
14
|
.command('order')
|
|
@@ -22,6 +23,10 @@ export function registerOrderCommand(program) {
|
|
|
22
23
|
.option('--margin-account <addr>', 'Margin vault address (default: from profile)')
|
|
23
24
|
.option('--position-account <addr>', 'Position vault address (default: from profile)')
|
|
24
25
|
.option('--limit-price <price>', 'Limit price in USDC (omit for market order)')
|
|
26
|
+
.option('--ppo', 'Enable PPO hedge option protection')
|
|
27
|
+
.option('--ppo-expire <duration>', 'PPO expiry: 30m (default) or 8h')
|
|
28
|
+
.option('--ppo-category <ATM|OTM>', 'PPO option category (default: ATM)')
|
|
29
|
+
.option('--ppo-tier <1-5>', 'OTM strike offset tier: 1=0.1%, 2=0.2%, 3=0.3%, 4=0.4%, 5=0.5%')
|
|
25
30
|
.option('--network <name>', 'Network name', 'jaspervault')
|
|
26
31
|
.option('--ttl <seconds>', 'Order TTL in seconds', '3600')
|
|
27
32
|
.option('--pretty', 'Pretty-print JSON output')
|
|
@@ -45,6 +50,7 @@ export function registerOrderCommand(program) {
|
|
|
45
50
|
const marginInput = parseFloat(opts.margin);
|
|
46
51
|
const notionalAmount = marginInput * leverage;
|
|
47
52
|
const actualMargin = marginInput.toFixed(6);
|
|
53
|
+
const { limitType, ppoSettings } = parsePpoOptions(opts);
|
|
48
54
|
const positionAccount = opts.positionAccount ?? getPositionAccountFromProfile(profile, side) ?? undefined;
|
|
49
55
|
const intent = {
|
|
50
56
|
side,
|
|
@@ -56,6 +62,7 @@ export function registerOrderCommand(program) {
|
|
|
56
62
|
limitPrice: opts.limitPrice,
|
|
57
63
|
network: opts.network,
|
|
58
64
|
ttlSeconds: parseInt(opts.ttl, 10),
|
|
65
|
+
limitType,
|
|
59
66
|
};
|
|
60
67
|
const provider = new JsonRpcProvider(net.rpcUrl);
|
|
61
68
|
const optionModuleV2 = net.contracts.optionModuleV2 ?? net.contracts.diamond;
|
|
@@ -77,7 +84,7 @@ export function registerOrderCommand(program) {
|
|
|
77
84
|
signData,
|
|
78
85
|
signature,
|
|
79
86
|
managedOrder,
|
|
80
|
-
ppoSettings
|
|
87
|
+
ppoSettings,
|
|
81
88
|
};
|
|
82
89
|
const config = loadConfig();
|
|
83
90
|
const client = new ApiClient(config);
|
|
@@ -94,12 +101,14 @@ export function registerOrderCommand(program) {
|
|
|
94
101
|
});
|
|
95
102
|
order
|
|
96
103
|
.command('create-option')
|
|
97
|
-
.description('
|
|
104
|
+
.description('[Deprecated] Use "jv order create --ppo" instead. Raw option payload passthrough.')
|
|
98
105
|
.requiredOption('--order-id <id>', 'Associated perps order ID')
|
|
99
106
|
.option('--data <json>', 'Inline JSON payload')
|
|
100
107
|
.option('--payload <file>', 'Path to JSON payload file')
|
|
101
108
|
.option('--pretty', 'Pretty-print JSON output')
|
|
102
109
|
.action(async (opts) => {
|
|
110
|
+
console.error('Warning: create-option is deprecated. Use "jv order create --ppo" instead.\n' +
|
|
111
|
+
'This command requires a pre-signed payload and will be removed in a future version.');
|
|
103
112
|
const config = loadConfig();
|
|
104
113
|
const client = new ApiClient(config);
|
|
105
114
|
const body = await resolvePayload(opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order.js","sourceRoot":"","sources":["../../../src/commands/order.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EACL,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"order.js","sourceRoot":"","sources":["../../../src/commands/order.ts"],"names":[],"mappings":"AACA,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AAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/src/commands/sl.js
CHANGED
|
@@ -7,6 +7,7 @@ import { getNetworkConfig } from '../services/chain-config.js';
|
|
|
7
7
|
import { loadDelegationKey } from '../services/key-manager.js';
|
|
8
8
|
import { loadVaultProfile, getPositionAccountFromProfile } from '../services/vault-profile.js';
|
|
9
9
|
import { buildSignData, signSignData, fetchWriterIndices, buildManagedOrder, } from '../services/order-signer.js';
|
|
10
|
+
import { parsePpoOptions } from '../utils/ppo.js';
|
|
10
11
|
export function registerSlCommand(program) {
|
|
11
12
|
const sl = program.command('sl').description('Stop-loss order management');
|
|
12
13
|
sl
|
|
@@ -16,6 +17,10 @@ export function registerSlCommand(program) {
|
|
|
16
17
|
.requiredOption('--price <usdc>', 'Target price in USDC')
|
|
17
18
|
.requiredOption('--symbol <symbol>', 'Asset symbol (e.g. JBTC)')
|
|
18
19
|
.option('--side <long|short>', 'Position side being closed', 'long')
|
|
20
|
+
.option('--ppo', 'Enable PPO hedge option protection')
|
|
21
|
+
.option('--ppo-expire <duration>', 'PPO expiry: 30m (default) or 8h')
|
|
22
|
+
.option('--ppo-category <ATM|OTM>', 'PPO option category (default: ATM)')
|
|
23
|
+
.option('--ppo-tier <1-5>', 'OTM strike offset tier: 1=0.1%, 2=0.2%, 3=0.3%, 4=0.4%, 5=0.5%')
|
|
19
24
|
.option('--network <name>', 'Network name', 'jaspervault')
|
|
20
25
|
.option('--ttl <seconds>', 'Order TTL in seconds', '86400')
|
|
21
26
|
.option('--pretty', 'Pretty-print JSON output')
|
|
@@ -52,11 +57,12 @@ export function registerSlCommand(program) {
|
|
|
52
57
|
const delegationWallet = new Wallet(delegation.delegationPrivateKey);
|
|
53
58
|
const signature = await signSignData(signData, delegationWallet);
|
|
54
59
|
const managedOrder = buildManagedOrder(signData, writerIndices, holder, '0');
|
|
60
|
+
const { ppoSettings } = parsePpoOptions(opts);
|
|
55
61
|
const body = {
|
|
56
62
|
signData,
|
|
57
63
|
signature,
|
|
58
64
|
managedOrder,
|
|
59
|
-
ppoSettings
|
|
65
|
+
ppoSettings,
|
|
60
66
|
};
|
|
61
67
|
const config = loadConfig();
|
|
62
68
|
const client = new ApiClient(config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sl.js","sourceRoot":"","sources":["../../../src/commands/sl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EACL,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"sl.js","sourceRoot":"","sources":["../../../src/commands/sl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,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OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACpE,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAC5C,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,SAAS,EAClB,QAAQ,CAAC,eAAe,EACxB,QAAQ,EACR,cAAc,CACf,CAAC;QACF,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;QACrE,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QACjE,MAAM,YAAY,GAAG,iBAAiB,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAE7E,MAAM,EAAE,WAAW,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QAE9C,MAAM,IAAI,GAAuB;YAC/B,QAAQ;YACR,SAAS;YACT,YAAY;YACZ,WAAW;SACZ,CAAC;QAEF,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAqB,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAChF,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CACF,CAAC;AACN,CAAC"}
|
package/dist/src/commands/tp.js
CHANGED
|
@@ -7,6 +7,7 @@ import { getNetworkConfig } from '../services/chain-config.js';
|
|
|
7
7
|
import { loadDelegationKey } from '../services/key-manager.js';
|
|
8
8
|
import { loadVaultProfile, getPositionAccountFromProfile } from '../services/vault-profile.js';
|
|
9
9
|
import { buildSignData, signSignData, fetchWriterIndices, buildManagedOrder, } from '../services/order-signer.js';
|
|
10
|
+
import { parsePpoOptions } from '../utils/ppo.js';
|
|
10
11
|
export function registerTpCommand(program) {
|
|
11
12
|
const tp = program.command('tp').description('Take-profit order management');
|
|
12
13
|
tp
|
|
@@ -16,6 +17,10 @@ export function registerTpCommand(program) {
|
|
|
16
17
|
.requiredOption('--price <usdc>', 'Target price in USDC')
|
|
17
18
|
.requiredOption('--symbol <symbol>', 'Asset symbol (e.g. JBTC)')
|
|
18
19
|
.option('--side <long|short>', 'Position side being closed', 'long')
|
|
20
|
+
.option('--ppo', 'Enable PPO hedge option protection')
|
|
21
|
+
.option('--ppo-expire <duration>', 'PPO expiry: 30m (default) or 8h')
|
|
22
|
+
.option('--ppo-category <ATM|OTM>', 'PPO option category (default: ATM)')
|
|
23
|
+
.option('--ppo-tier <1-5>', 'OTM strike offset tier: 1=0.1%, 2=0.2%, 3=0.3%, 4=0.4%, 5=0.5%')
|
|
19
24
|
.option('--network <name>', 'Network name', 'jaspervault')
|
|
20
25
|
.option('--ttl <seconds>', 'Order TTL in seconds', '86400')
|
|
21
26
|
.option('--pretty', 'Pretty-print JSON output')
|
|
@@ -52,11 +57,12 @@ export function registerTpCommand(program) {
|
|
|
52
57
|
const delegationWallet = new Wallet(delegation.delegationPrivateKey);
|
|
53
58
|
const signature = await signSignData(signData, delegationWallet);
|
|
54
59
|
const managedOrder = buildManagedOrder(signData, writerIndices, holder, '0');
|
|
60
|
+
const { ppoSettings } = parsePpoOptions(opts);
|
|
55
61
|
const body = {
|
|
56
62
|
signData,
|
|
57
63
|
signature,
|
|
58
64
|
managedOrder,
|
|
59
|
-
ppoSettings
|
|
65
|
+
ppoSettings,
|
|
60
66
|
};
|
|
61
67
|
const config = loadConfig();
|
|
62
68
|
const client = new ApiClient(config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tp.js","sourceRoot":"","sources":["../../../src/commands/tp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAA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,CAAC;QAE7E,MAAM,EAAE,WAAW,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QAE9C,MAAM,IAAI,GAAuB;YAC/B,QAAQ;YACR,SAAS;YACT,YAAY;YACZ,WAAW;SACZ,CAAC;QAEF,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAqB,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAChF,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CACF,CAAC;AACN,CAAC"}
|
|
@@ -62,8 +62,9 @@ export async function buildSignData(intent, profile, network) {
|
|
|
62
62
|
signOrderType = orderType;
|
|
63
63
|
}
|
|
64
64
|
const writerAddress = getWriterAddress(network, symbol, writerSide);
|
|
65
|
+
const limitType = !isTpSl ? (intent.limitType ?? 0) : 0;
|
|
65
66
|
return {
|
|
66
|
-
limitType
|
|
67
|
+
limitType,
|
|
67
68
|
orderID,
|
|
68
69
|
orderType: signOrderType,
|
|
69
70
|
productType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-signer.js","sourceRoot":"","sources":["../../../src/services/order-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,WAAW,GAAG,gFAAgF,CAAC;AACrG,MAAM,eAAe,GAAG,GAAG,IAAI,GAAG,CAAC;AAEnC,MAAM,gCAAgC,GAAG;IACvC,qfAAqf;CACtf,CAAC;AAQF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU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B,EAC5B,MAAc,EACd,WAAmB,GAAG;IAEtB,OAAO;QACL,MAAM;QACN,QAAQ;QACR,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,aAAa,EAAE,aAAa,CAAC,aAAa;QAC1C,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;QAChD,WAAW,EAAE,GAAG;QAChB,aAAa,EAAE,MAAM,CAAC,WAAW;QACjC,gBAAgB,EAAE,GAAG;QACrB,gBAAgB,EAAE,KAAK;QACvB,OAAO,EAAE,aAAa,CAAC,OAAO;KAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Skill template content and banner for jv init command.
|
|
3
|
-
*
|
|
3
|
+
* Generates a multi-file skill structure:
|
|
4
|
+
* SKILL.md — compact core rules + activation + intent table
|
|
5
|
+
* references/ — detailed docs loaded on demand by the agent
|
|
6
|
+
* scripts/ — helper scripts
|
|
4
7
|
*/
|
|
5
8
|
/** ANSI Shadow style ASCII art banner (plain text, no ANSI colors) */
|
|
6
9
|
export declare const BANNER: string;
|
|
10
|
+
export type SkillFiles = Record<string, string>;
|
|
7
11
|
/**
|
|
8
|
-
* Build platform-specific
|
|
12
|
+
* Build platform-specific skill file tree.
|
|
13
|
+
* Returns a Record mapping relative file paths to their content.
|
|
9
14
|
* @param platform - One of: openclaw, cursor, claude
|
|
10
15
|
*/
|
|
11
|
-
export declare function buildSkillContent(platform: string):
|
|
16
|
+
export declare function buildSkillContent(platform: string): SkillFiles;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Skill template content and banner for jv init command.
|
|
3
|
-
*
|
|
3
|
+
* Generates a multi-file skill structure:
|
|
4
|
+
* SKILL.md — compact core rules + activation + intent table
|
|
5
|
+
* references/ — detailed docs loaded on demand by the agent
|
|
6
|
+
* scripts/ — helper scripts
|
|
4
7
|
*/
|
|
5
8
|
import { readFileSync } from 'node:fs';
|
|
6
9
|
import { fileURLToPath } from 'node:url';
|
|
@@ -25,124 +28,126 @@ export const BANNER = `
|
|
|
25
28
|
── JasperVault CLI v${CLI_VERSION} ──
|
|
26
29
|
⟐ Skill Installer
|
|
27
30
|
`.trim();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Core SKILL.md body — kept under 50 lines so critical rules stay prominent
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
const SKILL_CORE_BODY = `
|
|
35
|
+
Trade perpetual contracts on JasperVault via the \`jv\` CLI. No private key is ever required.
|
|
31
36
|
|
|
32
|
-
##
|
|
37
|
+
## CRITICAL RULES (MUST FOLLOW — violations cause broken UX)
|
|
33
38
|
|
|
34
|
-
- \`jv\`
|
|
35
|
-
|
|
36
|
-
-
|
|
39
|
+
1. **WalletConnect ONLY**: ALWAYS use \`jv vault init-wc\`. NEVER suggest \`jv vault init\` (private-key mode). NEVER ask the user to set \`PRIVATE_KEY\`.
|
|
40
|
+
2. **QR Code Display**: When \`jv vault init-wc\` outputs JSON with a \`qrCodeUrl\` field, you MUST display it as a markdown image: \`\`. NEVER post the URL as plain text. NEVER print \`qrCodeText\`. The image will NOT render unless you use the \`\` wrapper.
|
|
41
|
+
3. **Long-running Commands**: \`jv vault init-wc\` runs for up to 2 minutes and outputs two JSON lines sequentially. Do NOT interrupt, kill, or assume it is finished after the first JSON line. Wait for the process to exit naturally.
|
|
42
|
+
4. **Real-time Prices**: NEVER guess or estimate prices. ALWAYS run \`jv price --symbol JBTC --pretty\` before any price-dependent operation (opening a position by asset quantity, calculating PnL).
|
|
37
43
|
|
|
38
44
|
## Activation Behavior
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
\`\`\`
|
|
46
|
-
|
|
47
|
-
2. If the command fails with "delegation key not found", "vault not initialized", "no profile", or similar error (exit code 1):
|
|
48
|
-
- Tell the user: "Your vault is not initialized yet. Let me start the setup via WalletConnect — no private key needed."
|
|
49
|
-
- Immediately run \`jv vault init-wc --network jaspervault --timeout 120\` and follow the QR code display instructions in the Setup Flow section below.
|
|
50
|
-
|
|
46
|
+
1. Check if vault is initialized: \`jv orders list --pretty\`
|
|
47
|
+
2. If the command fails (exit code 1, or errors like "delegation key not found" / "vault not initialized" / "no profile"):
|
|
48
|
+
- Tell the user: "Your vault is not initialized yet. Let me set it up via WalletConnect — no private key needed."
|
|
49
|
+
- Immediately run \`jv vault init-wc --network jaspervault --timeout 120\`.
|
|
50
|
+
- Follow the QR code display instructions in [references/onboarding.md](references/onboarding.md).
|
|
51
51
|
3. If the command succeeds → vault is ready. Proceed with the user's request.
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
## Intent → Command Reference
|
|
54
|
+
|
|
55
|
+
| User Intent | Command | Details |
|
|
56
|
+
|-------------|---------|---------|
|
|
57
|
+
| Initialize / connect wallet | \`jv vault init-wc\` | [references/onboarding.md](references/onboarding.md) |
|
|
58
|
+
| Deposit tokens | \`jv deposit info\` + \`jv deposit poll\` | [references/onboarding.md](references/onboarding.md) |
|
|
59
|
+
| Get current price | \`jv price --symbol JBTC --pretty\` | [references/trading.md](references/trading.md) |
|
|
60
|
+
| Open position (market) | \`jv order create --side long/short ...\` | [references/trading.md](references/trading.md) |
|
|
61
|
+
| Open position (limit) | \`jv order create ... --limit-price N\` | [references/trading.md](references/trading.md) |
|
|
62
|
+
| Reduce / close position | opposite-side \`jv order create\` | [references/trading.md](references/trading.md) |
|
|
63
|
+
| Set take-profit | \`jv tp set --order-id ID --price P\` | [references/trading.md](references/trading.md) |
|
|
64
|
+
| Set stop-loss | \`jv sl set --order-id ID --price P\` | [references/trading.md](references/trading.md) |
|
|
65
|
+
| Hedge / protect position (PPO) | add \`--ppo\` to order create | [references/trading.md](references/trading.md) |
|
|
66
|
+
| Query positions / portfolio | \`jv orders list --pretty\` | [references/queries.md](references/queries.md) |
|
|
67
|
+
| Job execution status | \`jv job status <jobId>\` | [references/queries.md](references/queries.md) |
|
|
68
|
+
| Manage limit orders | \`jv limit-order list/cancel\` | [references/queries.md](references/queries.md) |
|
|
69
|
+
|
|
70
|
+
## Security
|
|
71
|
+
|
|
72
|
+
- Never log or display private keys, signatures, or API keys.
|
|
73
|
+
- The CLI signs orders via the delegation wallet in \`~/.jaspervault/keys.json\`.
|
|
74
|
+
- Do NOT ask the user to set \`PRIVATE_KEY\`.
|
|
75
|
+
`.trim();
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// references/onboarding.md — WalletConnect init + deposit flow
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
const ONBOARDING_REFERENCE = `# WalletConnect Onboarding & Deposit
|
|
54
80
|
|
|
55
|
-
##
|
|
81
|
+
## Vault Init via WalletConnect
|
|
56
82
|
|
|
57
83
|
\`\`\`bash
|
|
58
|
-
# Initialize vault and delegation wallet via WalletConnect (one-time, no private key required)
|
|
59
84
|
jv vault init-wc --network jaspervault --timeout 120
|
|
60
85
|
\`\`\`
|
|
61
86
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
The command outputs two JSON lines:
|
|
87
|
+
This command runs for up to 2 minutes. Do NOT interrupt or kill the process after the first JSON line. Wait for the process to exit naturally.
|
|
65
88
|
|
|
66
|
-
|
|
89
|
+
The command outputs two JSON lines sequentially:
|
|
67
90
|
|
|
68
|
-
|
|
91
|
+
### Line 1: Awaiting Connection
|
|
69
92
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
Replace the URL above with the actual \`qrCodeUrl\` from the JSON output. Also provide the \`uri\` as a fallback:
|
|
75
|
-
|
|
76
|
-
> Or open your wallet app → WalletConnect → paste this URI: \`wc:...\`
|
|
77
|
-
|
|
78
|
-
CRITICAL: MUST use markdown image syntax \`\`. NEVER post the URL as plain text. NEVER print \`qrCodeText\`. NEVER generate your own QR code. The image will not appear if you only post the raw URL without the \`![...]()\` wrapper.
|
|
79
|
-
|
|
80
|
-
2. \`{"success":true, "message":"Vault initialized successfully", ...}\` — Init complete. The delegation wallet is saved to \`~/.jaspervault/keys.json\` and vault addresses to \`~/.jaspervault/profile.json\`. Subsequent commands use these automatically — no wallet interaction needed.
|
|
81
|
-
|
|
82
|
-
Do NOT ask the user to set \`PRIVATE_KEY\`. Do NOT suggest \`jv vault init\` unless the user explicitly requests private-key mode.
|
|
93
|
+
\`\`\`json
|
|
94
|
+
{"status":"awaiting_connection", "uri":"wc:...", "qrCodeUrl":"https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=wc%3A...", ...}
|
|
95
|
+
\`\`\`
|
|
83
96
|
|
|
84
|
-
|
|
97
|
+
Extract the \`qrCodeUrl\` field. You MUST send it as a markdown image so it renders as a scannable QR code in the chat:
|
|
85
98
|
|
|
86
|
-
|
|
99
|
+
\`\`\`
|
|
100
|
+

|
|
101
|
+
\`\`\`
|
|
87
102
|
|
|
88
|
-
|
|
103
|
+
Replace the URL with the actual \`qrCodeUrl\` value from the JSON output. Also provide the \`uri\` as a fallback:
|
|
89
104
|
|
|
90
|
-
|
|
91
|
-
|---------|---------|---------|
|
|
92
|
-
| Notional value | \`margin × leverage\` | 60 USDC × 50x = $3,000 |
|
|
93
|
-
| Position size | \`notional / current_price\` | $3,000 / $70,000 = 0.0428 JBTC |
|
|
105
|
+
> Or open your wallet app → WalletConnect → paste this URI: \`wc:...\`
|
|
94
106
|
|
|
95
|
-
|
|
107
|
+
CRITICAL: You MUST use markdown image syntax \`\`. NEVER post the URL as plain text. NEVER print \`qrCodeText\`. NEVER generate your own QR code.
|
|
96
108
|
|
|
97
|
-
|
|
98
|
-
|-----------|-------------|-------------|
|
|
99
|
-
| "long with $60 USDC margin at 50x" | already the margin | \`--margin 60\` |
|
|
100
|
-
| "open a $3,000 notional position at 50x" | margin = 3000 / 50 = 60 | \`--margin 60\` |
|
|
101
|
-
| "long 0.1 BTC at 50x" | margin = (0.1 × current_price) / 50 | \`--margin <result>\` |
|
|
109
|
+
After sending, wait for the user to scan and sign. Do not interrupt the CLI process.
|
|
102
110
|
|
|
103
|
-
|
|
111
|
+
### Line 2: Init Complete
|
|
104
112
|
|
|
105
|
-
|
|
113
|
+
\`\`\`json
|
|
114
|
+
{"success":true, "message":"Vault initialized successfully", ...}
|
|
115
|
+
\`\`\`
|
|
106
116
|
|
|
107
|
-
|
|
108
|
-
|-------|---------------|
|
|
109
|
-
| \`margin\` | Actual collateral deposited (e.g. 60 USDC) — matches what you passed to \`--margin\` |
|
|
110
|
-
| \`size\` | Position size in underlying asset (e.g. 0.0428 JBTC) |
|
|
111
|
-
| \`leverage\` | Leverage multiplier (e.g. 50) |
|
|
112
|
-
| \`entryPriceUsd\` | Entry price when position was opened |
|
|
117
|
+
Init is complete. Tell the user: "Vault initialized successfully. You can now deposit and trade."
|
|
113
118
|
|
|
114
|
-
|
|
119
|
+
The delegation wallet is saved to \`~/.jaspervault/keys.json\` and vault addresses to \`~/.jaspervault/profile.json\`. Subsequent commands use these automatically — no wallet interaction needed.
|
|
115
120
|
|
|
116
|
-
|
|
121
|
+
## Deposit via WalletConnect (Optional)
|
|
117
122
|
|
|
118
|
-
|
|
123
|
+
If the user wants to deposit:
|
|
119
124
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
| 3. Compute PnL (LONG) | \`unrealizedPnL = size × (currentPrice − entryPrice)\` |
|
|
125
|
-
| 3. Compute PnL (SHORT) | \`unrealizedPnL = size × (entryPrice − currentPrice)\` |
|
|
126
|
-
| 4. PnL percentage | \`pnlPercent = unrealizedPnL / margin × 100%\` |
|
|
127
|
-
| 5. Effective leverage loss | \`leveragedPnlPercent = priceChangePercent × leverage\` |
|
|
125
|
+
1. **Get unsigned transactions:**
|
|
126
|
+
\`\`\`bash
|
|
127
|
+
jv deposit info --wallet <walletAddress> --token jusdc --amount 100
|
|
128
|
+
\`\`\`
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
- PnL = 0.0428 × (71000 − 70000) = +$42.80
|
|
131
|
-
- PnL% = 42.80 / 60 = +71.3%
|
|
130
|
+
2. **Output contains \`transactions\` array.** Each \`tx\` has \`to\`, \`data\`, \`value\`, \`chainId\`. Send each via WalletConnect \`eth_sendTransaction\` to the user's wallet. Execute in order (approve first if present, then transferRemote).
|
|
132
131
|
|
|
133
|
-
|
|
132
|
+
3. **After transactions confirm**, poll for arrival:
|
|
133
|
+
\`\`\`bash
|
|
134
|
+
jv deposit poll --recipient <recipient> --token jusdc
|
|
135
|
+
\`\`\`
|
|
136
|
+
Use the \`recipient\` from step 1 output.
|
|
134
137
|
|
|
135
|
-
|
|
138
|
+
4. Tell the user: "Deposit completed. Your tokens have arrived on JasperVault."
|
|
139
|
+
`;
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
// references/trading.md — margin, orders, reduce/close, TP/SL, price
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
const TRADING_REFERENCE = `# Trading Commands
|
|
136
144
|
|
|
137
|
-
|
|
145
|
+
## Getting Market Price
|
|
138
146
|
|
|
139
|
-
|
|
147
|
+
MUST use before any price-dependent operation (opening position by asset quantity, calculating PnL).
|
|
140
148
|
|
|
141
149
|
\`\`\`bash
|
|
142
|
-
# Get current JBTC price
|
|
143
150
|
jv price --symbol JBTC --pretty
|
|
144
|
-
|
|
145
|
-
# Get current CBBTC price
|
|
146
151
|
jv price --symbol CBBTC --pretty
|
|
147
152
|
\`\`\`
|
|
148
153
|
|
|
@@ -153,9 +158,26 @@ Output:
|
|
|
153
158
|
|
|
154
159
|
Use the \`price\` field (human-readable USD value) for display and calculations. This command does NOT require vault initialization — it can be run anytime.
|
|
155
160
|
|
|
156
|
-
|
|
161
|
+
## How \`--margin\` Works
|
|
162
|
+
|
|
163
|
+
\`--margin\` = the **actual collateral (margin) in USDC** you deposit. The CLI internally multiplies by leverage to compute the notional position size.
|
|
164
|
+
|
|
165
|
+
| Concept | Formula | Example |
|
|
166
|
+
|---------|---------|---------|
|
|
167
|
+
| Notional value | \`margin × leverage\` | 60 USDC × 50x = $3,000 |
|
|
168
|
+
| Position size | \`notional / current_price\` | $3,000 / $70,000 = 0.0428 JBTC |
|
|
169
|
+
|
|
170
|
+
### Translating user intent to \`--margin\`:
|
|
157
171
|
|
|
158
|
-
|
|
172
|
+
| User says | Calculation | Pass to CLI |
|
|
173
|
+
|-----------|-------------|-------------|
|
|
174
|
+
| "long with $60 USDC margin at 50x" | already the margin | \`--margin 60\` |
|
|
175
|
+
| "open a $3,000 notional position at 50x" | margin = 3000 / 50 = 60 | \`--margin 60\` |
|
|
176
|
+
| "long 0.1 BTC at 50x" | margin = (0.1 × current_price) / 50 | \`--margin <result>\` |
|
|
177
|
+
|
|
178
|
+
CRITICAL: When the user specifies an asset amount (e.g. "0.1 BTC"), you MUST first run \`jv price --symbol JBTC --pretty\` to get the current price, then compute \`notional = size × price\`, then \`margin = notional / leverage\`.
|
|
179
|
+
|
|
180
|
+
## Creating Orders
|
|
159
181
|
|
|
160
182
|
\`\`\`bash
|
|
161
183
|
# Market order: Long JBTC, 60 USDC margin at 50x (= $3,000 notional)
|
|
@@ -172,99 +194,114 @@ The CLI signs the order internally using the delegation wallet. No pre-signed pa
|
|
|
172
194
|
|
|
173
195
|
On success, a market order returns \`jobId\`; a limit order returns \`limitOrderId\`.
|
|
174
196
|
|
|
175
|
-
|
|
197
|
+
## Reducing / Closing a Position
|
|
176
198
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
**Step-by-step for reducing a position:**
|
|
199
|
+
Create an **opposite-side order** with the margin portion you want to close. The system automatically detects existing positions and performs a partial close.
|
|
180
200
|
|
|
181
201
|
1. Query current position: \`jv orders list --pretty\`
|
|
182
|
-
2.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
3. Create opposite-side order with that margin value
|
|
186
|
-
|
|
187
|
-
**Example: Reduce a LONG position by half**
|
|
202
|
+
2. Read the \`margin\` field directly from output (e.g. 60 USDC)
|
|
203
|
+
3. To close half: \`close_margin = margin / 2\` (e.g. 30 USDC)
|
|
204
|
+
4. Create opposite-side order with that margin value
|
|
188
205
|
|
|
189
|
-
|
|
190
|
-
- margin: 60 USDC, leverage: 50, size: 0.0428 JBTC
|
|
191
|
-
|
|
192
|
-
To close half (30 USDC margin → $1,500 notional):
|
|
206
|
+
**Reduce LONG by half (30 USDC margin):**
|
|
193
207
|
\`\`\`bash
|
|
194
208
|
jv order create --side short --symbol JBTC --margin 30 --leverage 50 --network jaspervault
|
|
195
209
|
\`\`\`
|
|
196
210
|
|
|
197
|
-
**
|
|
211
|
+
**Close entire LONG (60 USDC margin):**
|
|
198
212
|
\`\`\`bash
|
|
199
213
|
jv order create --side short --symbol JBTC --margin 60 --leverage 50 --network jaspervault
|
|
200
214
|
\`\`\`
|
|
201
215
|
|
|
202
216
|
IMPORTANT: The \`--margin\` for reduction = the margin portion you want to close (read directly from \`jv orders list\` output \`margin\` field).
|
|
203
217
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
When the user wants to **set take-profit**, **set TP**, or **protect profits**:
|
|
218
|
+
## Setting Take-Profit
|
|
207
219
|
|
|
208
220
|
\`\`\`bash
|
|
209
221
|
jv tp set --order-id <orderId> --price <usdc_price> --symbol <symbol> --network jaspervault
|
|
210
222
|
\`\`\`
|
|
211
223
|
|
|
212
|
-
Example:
|
|
213
|
-
\`\`\`bash
|
|
214
|
-
jv tp set --order-id 99 --price 105000 --symbol JBTC --network jaspervault
|
|
215
|
-
\`\`\`
|
|
224
|
+
Example: \`jv tp set --order-id 99 --price 105000 --symbol JBTC --network jaspervault\`
|
|
216
225
|
|
|
217
226
|
Returns \`limitOrderId\` on success.
|
|
218
227
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
When the user wants to **set stop-loss**, **set SL**, or **limit downside risk**:
|
|
228
|
+
## Setting Stop-Loss
|
|
222
229
|
|
|
223
230
|
\`\`\`bash
|
|
224
231
|
jv sl set --order-id <orderId> --price <usdc_price> --symbol <symbol> --network jaspervault
|
|
225
232
|
\`\`\`
|
|
226
233
|
|
|
227
|
-
Example:
|
|
228
|
-
\`\`\`bash
|
|
229
|
-
jv sl set --order-id 99 --price 90000 --symbol JBTC --network jaspervault
|
|
230
|
-
\`\`\`
|
|
234
|
+
Example: \`jv sl set --order-id 99 --price 90000 --symbol JBTC --network jaspervault\`
|
|
231
235
|
|
|
232
236
|
Returns \`limitOrderId\` on success.
|
|
233
237
|
|
|
234
|
-
|
|
238
|
+
## PPO Hedge Protection
|
|
235
239
|
|
|
236
|
-
|
|
240
|
+
Add \`--ppo\` to any \`jv order create\` command to enable automatic hedge option protection. PPO hedges the entire position automatically — the user does NOT specify how much to hedge.
|
|
237
241
|
|
|
238
|
-
|
|
239
|
-
jv order create-option --order-id <perps_order_id> --data '<signed_option_payload>'
|
|
240
|
-
\`\`\`
|
|
242
|
+
**Options:**
|
|
241
243
|
|
|
242
|
-
|
|
244
|
+
| Flag | Values | Default | Description |
|
|
245
|
+
|------|--------|---------|-------------|
|
|
246
|
+
| \`--ppo\` | (boolean) | off | Enable PPO |
|
|
247
|
+
| \`--ppo-expire\` | \`30m\` or \`8h\` | \`30m\` | Option duration |
|
|
248
|
+
| \`--ppo-category\` | \`ATM\` or \`OTM\` | \`ATM\` | ATM = strike at market price; OTM = strike offset |
|
|
249
|
+
| \`--ppo-tier\` | \`1-5\` | (required for OTM) | OTM offset: 1=0.1%, 2=0.2%, 3=0.3%, 4=0.4%, 5=0.5% |
|
|
243
250
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
When the user asks about **order execution status**, **is my order done**, or **transaction result**:
|
|
251
|
+
**Examples:**
|
|
247
252
|
|
|
248
253
|
\`\`\`bash
|
|
249
|
-
|
|
254
|
+
# ATM protection, 30 min (default)
|
|
255
|
+
jv order create --side long --symbol JBTC --margin 60 --leverage 50 --ppo --network jaspervault
|
|
256
|
+
|
|
257
|
+
# ATM protection, 8 hours
|
|
258
|
+
jv order create --side long --symbol JBTC --margin 60 --leverage 50 --ppo --ppo-expire 8h --network jaspervault
|
|
259
|
+
|
|
260
|
+
# OTM protection, tier 5 (0.5% offset), 30 min
|
|
261
|
+
jv order create --side long --symbol JBTC --margin 60 --leverage 50 --ppo --ppo-category OTM --ppo-tier 5 --network jaspervault
|
|
262
|
+
|
|
263
|
+
# OTM protection, tier 3 (0.3% offset), 8 hours
|
|
264
|
+
jv order create --side short --symbol JBTC --margin 60 --leverage 50 --ppo --ppo-expire 8h --ppo-category OTM --ppo-tier 3 --network jaspervault
|
|
250
265
|
\`\`\`
|
|
251
266
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
267
|
+
**AI agent behavior when user wants OTM:**
|
|
268
|
+
|
|
269
|
+
1. First run \`jv price --symbol JBTC --pretty\` to get current price
|
|
270
|
+
2. Calculate strike for each tier based on position side:
|
|
271
|
+
- LONG (PUT hedge): \`strike = price × (1 - tier_ratio)\`
|
|
272
|
+
- SHORT (CALL hedge): \`strike = price × (1 + tier_ratio)\`
|
|
273
|
+
3. Present options: "Tier 1: $87,208 (0.1%), Tier 2: $87,121 (0.2%), ..., Tier 5: $86,860 (0.5%)"
|
|
274
|
+
4. User picks tier → use \`--ppo-tier N\`
|
|
256
275
|
|
|
257
|
-
|
|
276
|
+
**Intent mapping:**
|
|
277
|
+
|
|
278
|
+
- User says "hedge" / "protect" / "PPO" / "对冲" / "加保护" → add \`--ppo\`
|
|
279
|
+
- User says "8 hour" / "8小时" → \`--ppo-expire 8h\`
|
|
280
|
+
- User says "OTM" / "价外" → \`--ppo-category OTM\`, then present tier options
|
|
281
|
+
- User says "ATM" / "平价" or nothing → default ATM, 30 min
|
|
282
|
+
`;
|
|
283
|
+
// ---------------------------------------------------------------------------
|
|
284
|
+
// references/queries.md — positions, job status, limit orders, output, errors
|
|
285
|
+
// ---------------------------------------------------------------------------
|
|
286
|
+
const QUERIES_REFERENCE = `# Queries, Output Interpretation & Error Handling
|
|
258
287
|
|
|
259
|
-
|
|
288
|
+
## Querying Positions
|
|
260
289
|
|
|
261
290
|
\`\`\`bash
|
|
262
|
-
# List
|
|
291
|
+
# List active positions (default — use for "current positions")
|
|
263
292
|
jv orders list --pretty
|
|
264
293
|
|
|
265
294
|
# Filter by side
|
|
266
295
|
jv orders list --position-side LONG
|
|
267
296
|
|
|
297
|
+
# Include closed/historical orders
|
|
298
|
+
jv orders list --all --pretty
|
|
299
|
+
|
|
300
|
+
# Filter by time range
|
|
301
|
+
jv orders list --all --since 7d --pretty
|
|
302
|
+
jv orders list --since 1w --pretty
|
|
303
|
+
jv orders list --all --since 2025-01-01 --until 2025-01-31 --pretty
|
|
304
|
+
|
|
268
305
|
# Get a specific position
|
|
269
306
|
jv orders get <orderId>
|
|
270
307
|
|
|
@@ -272,31 +309,52 @@ jv orders get <orderId>
|
|
|
272
309
|
jv orders stats
|
|
273
310
|
\`\`\`
|
|
274
311
|
|
|
275
|
-
|
|
312
|
+
**Key output fields (human-readable, pre-converted from wei):**
|
|
276
313
|
|
|
277
|
-
|
|
314
|
+
| Field | Description |
|
|
315
|
+
|-------|-------------|
|
|
316
|
+
| \`margin\` | Margin deposited in USDC (e.g. \`"60.000000"\`) |
|
|
317
|
+
| \`size\` | Position size in underlying asset (e.g. \`"0.04386000"\` JBTC) |
|
|
318
|
+
| \`entryPriceUsd\` | Entry price in USD (e.g. \`"68476.000000000000000000"\`) |
|
|
319
|
+
| \`strikeAmountUsd\` | Strike amount in USD |
|
|
320
|
+
| \`leverage\` | Leverage multiplier (e.g. \`"50"\`) |
|
|
321
|
+
| \`createdTime\` | Creation time in ISO 8601 format |
|
|
322
|
+
| \`positionSide\` | \`"LONG"\` or \`"SHORT"\` |
|
|
323
|
+
| \`isActive\` | \`true\` = open position, \`false\` = closed |
|
|
324
|
+
| \`id\` | Order ID (use for TP/SL commands) |
|
|
278
325
|
|
|
279
|
-
|
|
280
|
-
# List limit orders for a wallet
|
|
281
|
-
jv limit-order list --wallet <address>
|
|
326
|
+
To calculate notional from output: \`notional = margin × leverage\` (or \`size × current_price\`)
|
|
282
327
|
|
|
283
|
-
|
|
284
|
-
jv limit-order list --wallet <address> --status PENDING
|
|
328
|
+
**Pagination:** use \`--page\` and \`--limit\` (e.g. \`jv orders list --page 2 --limit 10\`).
|
|
285
329
|
|
|
286
|
-
|
|
287
|
-
jv limit-order status <limitOrderId>
|
|
330
|
+
## Calculating Unrealized PnL
|
|
288
331
|
|
|
289
|
-
|
|
290
|
-
jv limit-order cancel <limitOrderId>
|
|
291
|
-
\`\`\`
|
|
332
|
+
When the user asks about profit/loss, portfolio value, or position health, you MUST fetch the current price first:
|
|
292
333
|
|
|
293
|
-
|
|
334
|
+
| Step | Formula |
|
|
335
|
+
|------|---------|
|
|
336
|
+
| 1. Get current price | \`jv price --symbol JBTC --pretty\` → read \`price\` field |
|
|
337
|
+
| 2. Get position data | \`jv orders list --pretty\` → read \`size\`, \`entryPriceUsd\`, \`margin\`, \`positionSide\` |
|
|
338
|
+
| 3. Compute PnL (LONG) | \`unrealizedPnL = size × (currentPrice − entryPrice)\` |
|
|
339
|
+
| 3. Compute PnL (SHORT) | \`unrealizedPnL = size × (entryPrice − currentPrice)\` |
|
|
340
|
+
| 4. PnL percentage | \`pnlPercent = unrealizedPnL / margin × 100%\` |
|
|
341
|
+
| 5. Effective leverage | \`leveragedPnlPercent = priceChangePercent × leverage\` |
|
|
294
342
|
|
|
295
|
-
|
|
343
|
+
Example: LONG 0.0428 JBTC, entry $70,000, current $71,000, margin 60 USDC
|
|
344
|
+
- PnL = 0.0428 × (71000 − 70000) = +$42.80
|
|
345
|
+
- PnL% = 42.80 / 60 = +71.3%
|
|
346
|
+
|
|
347
|
+
IMPORTANT: NEVER guess or estimate the current price. ALWAYS use \`jv price\` to get the real-time price.
|
|
348
|
+
|
|
349
|
+
## Job Status
|
|
350
|
+
|
|
351
|
+
\`\`\`bash
|
|
352
|
+
jv job status <jobId> --pretty
|
|
353
|
+
\`\`\`
|
|
296
354
|
|
|
297
|
-
|
|
355
|
+
Key fields: \`status\` ("completed", "failed", "active", "waiting"), \`result.transactionHash\`, \`result.operationType\` (CREATE, ADD_SIZE, CLOSE_SIZE, etc.).
|
|
298
356
|
|
|
299
|
-
|
|
357
|
+
## Market Order Output (IMPORTANT — two JSON lines)
|
|
300
358
|
|
|
301
359
|
\`jv order create\` for market orders prints **two JSON lines sequentially**:
|
|
302
360
|
|
|
@@ -310,45 +368,65 @@ All commands output JSON to stdout. Extract key fields to compose user-friendly
|
|
|
310
368
|
{"jobId":"MARKET_ORDER_xxx","status":"completed","transactionHash":"0x..."}
|
|
311
369
|
\`\`\`
|
|
312
370
|
|
|
313
|
-
**How to determine success:**
|
|
314
|
-
|
|
315
|
-
- If \`status === "completed"\` → the order is DONE. It succeeded on-chain.
|
|
316
|
-
- If \`status === "failed"\` → the order failed. Report the error.
|
|
317
|
-
- If \`status === "timeout"\` → timed out waiting; use \`jv job status <jobId>\` to check later.
|
|
318
|
-
|
|
319
371
|
**CRITICAL RULES after order execution:**
|
|
320
372
|
|
|
321
|
-
1.
|
|
322
|
-
2.
|
|
323
|
-
3.
|
|
324
|
-
4.
|
|
373
|
+
1. If \`status === "completed"\` → the order IS executed. Do NOT retry or place another order.
|
|
374
|
+
2. If \`status === "failed"\` → report the error.
|
|
375
|
+
3. If \`status === "timeout"\` → use \`jv job status <jobId>\` to check later.
|
|
376
|
+
4. The \`operation\` field (if present) contains raw on-chain data in wei format — do NOT try to interpret it.
|
|
377
|
+
5. **To verify the actual position**, always run \`jv orders list --pretty\` and read the human-readable fields.
|
|
378
|
+
6. Report to the user: "Order executed successfully. Tx: {transactionHash}. Let me check your updated position..." then run \`jv orders list --pretty\`.
|
|
325
379
|
|
|
326
|
-
**Limit order
|
|
380
|
+
**Limit order output:**
|
|
327
381
|
\`\`\`json
|
|
328
382
|
{"success":true,"orderType":"limit","limitOrderId":"0x..."}
|
|
329
383
|
\`\`\`
|
|
330
384
|
Tell the user: "Limit order placed. ID: {limitOrderId}."
|
|
331
385
|
|
|
332
|
-
##
|
|
386
|
+
## Managing Limit Orders
|
|
333
387
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
-
|
|
388
|
+
\`\`\`bash
|
|
389
|
+
# List limit orders for a wallet
|
|
390
|
+
jv limit-order list --wallet <address>
|
|
337
391
|
|
|
338
|
-
|
|
392
|
+
# Filter by status
|
|
393
|
+
jv limit-order list --wallet <address> --status PENDING
|
|
339
394
|
|
|
340
|
-
|
|
395
|
+
# Check a specific limit order
|
|
396
|
+
jv limit-order status <limitOrderId>
|
|
341
397
|
|
|
342
|
-
|
|
343
|
-
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
398
|
+
# Cancel a limit order
|
|
399
|
+
jv limit-order cancel <limitOrderId>
|
|
400
|
+
\`\`\`
|
|
401
|
+
|
|
402
|
+
Possible statuses: PENDING, TRIGGERED, EXECUTING, COMPLETED, FAILED, EXPIRED, CANCELLED.
|
|
403
|
+
|
|
404
|
+
## Error Handling
|
|
405
|
+
|
|
406
|
+
| Exit Code | Meaning | Action |
|
|
407
|
+
|-----------|---------|--------|
|
|
408
|
+
| 1 | Configuration error (e.g. delegation key not found) | Run \`jv vault init-wc\` first |
|
|
409
|
+
| 2 | Network/HTTP error | Tell user the service may be unreachable |
|
|
410
|
+
| 3 | Business error (duplicate order, invalid params) | Read stderr, relay message |
|
|
411
|
+
|
|
412
|
+
When an error occurs, stderr contains the error message. Never expose raw stack traces or internal URLs to the user.
|
|
413
|
+
`;
|
|
414
|
+
// ---------------------------------------------------------------------------
|
|
415
|
+
// scripts/check-init.sh
|
|
416
|
+
// ---------------------------------------------------------------------------
|
|
417
|
+
const CHECK_INIT_SCRIPT = `#!/usr/bin/env bash
|
|
418
|
+
# Quick vault initialization check — exits 0 if ready, non-zero otherwise
|
|
419
|
+
jv orders list --pretty 2>/dev/null
|
|
420
|
+
exit $?
|
|
421
|
+
`;
|
|
422
|
+
// ---------------------------------------------------------------------------
|
|
423
|
+
// Platform-specific frontmatter
|
|
424
|
+
// ---------------------------------------------------------------------------
|
|
347
425
|
function getOpenClawFrontmatter() {
|
|
348
426
|
return `---
|
|
349
427
|
name: jasper-vault-cli
|
|
350
|
-
description: "Trade perpetual contracts (perps) on JasperVault — open
|
|
351
|
-
trigger: "jaspervault|jasper vault|jasper trading|jv trade|jv order|在jasper交易|jasper
|
|
428
|
+
description: "Trade perpetual contracts (perps) on JasperVault — open/close positions, set TP/SL, manage limit orders, deposit, and query portfolio via the \`jv\` CLI. Initialize wallet via WalletConnect QR scan (no private key needed). 在 JasperVault 上交易永续合约 — 做多做空、开仓平仓、止盈止损、限价单、持仓查询、充值,使用 WalletConnect 扫码初始化(无需私钥)。"
|
|
429
|
+
trigger: "jaspervault|jasper vault|jasper trading|jv|jv trade|jv order|在jasper交易|jasper 交易|初始化钱包|连接钱包|开仓|平仓|做多|做空|止盈|止损|查看持仓|永续合约"
|
|
352
430
|
tools: [shell]
|
|
353
431
|
metadata:
|
|
354
432
|
openclaw:
|
|
@@ -361,24 +439,39 @@ metadata:
|
|
|
361
439
|
function getClaudeFrontmatter() {
|
|
362
440
|
return `---
|
|
363
441
|
name: jasper-vault-cli
|
|
364
|
-
description: Trade perpetual contracts
|
|
442
|
+
description: "Trade perpetual contracts (perps) on JasperVault — open/close positions, set TP/SL, manage limit orders, deposit, and query portfolio via the \`jv\` CLI. Initialize wallet via WalletConnect QR scan (no private key needed)."
|
|
365
443
|
---
|
|
366
444
|
`;
|
|
367
445
|
}
|
|
446
|
+
// ---------------------------------------------------------------------------
|
|
447
|
+
// Public API
|
|
448
|
+
// ---------------------------------------------------------------------------
|
|
368
449
|
/**
|
|
369
|
-
* Build platform-specific
|
|
450
|
+
* Build platform-specific skill file tree.
|
|
451
|
+
* Returns a Record mapping relative file paths to their content.
|
|
370
452
|
* @param platform - One of: openclaw, cursor, claude
|
|
371
453
|
*/
|
|
372
454
|
export function buildSkillContent(platform) {
|
|
455
|
+
let skillMd;
|
|
373
456
|
switch (platform) {
|
|
374
457
|
case 'openclaw':
|
|
375
|
-
|
|
458
|
+
skillMd = getOpenClawFrontmatter() + '\n# JasperVault Trading Skill\n\n' + SKILL_CORE_BODY;
|
|
459
|
+
break;
|
|
376
460
|
case 'claude':
|
|
377
|
-
|
|
461
|
+
skillMd = getClaudeFrontmatter() + '\n# JasperVault Trading Skill\n\n' + SKILL_CORE_BODY;
|
|
462
|
+
break;
|
|
378
463
|
case 'cursor':
|
|
379
|
-
|
|
464
|
+
skillMd = '# jasper-vault-cli\n\n' + SKILL_CORE_BODY;
|
|
465
|
+
break;
|
|
380
466
|
default:
|
|
381
467
|
throw new Error(`Unknown platform: ${platform}`);
|
|
382
468
|
}
|
|
469
|
+
return {
|
|
470
|
+
'SKILL.md': skillMd,
|
|
471
|
+
'references/onboarding.md': ONBOARDING_REFERENCE,
|
|
472
|
+
'references/trading.md': TRADING_REFERENCE,
|
|
473
|
+
'references/queries.md': QUERIES_REFERENCE,
|
|
474
|
+
'scripts/check-init.sh': CHECK_INIT_SCRIPT,
|
|
475
|
+
};
|
|
383
476
|
}
|
|
384
477
|
//# sourceMappingURL=skill-body.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-body.js","sourceRoot":"","sources":["../../../src/templates/skill-body.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"skill-body.js","sourceRoot":"","sources":["../../../src/templates/skill-body.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,IAAI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oB;IAC3B,OAAO;;;;CAIR,CAAC;AACF,CAAC;AAED,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IAChD,IAAI,OAAe,CAAC;IAEpB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,UAAU;YACb,OAAO,GAAG,sBAAsB,EAAE,GAAG,mCAAmC,GAAG,eAAe,CAAC;YAC3F,MAAM;QACR,KAAK,QAAQ;YACX,OAAO,GAAG,oBAAoB,EAAE,GAAG,mCAAmC,GAAG,eAAe,CAAC;YACzF,MAAM;QACR,KAAK,QAAQ;YACX,OAAO,GAAG,wBAAwB,GAAG,eAAe,CAAC;YACrD,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,OAAO;QACL,UAAU,EAAE,OAAO;QACnB,0BAA0B,EAAE,oBAAoB;QAChD,uBAAuB,EAAE,iBAAiB;QAC1C,uBAAuB,EAAE,iBAAiB;QAC1C,uBAAuB,EAAE,iBAAiB;KAC3C,CAAC;AACJ,CAAC"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PPOSettings } from '../types.js';
|
|
2
|
+
export declare const PPO_TIER_RATIOS: Record<number, number>;
|
|
3
|
+
export interface PpoResult {
|
|
4
|
+
limitType: number;
|
|
5
|
+
ppoSettings: PPOSettings;
|
|
6
|
+
}
|
|
7
|
+
export declare function parsePpoOptions(opts: {
|
|
8
|
+
ppo?: boolean;
|
|
9
|
+
ppoExpire?: string;
|
|
10
|
+
ppoCategory?: string;
|
|
11
|
+
ppoTier?: string;
|
|
12
|
+
}): PpoResult;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { exitWithError, EXIT_CODES } from './output.js';
|
|
2
|
+
export const PPO_TIER_RATIOS = {
|
|
3
|
+
1: 0.001,
|
|
4
|
+
2: 0.002,
|
|
5
|
+
3: 0.003,
|
|
6
|
+
4: 0.004,
|
|
7
|
+
5: 0.005,
|
|
8
|
+
};
|
|
9
|
+
const PPO_EXPIRE_MAP = {
|
|
10
|
+
'30m': '1800',
|
|
11
|
+
'8h': '28800',
|
|
12
|
+
};
|
|
13
|
+
export function parsePpoOptions(opts) {
|
|
14
|
+
if (!opts.ppo) {
|
|
15
|
+
return { limitType: 0, ppoSettings: { optionExpireTime: '0' } };
|
|
16
|
+
}
|
|
17
|
+
const expire = opts.ppoExpire ?? '30m';
|
|
18
|
+
const expireSeconds = PPO_EXPIRE_MAP[expire];
|
|
19
|
+
if (!expireSeconds) {
|
|
20
|
+
exitWithError(`--ppo-expire must be 30m or 8h (got "${expire}")`, EXIT_CODES.CONFIG_ERROR);
|
|
21
|
+
}
|
|
22
|
+
const category = (opts.ppoCategory?.toUpperCase() ?? 'ATM');
|
|
23
|
+
if (category !== 'ATM' && category !== 'OTM') {
|
|
24
|
+
exitWithError(`--ppo-category must be ATM or OTM (got "${opts.ppoCategory}")`, EXIT_CODES.CONFIG_ERROR);
|
|
25
|
+
}
|
|
26
|
+
const ppoSettings = {
|
|
27
|
+
optionExpireTime: expireSeconds,
|
|
28
|
+
optionCategory: category,
|
|
29
|
+
};
|
|
30
|
+
if (category === 'OTM') {
|
|
31
|
+
if (!opts.ppoTier) {
|
|
32
|
+
exitWithError('OTM requires --ppo-tier (1-5)', EXIT_CODES.CONFIG_ERROR);
|
|
33
|
+
}
|
|
34
|
+
const tier = parseInt(opts.ppoTier, 10);
|
|
35
|
+
if (!(tier >= 1 && tier <= 5)) {
|
|
36
|
+
exitWithError(`--ppo-tier must be 1-5 (got "${opts.ppoTier}")`, EXIT_CODES.CONFIG_ERROR);
|
|
37
|
+
}
|
|
38
|
+
ppoSettings.ratio = PPO_TIER_RATIOS[tier];
|
|
39
|
+
}
|
|
40
|
+
else if (opts.ppoTier) {
|
|
41
|
+
console.error('Warning: --ppo-tier is ignored for ATM options');
|
|
42
|
+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