@miramarket/cli 1.8.0 → 1.9.0

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 (55) hide show
  1. package/README.md +1 -0
  2. package/dist/{chunk-UCB7XSQE.js → chunk-CUQEGUAG.js} +726 -264
  3. package/dist/{chunk-NKZGADKF.js → chunk-GVMZCXYH.js} +2 -2
  4. package/dist/commands/account/accept-policies.js +17 -17
  5. package/dist/commands/account/capital.js +7 -7
  6. package/dist/commands/account/policies.js +7 -7
  7. package/dist/commands/account/setup.js +10 -10
  8. package/dist/commands/account/status.js +5 -5
  9. package/dist/commands/account/withdraw.js +12 -12
  10. package/dist/commands/auth/status.js +7 -7
  11. package/dist/commands/balance.js +8 -8
  12. package/dist/commands/bridge/execute.js +9 -9
  13. package/dist/commands/bridge/quote.js +5 -5
  14. package/dist/commands/bridge/status.js +5 -5
  15. package/dist/commands/edit.js +5 -5
  16. package/dist/commands/init.js +22 -22
  17. package/dist/commands/login.js +7 -7
  18. package/dist/commands/logout.js +4 -4
  19. package/dist/commands/markets/list.js +5 -5
  20. package/dist/commands/markets/orderbook.js +5 -5
  21. package/dist/commands/markets/prices-history.js +6 -6
  22. package/dist/commands/markets/resolve.js +5 -5
  23. package/dist/commands/markets/search.js +5 -5
  24. package/dist/commands/markets/show.js +5 -5
  25. package/dist/commands/order/cancel.js +7 -7
  26. package/dist/commands/order/status.js +9 -9
  27. package/dist/commands/perps/history.js +5 -5
  28. package/dist/commands/perps/list.js +5 -5
  29. package/dist/commands/perps/positions.js +5 -5
  30. package/dist/commands/perps/show.js +5 -5
  31. package/dist/commands/portfolio.js +9 -9
  32. package/dist/commands/post.js +6 -6
  33. package/dist/commands/preview.js +5 -5
  34. package/dist/commands/schema.js +3 -3
  35. package/dist/commands/status.js +6 -6
  36. package/dist/commands/stocks/history.js +5 -5
  37. package/dist/commands/stocks/list.js +5 -5
  38. package/dist/commands/stocks/show.js +5 -5
  39. package/dist/commands/strategies/approval.js +5 -5
  40. package/dist/commands/strategies/cancel.js +6 -6
  41. package/dist/commands/strategies/delete.js +7 -7
  42. package/dist/commands/strategies/exit.js +7 -7
  43. package/dist/commands/strategies/generate.js +13 -13
  44. package/dist/commands/strategies/list.js +6 -6
  45. package/dist/commands/strategies/pull.js +5 -5
  46. package/dist/commands/strategies/rename.js +6 -6
  47. package/dist/commands/strategies/runs.js +7 -7
  48. package/dist/commands/strategies/show.js +22 -13
  49. package/dist/commands/strategies/update.js +7 -7
  50. package/dist/commands/strategies/watch.js +10 -8
  51. package/dist/commands/trade.js +49 -14
  52. package/dist/commands/update.js +8 -8
  53. package/dist/commands/validate.js +7 -7
  54. package/oclif.manifest.json +1 -1
  55. package/package.json +3 -3
@@ -3,16 +3,16 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkUCB7XSQEjs = require('../../chunk-UCB7XSQE.js');
6
+ var _chunkCUQEGUAGjs = require('../../chunk-CUQEGUAG.js');
7
7
 
8
8
 
9
9
  var _chunkQGM4M3NIjs = require('../../chunk-QGM4M3NI.js');
10
10
 
11
11
  // src/commands/strategies/rename.ts
12
12
  var _core = require('@oclif/core');
13
- var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
14
- var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
15
- var StrategiesRename = class _StrategiesRename extends _chunkUCB7XSQEjs.BaseCommand {
13
+ var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
14
+ var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
15
+ var StrategiesRename = class _StrategiesRename extends _chunkCUQEGUAGjs.BaseCommand {
16
16
  static {
17
17
  this.description = "Rename a strategy.";
18
18
  }
@@ -33,12 +33,12 @@ var StrategiesRename = class _StrategiesRename extends _chunkUCB7XSQEjs.BaseComm
33
33
  async run() {
34
34
  const { args, flags } = await this.parse(_StrategiesRename);
35
35
  (0, import_miramarket_client2.requireAuth)();
36
- await _chunkUCB7XSQEjs.withSpinner.call(void 0,
36
+ await _chunkCUQEGUAGjs.withSpinner.call(void 0,
37
37
  "Renaming strategy...",
38
38
  async () => (0, import_miramarket_client.renameStrategy)(await (0, import_miramarket_client.getConvexClient)(), args.strategyId, args.name),
39
39
  { json: flags.json }
40
40
  );
41
- _chunkUCB7XSQEjs.printResult.call(void 0,
41
+ _chunkCUQEGUAGjs.printResult.call(void 0,
42
42
  {
43
43
  ok: true,
44
44
  command: "strategies rename",
@@ -6,16 +6,16 @@ var _chunkP7NT6RRJjs = require('../../chunk-P7NT6RRJ.js');
6
6
 
7
7
 
8
8
 
9
- var _chunkUCB7XSQEjs = require('../../chunk-UCB7XSQE.js');
9
+ var _chunkCUQEGUAGjs = require('../../chunk-CUQEGUAG.js');
10
10
 
11
11
 
12
12
  var _chunkQGM4M3NIjs = require('../../chunk-QGM4M3NI.js');
13
13
 
14
14
  // src/commands/strategies/runs.ts
15
15
  var _core = require('@oclif/core');
16
- var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
17
- var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
18
- var import_miramarket_client3 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
16
+ var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
17
+ var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
18
+ var import_miramarket_client3 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
19
19
  function summarizeRun(run) {
20
20
  return {
21
21
  id: run._id,
@@ -32,7 +32,7 @@ function summarizeRun(run) {
32
32
  settlementCount: _nullishCoalesce(_optionalChain([run, 'access', _3 => _3.settlement, 'optionalAccess', _4 => _4.length]), () => ( 0))
33
33
  };
34
34
  }
35
- var StrategiesRuns = class _StrategiesRuns extends _chunkUCB7XSQEjs.BaseCommand {
35
+ var StrategiesRuns = class _StrategiesRuns extends _chunkCUQEGUAGjs.BaseCommand {
36
36
  static {
37
37
  this.description = "List run history for a strategy.";
38
38
  }
@@ -53,7 +53,7 @@ var StrategiesRuns = class _StrategiesRuns extends _chunkUCB7XSQEjs.BaseCommand
53
53
  async run() {
54
54
  const { args, flags } = await this.parse(_StrategiesRuns);
55
55
  (0, import_miramarket_client2.requireAuth)();
56
- const detail = await _chunkUCB7XSQEjs.withSpinner.call(void 0,
56
+ const detail = await _chunkCUQEGUAGjs.withSpinner.call(void 0,
57
57
  "Fetching run history...",
58
58
  async () => (0, import_miramarket_client.getStrategyDetails)(await (0, import_miramarket_client.getConvexClient)(), args.strategyId),
59
59
  { json: flags.json }
@@ -65,7 +65,7 @@ var StrategiesRuns = class _StrategiesRuns extends _chunkUCB7XSQEjs.BaseCommand
65
65
  );
66
66
  }
67
67
  const runs = detail.runs.slice(0, flags.limit).map(summarizeRun);
68
- _chunkUCB7XSQEjs.printResult.call(void 0,
68
+ _chunkCUQEGUAGjs.printResult.call(void 0,
69
69
  {
70
70
  ok: true,
71
71
  command: "strategies runs",
@@ -6,17 +6,17 @@ var _chunkP7NT6RRJjs = require('../../chunk-P7NT6RRJ.js');
6
6
 
7
7
 
8
8
 
9
- var _chunkUCB7XSQEjs = require('../../chunk-UCB7XSQE.js');
9
+ var _chunkCUQEGUAGjs = require('../../chunk-CUQEGUAG.js');
10
10
 
11
11
 
12
12
  var _chunkQGM4M3NIjs = require('../../chunk-QGM4M3NI.js');
13
13
 
14
14
  // src/commands/strategies/show.ts
15
15
  var _core = require('@oclif/core');
16
- var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
17
- var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
18
- var import_miramarket_client3 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
19
- var StrategiesShow = class _StrategiesShow extends _chunkUCB7XSQEjs.BaseCommand {
16
+ var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
17
+ var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
18
+ var import_miramarket_client3 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
19
+ var StrategiesShow = class _StrategiesShow extends _chunkCUQEGUAGjs.BaseCommand {
20
20
  static {
21
21
  this.description = "Show details for a strategy by ID.";
22
22
  }
@@ -37,9 +37,15 @@ var StrategiesShow = class _StrategiesShow extends _chunkUCB7XSQEjs.BaseCommand
37
37
  async run() {
38
38
  const { args, flags } = await this.parse(_StrategiesShow);
39
39
  (0, import_miramarket_client2.requireAuth)();
40
- const detail = await _chunkUCB7XSQEjs.withSpinner.call(void 0,
40
+ const { detail, limitOrders } = await _chunkCUQEGUAGjs.withSpinner.call(void 0,
41
41
  "Fetching strategy details...",
42
- async () => (0, import_miramarket_client.getStrategyDetails)(await (0, import_miramarket_client.getConvexClient)(), args.strategyId),
42
+ async () => {
43
+ const client = await (0, import_miramarket_client.getConvexClient)();
44
+ const found = await (0, import_miramarket_client.getStrategyDetails)(client, args.strategyId);
45
+ const runId = _optionalChain([found, 'optionalAccess', _ => _.latestRun, 'optionalAccess', _2 => _2._id]);
46
+ const orders = found && runId && (0, import_miramarket_client.hasStoredLimitCondition)(found.nodes) ? await (0, import_miramarket_client.listLimitOrders)(client, runId) : [];
47
+ return { detail: found, limitOrders: (0, import_miramarket_client.limitOrderRows)(orders) };
48
+ },
43
49
  { json: flags.json }
44
50
  );
45
51
  if (!detail) {
@@ -61,20 +67,23 @@ var StrategiesShow = class _StrategiesShow extends _chunkUCB7XSQEjs.BaseCommand
61
67
  source: _nullishCoalesce(detail.source, () => ( "app")),
62
68
  settlementPolicy: _nullishCoalesce(detail.settlementPolicy, () => ( "redeem_and_hold")),
63
69
  initialPrincipalUsd: _nullishCoalesce(detail.initialPrincipalUsd, () => ( null)),
64
- runId: _nullishCoalesce(_optionalChain([run, 'optionalAccess', _ => _._id]), () => ( null)),
65
- runStatus: _nullishCoalesce(_optionalChain([run, 'optionalAccess', _2 => _2.status]), () => ( "no-run")),
70
+ runId: _nullishCoalesce(_optionalChain([run, 'optionalAccess', _3 => _3._id]), () => ( null)),
71
+ runStatus: _nullishCoalesce(_optionalChain([run, 'optionalAccess', _4 => _4.status]), () => ( "no-run")),
66
72
  runCount: detail.runs.length,
67
73
  // The latest run's money: closed positions, then what it still holds at
68
74
  // its last mark. A fresh buy shows only in the open figures.
69
- realizedPnlUsd: _nullishCoalesce(_optionalChain([run, 'optionalAccess', _3 => _3.realizedPnlUsd]), () => ( null)),
75
+ realizedPnlUsd: _nullishCoalesce(_optionalChain([run, 'optionalAccess', _5 => _5.realizedPnlUsd]), () => ( null)),
70
76
  openValueUsd: run ? marks.openValueUsd : null,
71
- unrealizedPnlUsd: run ? marks.unrealizedPnlUsd : null
77
+ unrealizedPnlUsd: run ? marks.unrealizedPnlUsd : null,
78
+ // The latest run's Limit conditions as orders on the venue, each with
79
+ // a summary such as "resting, 40 of 100 filled @ 0.42".
80
+ limitOrders
72
81
  };
73
82
  if (!flags.verbose || !run) {
74
- _chunkUCB7XSQEjs.printResult.call(void 0, base, flags.json);
83
+ _chunkCUQEGUAGjs.printResult.call(void 0, base, flags.json);
75
84
  return;
76
85
  }
77
- _chunkUCB7XSQEjs.printResult.call(void 0,
86
+ _chunkCUQEGUAGjs.printResult.call(void 0,
78
87
  {
79
88
  ...base,
80
89
  run: {
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkUCB7XSQEjs = require('../../chunk-UCB7XSQE.js');
7
+ var _chunkCUQEGUAGjs = require('../../chunk-CUQEGUAG.js');
8
8
 
9
9
 
10
10
  var _chunkQGM4M3NIjs = require('../../chunk-QGM4M3NI.js');
@@ -12,9 +12,9 @@ var _chunkQGM4M3NIjs = require('../../chunk-QGM4M3NI.js');
12
12
  // src/commands/strategies/update.ts
13
13
  var _core = require('@oclif/core');
14
14
  var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
15
- var import_shared = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist.call(void 0, ));
16
- var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
17
- var StrategiesUpdate = class _StrategiesUpdate extends _chunkUCB7XSQEjs.BaseCommand {
15
+ var import_shared = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist.call(void 0, ));
16
+ var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
17
+ var StrategiesUpdate = class _StrategiesUpdate extends _chunkCUQEGUAGjs.BaseCommand {
18
18
  static {
19
19
  this.description = "Edit the future part of a running strategy in place. Nodes the run has executed or is waiting on are locked; only downstream (child) nodes can change.";
20
20
  }
@@ -53,7 +53,7 @@ var StrategiesUpdate = class _StrategiesUpdate extends _chunkUCB7XSQEjs.BaseComm
53
53
  if (!args.file && !_optionalChain([flags, 'access', _ => _.set, 'optionalAccess', _2 => _2.length]) && !_optionalChain([flags, 'access', _3 => _3.unset, 'optionalAccess', _4 => _4.length])) {
54
54
  throw (0, import_miramarket_client.inputError)("Provide a strategy file, or at least one --set/--unset edit.");
55
55
  }
56
- const state = await _chunkUCB7XSQEjs.withSpinner.call(void 0,
56
+ const state = await _chunkCUQEGUAGjs.withSpinner.call(void 0,
57
57
  "Fetching strategy...",
58
58
  async () => (0, import_miramarket_client.getStrategyEditState)(await (0, import_miramarket_client.getConvexClient)(), args.strategyId),
59
59
  { json: flags.json }
@@ -98,12 +98,12 @@ var StrategiesUpdate = class _StrategiesUpdate extends _chunkUCB7XSQEjs.BaseComm
98
98
  errors: errors.map((message) => ({ message }))
99
99
  });
100
100
  }
101
- await _chunkUCB7XSQEjs.withSpinner.call(void 0,
101
+ await _chunkCUQEGUAGjs.withSpinner.call(void 0,
102
102
  "Updating strategy...",
103
103
  async () => (0, import_miramarket_client.updateStrategyDuringRun)(await (0, import_miramarket_client.getConvexClient)(), args.strategyId, JSON.stringify(candidate)),
104
104
  { json: flags.json }
105
105
  );
106
- _chunkUCB7XSQEjs.printResult.call(void 0,
106
+ _chunkCUQEGUAGjs.printResult.call(void 0,
107
107
  {
108
108
  ok: true,
109
109
  command: "strategies update",
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkUCB7XSQEjs = require('../../chunk-UCB7XSQE.js');
6
+ var _chunkCUQEGUAGjs = require('../../chunk-CUQEGUAG.js');
7
7
 
8
8
 
9
9
  var _chunkQGM4M3NIjs = require('../../chunk-QGM4M3NI.js');
@@ -11,9 +11,9 @@ var _chunkQGM4M3NIjs = require('../../chunk-QGM4M3NI.js');
11
11
  // src/commands/strategies/watch.ts
12
12
  var _core = require('@oclif/core');
13
13
  var _prompts = require('@clack/prompts'); var clack = _interopRequireWildcard(_prompts);
14
- var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
15
- var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
16
- var import_miramarket_client3 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
14
+ var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
15
+ var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
16
+ var import_miramarket_client3 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
17
17
  function buildRunSummary(run) {
18
18
  return {
19
19
  isDemo: _nullishCoalesce(run.isDemo, () => ( false)),
@@ -40,7 +40,7 @@ function pickRun(detail, runId, strategyId) {
40
40
  if (!detail.latestRun) throw (0, import_miramarket_client3.inputError)(`Strategy has no runs yet: ${strategyId}`, "NO_RUNS");
41
41
  return detail.latestRun;
42
42
  }
43
- var StrategiesWatch = class _StrategiesWatch extends _chunkUCB7XSQEjs.BaseCommand {
43
+ var StrategiesWatch = class _StrategiesWatch extends _chunkCUQEGUAGjs.BaseCommand {
44
44
  static {
45
45
  this.description = "Poll a strategy run until it reaches one of --until's terminal statuses.";
46
46
  }
@@ -86,7 +86,7 @@ var StrategiesWatch = class _StrategiesWatch extends _chunkUCB7XSQEjs.BaseComman
86
86
  const intervalMs = Math.max(2, flags.interval) * 1e3;
87
87
  const timeoutMs = flags.timeout * 1e3;
88
88
  const jsonOutput = flags.json || flags.events;
89
- const showSpinner = !jsonOutput && !_chunkUCB7XSQEjs.isJsonMode.call(void 0, ) && Boolean(process.stdout.isTTY);
89
+ const showSpinner = !jsonOutput && !_chunkCUQEGUAGjs.isJsonMode.call(void 0, ) && Boolean(process.stdout.isTTY);
90
90
  (0, import_miramarket_client2.requireAuth)();
91
91
  const startedAt = Date.now();
92
92
  const transitions = [];
@@ -129,6 +129,7 @@ var StrategiesWatch = class _StrategiesWatch extends _chunkUCB7XSQEjs.BaseComman
129
129
  }
130
130
  _optionalChain([spinner2, 'optionalAccess', _9 => _9.stop, 'call', _10 => _10(`Reached status: ${run.status}`)]);
131
131
  const failed = flags["fail-on-error"] && (run.status === "failed" || run.status === "canceled");
132
+ const limitOrders = (0, import_miramarket_client.hasStoredLimitCondition)(detail.nodes) ? (0, import_miramarket_client.limitOrderRows)(await (0, import_miramarket_client.listLimitOrders)(await (0, import_miramarket_client.getConvexClient)(), run._id)) : [];
132
133
  const envelope = {
133
134
  ok: !failed,
134
135
  command: "strategies watch",
@@ -138,12 +139,13 @@ var StrategiesWatch = class _StrategiesWatch extends _chunkUCB7XSQEjs.BaseComman
138
139
  watched: true,
139
140
  waitedMs: Date.now() - startedAt,
140
141
  transitions,
141
- run: buildRunSummary(run)
142
+ run: buildRunSummary(run),
143
+ limitOrders
142
144
  };
143
145
  if (flags.events) {
144
146
  process.stdout.write(JSON.stringify(envelope) + "\n");
145
147
  } else {
146
- _chunkUCB7XSQEjs.printResult.call(void 0, envelope, jsonOutput);
148
+ _chunkCUQEGUAGjs.printResult.call(void 0, envelope, jsonOutput);
147
149
  }
148
150
  if (failed) {
149
151
  this.exit(4);
@@ -3,17 +3,17 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkUCB7XSQEjs = require('../chunk-UCB7XSQE.js');
6
+ var _chunkCUQEGUAGjs = require('../chunk-CUQEGUAG.js');
7
7
 
8
8
 
9
9
  var _chunkQGM4M3NIjs = require('../chunk-QGM4M3NI.js');
10
10
 
11
11
  // src/commands/trade.ts
12
12
  var _core = require('@oclif/core');
13
- var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
14
- var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
15
- var import_miramarket_client3 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
16
- var TradeCommand = class _TradeCommand extends _chunkUCB7XSQEjs.BaseCommand {
13
+ var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
14
+ var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
15
+ var import_miramarket_client3 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
16
+ var TradeCommand = class _TradeCommand extends _chunkCUQEGUAGjs.BaseCommand {
17
17
  static {
18
18
  this.description = "Place a CLOB limit order on Polymarket.";
19
19
  }
@@ -31,8 +31,11 @@ var TradeCommand = class _TradeCommand extends _chunkUCB7XSQEjs.BaseCommand {
31
31
  required: true,
32
32
  options: ["buy", "sell"]
33
33
  }),
34
- price: _core.Flags.string({ description: "Limit price (0\u20131, e.g. 0.55 = 55 cents)", required: true }),
35
- size: _core.Flags.string({ description: "Order size in USDC", required: true }),
34
+ price: _core.Flags.string({ description: "Limit price (0\u20131, up to 4 decimals, e.g. 0.55 = 55 cents)", required: true }),
35
+ size: _core.Flags.string({
36
+ description: "Order size in SHARES, not USDC: a buy costs price \xD7 size, a sell receives it. A default FOK buy is sent as a dollar budget of price \xD7 size, so it can fill a few more shares at a better average price",
37
+ required: true
38
+ }),
36
39
  "order-type": _core.Flags.string({
37
40
  description: "Order type: FOK (fill-or-kill) or GTC (good-till-cancel)",
38
41
  options: ["FOK", "GTC"],
@@ -50,16 +53,34 @@ var TradeCommand = class _TradeCommand extends _chunkUCB7XSQEjs.BaseCommand {
50
53
  if (!flags.confirm) {
51
54
  throw (0, import_miramarket_client3.inputError)("Pass --confirm to place a real order. This action spends real money.");
52
55
  }
53
- const price = parseFloat(flags.price);
54
- const size = parseFloat(flags.size);
55
- if (isNaN(price) || price <= 0 || price >= 1) {
56
+ const rawPrice = String(flags.price).trim();
57
+ const rawSize = String(flags.size).trim();
58
+ const price = Number(rawPrice);
59
+ const size = Number(rawSize);
60
+ if (!/^[1-9]\d{19,77}$/.test(flags["token-id"]) || BigInt(flags["token-id"]) > (1n << 256n) - 1n) {
61
+ throw (0, import_miramarket_client3.inputError)(
62
+ `--token-id must be a Polymarket outcome token id (a long decimal string). Use \`markets resolve <handle>\` to get one from a market id, slug or link.`
63
+ );
64
+ }
65
+ if (isNaN(price) || !Number.isFinite(price)) {
66
+ throw (0, import_miramarket_client3.inputError)("Price must be a decimal number (e.g. 0.55)");
67
+ }
68
+ if (price <= 0 || price >= 1) {
56
69
  throw (0, import_miramarket_client3.inputError)("Price must be between 0 and 1 (exclusive)");
57
70
  }
58
- if (isNaN(size) || size <= 0) {
59
- throw (0, import_miramarket_client3.inputError)("Size must be a positive number");
71
+ if (!/^(?:0(?:\.\d{1,4})?|\.\d{1,4})$/.test(rawPrice) || price < 1e-4) {
72
+ throw (0, import_miramarket_client3.inputError)(
73
+ "Price must be a decimal between 0.0001 and 0.9999 with at most 4 decimals (e.g. 0.55, 0.5555)"
74
+ );
75
+ }
76
+ if (isNaN(size) || !Number.isFinite(size) || size <= 0) {
77
+ throw (0, import_miramarket_client3.inputError)("Size must be a positive number of shares");
78
+ }
79
+ if (!/^\d+(?:\.\d{1,6})?$/.test(rawSize)) {
80
+ throw (0, import_miramarket_client3.inputError)("Size must be a number of shares, without units (e.g. 100 or 12.5)");
60
81
  }
61
82
  (0, import_miramarket_client2.requireAuth)();
62
- const result = await _chunkUCB7XSQEjs.withSpinner.call(void 0,
83
+ const result = await _chunkCUQEGUAGjs.withSpinner.call(void 0,
63
84
  `Placing ${flags.side} order...`,
64
85
  () => (0, import_miramarket_client.placeOrder)({
65
86
  tokenId: flags["token-id"],
@@ -70,12 +91,26 @@ var TradeCommand = class _TradeCommand extends _chunkUCB7XSQEjs.BaseCommand {
70
91
  }),
71
92
  { json: flags.json }
72
93
  );
73
- _chunkUCB7XSQEjs.printResult.call(void 0,
94
+ _chunkCUQEGUAGjs.printResult.call(void 0,
74
95
  {
75
96
  ok: true,
76
97
  command: "trade",
77
98
  orderId: result.orderId,
78
99
  status: result.status,
100
+ // The size that was asked for, in the units both the venue and this flag
101
+ // use. Printing the notional beside it is what stops "size 20" being read
102
+ // as $20 when it is 20 shares at `price`.
103
+ //
104
+ // Not the filled count: a FOK buy is handed to the venue as a dollar
105
+ // budget of price × size and can fill more shares at a better average
106
+ // price (0.65 × 20 = $13 buys 26 shares at 0.50). A GTC rests at its own
107
+ // price and can fill fewer, later, or never.
108
+ requestedShares: size,
109
+ orderType: String(flags["order-type"]),
110
+ price,
111
+ // The quote, not the fill: a resting GTC may fill better or not at all,
112
+ // and on a sell this is proceeds rather than a cost.
113
+ limitNotionalUsd: Math.round(price * size * 1e6) / 1e6,
79
114
  transactionsHashes: _nullishCoalesce(result.transactionsHashes, () => ( []))
80
115
  },
81
116
  flags.json
@@ -3,18 +3,18 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkUCB7XSQEjs = require('../chunk-UCB7XSQE.js');
6
+ var _chunkCUQEGUAGjs = require('../chunk-CUQEGUAG.js');
7
7
 
8
8
 
9
9
  var _chunkQGM4M3NIjs = require('../chunk-QGM4M3NI.js');
10
10
 
11
11
  // src/commands/update.ts
12
- var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
12
+ var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
13
13
  var _core = require('@oclif/core');
14
14
  var _fs = require('fs'); var fs2 = _interopRequireWildcard(_fs); var fs = _interopRequireWildcard(_fs);
15
15
 
16
16
  // src/lib/self-update.ts
17
- var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
17
+ var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
18
18
  var _child_process = require('child_process');
19
19
 
20
20
  var _path = require('path'); var path = _interopRequireWildcard(_path);
@@ -182,7 +182,7 @@ function isPermissionFailure(output) {
182
182
  }
183
183
 
184
184
  // src/commands/update.ts
185
- var Update = class _Update extends _chunkUCB7XSQEjs.BaseCommand {
185
+ var Update = class _Update extends _chunkCUQEGUAGjs.BaseCommand {
186
186
  static {
187
187
  this.description = "Update miramarket-cli to the latest release on npm, with the package manager it was installed with.";
188
188
  }
@@ -203,7 +203,7 @@ var Update = class _Update extends _chunkUCB7XSQEjs.BaseCommand {
203
203
  const { flags } = await this.parse(_Update);
204
204
  const current = this.config.version;
205
205
  const install = detectInstall(realPath(this.config.root));
206
- const latest = await _chunkUCB7XSQEjs.withSpinner.call(void 0, "Checking npm for the latest release...", () => fetchLatestVersion(), {
206
+ const latest = await _chunkCUQEGUAGjs.withSpinner.call(void 0, "Checking npm for the latest release...", () => fetchLatestVersion(), {
207
207
  json: flags.json
208
208
  });
209
209
  const base = {
@@ -215,7 +215,7 @@ var Update = class _Update extends _chunkUCB7XSQEjs.BaseCommand {
215
215
  };
216
216
  const order = compareVersions(latest, current);
217
217
  if (order <= 0) {
218
- _chunkUCB7XSQEjs.printResult.call(void 0,
218
+ _chunkCUQEGUAGjs.printResult.call(void 0,
219
219
  {
220
220
  ...base,
221
221
  updateAvailable: false,
@@ -228,7 +228,7 @@ var Update = class _Update extends _chunkUCB7XSQEjs.BaseCommand {
228
228
  }
229
229
  const plan = updatePlan(install, latest);
230
230
  if (flags.check) {
231
- _chunkUCB7XSQEjs.printResult.call(void 0,
231
+ _chunkCUQEGUAGjs.printResult.call(void 0,
232
232
  {
233
233
  ...base,
234
234
  updateAvailable: true,
@@ -268,7 +268,7 @@ ${result.output.trim()}` : ""}`,
268
268
  "UPDATE_NOT_APPLIED"
269
269
  );
270
270
  }
271
- _chunkUCB7XSQEjs.printResult.call(void 0,
271
+ _chunkCUQEGUAGjs.printResult.call(void 0,
272
272
  {
273
273
  ...base,
274
274
  updateAvailable: false,
@@ -3,18 +3,18 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkUCB7XSQEjs = require('../chunk-UCB7XSQE.js');
6
+ var _chunkCUQEGUAGjs = require('../chunk-CUQEGUAG.js');
7
7
 
8
8
 
9
9
  var _chunkQGM4M3NIjs = require('../chunk-QGM4M3NI.js');
10
10
 
11
11
  // src/commands/validate.ts
12
12
  var _core = require('@oclif/core');
13
- var import_shared = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist.call(void 0, ));
13
+ var import_shared = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist.call(void 0, ));
14
14
  var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
15
- var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
16
- var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkUCB7XSQEjs.require_dist2.call(void 0, ));
17
- var Validate = class _Validate extends _chunkUCB7XSQEjs.BaseCommand {
15
+ var import_miramarket_client = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
16
+ var import_miramarket_client2 = _chunkQGM4M3NIjs.__toESM.call(void 0, _chunkCUQEGUAGjs.require_dist2.call(void 0, ));
17
+ var Validate = class _Validate extends _chunkCUQEGUAGjs.BaseCommand {
18
18
  static {
19
19
  this.description = "Validate a strategy JSON file against the ConditionalAction schema.";
20
20
  }
@@ -53,14 +53,14 @@ var Validate = class _Validate extends _chunkUCB7XSQEjs.BaseCommand {
53
53
  }
54
54
  const errors = (0, import_shared.validateConditionalActionStrategy)(strategy);
55
55
  if (errors.length === 0) errors.push(...await (0, import_miramarket_client2.unreachableTakeProfitErrors)(strategy));
56
- const warnings = errors.length === 0 ? await (0, import_miramarket_client2.minimumOrderWarnings)(strategy) : [];
56
+ const warnings = errors.length === 0 ? [...(0, import_miramarket_client2.strategyFieldWarnings)(strategy), ...await (0, import_miramarket_client2.minimumOrderWarnings)(strategy)] : [];
57
57
  const valid = errors.length === 0;
58
58
  (0, import_miramarket_client2.saveState)({
59
59
  currentStrategyPath: args.file,
60
60
  lastValidationOk: valid,
61
61
  lastValidationErrors: errors
62
62
  });
63
- _chunkUCB7XSQEjs.printResult.call(void 0,
63
+ _chunkCUQEGUAGjs.printResult.call(void 0,
64
64
  {
65
65
  ok: valid,
66
66
  command: "validate",