@reefclaw/openclaw-plugin 0.1.4 → 0.1.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.
Files changed (124) hide show
  1. package/ccxt/binance-private.d.ts +21 -0
  2. package/ccxt/binance-private.js +132 -22
  3. package/config/plugin-config-io.d.ts +6 -0
  4. package/config/tool-gate.js +3 -0
  5. package/exchange-adapter.d.ts +16 -0
  6. package/index.js +567 -57
  7. package/lifecycle/trading-operation-lock.d.ts +17 -0
  8. package/lifecycle/trading-operation-lock.js +14 -0
  9. package/live/bracket-id.d.ts +2 -3
  10. package/live/bracket-id.js +22 -9
  11. package/live/live-adapter.d.ts +24 -1
  12. package/live/live-adapter.js +114 -2
  13. package/live/local-signal-service.js +11 -6
  14. package/live/local-strategy-evaluator.js +4 -0
  15. package/live/proposal-decision-listener.d.ts +6 -0
  16. package/live/proposal-decision-listener.js +4 -0
  17. package/live/stop-watcher.d.ts +27 -1
  18. package/live/stop-watcher.js +59 -2
  19. package/onboarding/runtime.d.ts +13 -0
  20. package/onboarding/runtime.js +22 -2
  21. package/openclaw.plugin.json +1 -0
  22. package/package.json +1 -1
  23. package/persistence/state-manager.d.ts +24 -0
  24. package/persistence/state-manager.js +62 -4
  25. package/portfolio/wave9-admission.d.ts +67 -0
  26. package/portfolio/wave9-admission.js +262 -0
  27. package/portfolio/wave9-policy.d.ts +36 -0
  28. package/portfolio/wave9-policy.js +183 -0
  29. package/signals/conditions/registry.js +50 -0
  30. package/simulator/exchange-simulator.js +5 -0
  31. package/simulator/fill-engine.js +5 -1
  32. package/simulator/types.d.ts +6 -1
  33. package/strategy/evaluator.d.ts +3 -0
  34. package/strategy/evaluator.js +5 -0
  35. package/tools/assessment-validation.d.ts +2 -0
  36. package/tools/attach-brackets.d.ts +7 -2
  37. package/tools/attach-brackets.js +36 -0
  38. package/tools/cancel-all-orders.d.ts +2 -0
  39. package/tools/cancel-all-orders.js +4 -1
  40. package/tools/cancel-order.d.ts +4 -0
  41. package/tools/cancel-order.js +49 -3
  42. package/tools/close-position.d.ts +23 -0
  43. package/tools/close-position.js +286 -13
  44. package/tools/create-order.d.ts +28 -0
  45. package/tools/create-order.js +1364 -192
  46. package/tools/get-analytics.js +2 -2
  47. package/tools/get-basis.js +2 -2
  48. package/tools/get-cascade-risk.js +2 -2
  49. package/tools/get-crypto-metrics.js +20 -3
  50. package/tools/get-cvd.js +2 -2
  51. package/tools/get-divergences.js +2 -2
  52. package/tools/get-funding-context.js +2 -2
  53. package/tools/get-liquidation-levels.js +2 -2
  54. package/tools/get-liquidation-pulse.js +2 -2
  55. package/tools/get-pattern-scan.js +2 -2
  56. package/tools/get-regime.js +2 -2
  57. package/tools/get-resting-liquidity.js +2 -2
  58. package/tools/get-risk-scenario.js +2 -2
  59. package/tools/get-session-review.js +2 -2
  60. package/tools/get-setup-detail.js +9 -1
  61. package/tools/get-signals.js +2 -2
  62. package/tools/get-sizing.js +2 -2
  63. package/tools/get-trade-feedback.js +2 -2
  64. package/tools/get-trade-flow.js +2 -2
  65. package/tools/get-volume-profile.js +2 -2
  66. package/tools/get-wave9-status.d.ts +127 -0
  67. package/tools/get-wave9-status.js +796 -0
  68. package/tools/intel-api.d.ts +20 -0
  69. package/tools/intel-api.js +67 -0
  70. package/tools/intel-cache.d.ts +1 -1
  71. package/tools/intel-cache.js +20 -5
  72. package/tools/list-strategies.d.ts +11 -1
  73. package/tools/list-strategies.js +17 -0
  74. package/tools/modify-stop.d.ts +4 -0
  75. package/tools/modify-stop.js +63 -24
  76. package/tools/modify-target.d.ts +4 -0
  77. package/tools/modify-target.js +62 -23
  78. package/tools/scan-pairs.js +19 -8
  79. package/tools/toggle-strategy.js +7 -0
  80. package/types.d.ts +5 -0
  81. package/venues/hyperliquid/hl-balance.d.ts +116 -0
  82. package/venues/hyperliquid/hl-balance.js +145 -0
  83. package/venues/hyperliquid/hl-brackets.d.ts +102 -0
  84. package/venues/hyperliquid/hl-brackets.js +172 -0
  85. package/venues/hyperliquid/hl-cloid.d.ts +22 -0
  86. package/venues/hyperliquid/hl-cloid.js +82 -0
  87. package/venues/hyperliquid/hl-info-cache.d.ts +46 -0
  88. package/venues/hyperliquid/hl-info-cache.js +125 -0
  89. package/venues/hyperliquid/hl-live-adapter.d.ts +88 -0
  90. package/venues/hyperliquid/hl-live-adapter.js +353 -0
  91. package/venues/hyperliquid/hl-precision.d.ts +61 -0
  92. package/venues/hyperliquid/hl-precision.js +176 -0
  93. package/venues/hyperliquid/hl-private.d.ts +88 -0
  94. package/venues/hyperliquid/hl-private.js +357 -0
  95. package/venues/hyperliquid/hl-public.d.ts +31 -4
  96. package/venues/hyperliquid/hl-public.js +155 -11
  97. package/venues/hyperliquid/hl-rate-gate.d.ts +57 -0
  98. package/venues/hyperliquid/hl-rate-gate.js +220 -0
  99. package/venues/hyperliquid/hl-user-stream.d.ts +90 -0
  100. package/venues/hyperliquid/hl-user-stream.js +220 -0
  101. package/venues/registry.d.ts +28 -9
  102. package/venues/registry.js +19 -13
  103. package/venues/symbols.d.ts +43 -0
  104. package/venues/symbols.js +107 -0
  105. package/wave9/live-account-capture.d.ts +67 -0
  106. package/wave9/live-account-capture.js +435 -0
  107. package/wave9/live-autonomous-protection.d.ts +39 -0
  108. package/wave9/live-autonomous-protection.js +112 -0
  109. package/wave9/live-durable-reconciliation-scheduler.d.ts +33 -0
  110. package/wave9/live-durable-reconciliation-scheduler.js +115 -0
  111. package/wave9/live-execution-ledger.d.ts +107 -0
  112. package/wave9/live-execution-ledger.js +498 -0
  113. package/wave9/live-position-confirmation.d.ts +18 -0
  114. package/wave9/live-position-confirmation.js +111 -0
  115. package/wave9/live-residual-protection.d.ts +18 -0
  116. package/wave9/live-residual-protection.js +250 -0
  117. package/wave9/live-startup-reconciliation.d.ts +38 -0
  118. package/wave9/live-startup-reconciliation.js +454 -0
  119. package/wave9/live-symbol-ownership.d.ts +20 -0
  120. package/wave9/live-symbol-ownership.js +132 -0
  121. package/wave9/paper-admission-guard.d.ts +199 -0
  122. package/wave9/paper-admission-guard.js +650 -0
  123. package/wave9/usdm-evidence-provider.d.ts +42 -0
  124. package/wave9/usdm-evidence-provider.js +133 -0
@@ -0,0 +1,199 @@
1
+ import type { IExchangeAdapter } from '../exchange-adapter.js';
2
+ /** One catalog toggle represents both frozen Wave 9 strategy legs. */
3
+ export declare const WAVE9_BUNDLE_SETUP_TYPE = "wave9_28d_momentum_reversal";
4
+ export declare const WAVE9_MECHANICAL_EXIT_REASON = "wave9_signal_reversal";
5
+ export type Wave9ExecutionMode = 'PAPER' | 'LIVE';
6
+ /** Conservative shared identity check for current, legacy, or Wave 9-mission positions. */
7
+ export declare function isWave9ManagedPosition(position: {
8
+ setupType?: string | null;
9
+ missionId?: string | null;
10
+ }): boolean;
11
+ export interface Wave9PaperAccountSnapshot {
12
+ schema: 'wave9-paper-account-v1';
13
+ /** Local simulator mutation stamp. It is not a cross-process lease. */
14
+ savedAt: number | null;
15
+ quoteCurrency: string;
16
+ wallet: Array<{
17
+ currency: string;
18
+ total: number;
19
+ available: number;
20
+ locked: number;
21
+ }>;
22
+ equityUsd: number;
23
+ sessionStartNavUsd: number | null;
24
+ positions: Array<{
25
+ symbol: string;
26
+ side: 'long' | 'short';
27
+ quantity: number;
28
+ entryPrice: number;
29
+ markPrice: number;
30
+ openedAt: string;
31
+ missionId: string | null;
32
+ setupType: string | null;
33
+ candidateId: string | null;
34
+ strategy: string | null;
35
+ accruedFundingUsd: number | null;
36
+ fundingThroughTime: string | null;
37
+ stopPrice: number | null;
38
+ initialOpenRiskUsd: number | null;
39
+ }>;
40
+ openOrders: Array<{
41
+ id: string;
42
+ symbol: string;
43
+ side: 'buy' | 'sell';
44
+ type: 'market' | 'limit';
45
+ amount: number;
46
+ filled: number;
47
+ price: number | null;
48
+ }>;
49
+ /** Persisted closed candidates prevent same-event replay after restart. */
50
+ closedWave9CandidateIds: string[];
51
+ }
52
+ export interface Wave9PaperAccountFingerprint {
53
+ fingerprint: string;
54
+ snapshot: Wave9PaperAccountSnapshot;
55
+ authoritative: false;
56
+ runtimeParity: false;
57
+ provenance: 'process_local_unlocked_simulator';
58
+ }
59
+ export interface Wave9PaperPositionFingerprint {
60
+ fingerprint: string;
61
+ snapshot: Omit<Wave9PaperAccountSnapshot['positions'][number], 'markPrice' | 'accruedFundingUsd' | 'fundingThroughTime'>;
62
+ authoritative: false;
63
+ runtimeParity: false;
64
+ provenance: 'process_local_unlocked_simulator';
65
+ }
66
+ export interface Wave9PaperAdmissionTokenDecision {
67
+ batchId: string;
68
+ candidateId: string;
69
+ missionId: string;
70
+ symbol: string;
71
+ side: 'BUY' | 'SELL';
72
+ /** String form preserves the exact frozen JS number across issuance. */
73
+ quantity: string;
74
+ stopPrice: string;
75
+ sequence: number;
76
+ notBeforeMs: number;
77
+ deadlineMs: number;
78
+ accountFingerprint: string;
79
+ tradingMode: Wave9ExecutionMode;
80
+ }
81
+ export interface Wave9IssuedAdmission {
82
+ token: string;
83
+ batchId: string;
84
+ candidateId: string;
85
+ missionId: string;
86
+ sequence: number;
87
+ deadlineMs: number;
88
+ accountFingerprint: string;
89
+ tradingMode: Wave9ExecutionMode;
90
+ }
91
+ export interface Wave9PaperExitTokenDecision {
92
+ candidateId: string;
93
+ missionId: string;
94
+ symbol: string;
95
+ positionSide: 'long' | 'short';
96
+ reason: 'signal_reversal';
97
+ notBeforeMs: number;
98
+ deadlineMs: number;
99
+ positionFingerprint: string;
100
+ tradingMode: Wave9ExecutionMode;
101
+ }
102
+ export interface Wave9IssuedExit {
103
+ token: string;
104
+ candidateId: string;
105
+ missionId: string;
106
+ deadlineMs: number;
107
+ positionFingerprint: string;
108
+ tradingMode: Wave9ExecutionMode;
109
+ }
110
+ export interface Wave9EntryAuthorizationRequest {
111
+ token: string;
112
+ candidateId: string;
113
+ missionId: string;
114
+ symbol: string;
115
+ side: string;
116
+ type: string;
117
+ quantity: number;
118
+ stopPrice: number | undefined;
119
+ setupType: string | undefined;
120
+ accountFingerprint: string;
121
+ tradingMode: Wave9ExecutionMode;
122
+ }
123
+ export interface Wave9ExitAuthorizationRequest {
124
+ token: string;
125
+ candidateId: string;
126
+ missionId: string;
127
+ symbol: string;
128
+ positionSide: 'long' | 'short';
129
+ setupType: string | undefined;
130
+ reason: string | undefined;
131
+ positionFingerprint: string;
132
+ tradingMode: Wave9ExecutionMode;
133
+ }
134
+ export interface Wave9AuthorizationLease {
135
+ readonly leaseId: string;
136
+ readonly kind: 'entry' | 'exit';
137
+ readonly token: string;
138
+ }
139
+ export declare class Wave9PaperAdmissionGuardError extends Error {
140
+ constructor(message: string);
141
+ }
142
+ export interface Wave9PaperAdmissionGuardOptions {
143
+ now?: () => number;
144
+ /** Opaque-token lifetime, bounded again by the decision's hard deadline. */
145
+ tokenTtlMs?: number;
146
+ }
147
+ /**
148
+ * Capture the complete process-local book inputs used to defend a Wave 9
149
+ * admission against local TOCTOU. This is deliberately labelled non-
150
+ * authoritative: the production paper deployment has no cross-process owner
151
+ * lease, so a matching hash is useful fail-closed protection, never parity or
152
+ * promotion evidence.
153
+ */
154
+ export declare function captureWave9PaperAccountSnapshot(adapter: IExchangeAdapter): Wave9PaperAccountFingerprint;
155
+ /** Stable held-position identity for a mechanical reversal close. */
156
+ export declare function captureWave9PaperPositionFingerprint(adapter: IExchangeAdapter, symbol: string): Wave9PaperPositionFingerprint;
157
+ /** In-memory capability guard shared by get_wave9_status and mutation tools. */
158
+ export declare class Wave9PaperAdmissionGuard {
159
+ private readonly now;
160
+ private readonly tokenTtlMs;
161
+ private readonly batches;
162
+ private readonly events;
163
+ private readonly entriesByToken;
164
+ private readonly exitsByIdentity;
165
+ private readonly exitsByToken;
166
+ constructor(options?: Wave9PaperAdmissionGuardOptions);
167
+ issueBatch(decisions: readonly Wave9PaperAdmissionTokenDecision[]): Wave9IssuedAdmission[];
168
+ issueExitBatch(decisions: readonly Wave9PaperExitTokenDecision[]): Wave9IssuedExit[];
169
+ beginEntry(request: Wave9EntryAuthorizationRequest): Wave9AuthorizationLease;
170
+ beginExit(request: Wave9ExitAuthorizationRequest): Wave9AuthorizationLease;
171
+ revalidate(lease: Wave9AuthorizationLease, fingerprint: string): void;
172
+ commit(lease: Wave9AuthorizationLease): void;
173
+ /**
174
+ * Consume a failed capability. Entry failure latches the whole projected
175
+ * batch because later sizing assumed every earlier accepted entry. Exit
176
+ * retry is allowed when the caller explicitly proves another attempt stays
177
+ * risk-reducing, including a residual/unknown result after a reduce-only
178
+ * LIVE close submission.
179
+ */
180
+ abort(lease: Wave9AuthorizationLease, reason: string, options?: {
181
+ retryable?: boolean;
182
+ latchEvent?: boolean;
183
+ }): void;
184
+ private validateWindow;
185
+ private newEntryRecord;
186
+ private newExitRecord;
187
+ private rotateEntryToken;
188
+ private rotateExitToken;
189
+ private newToken;
190
+ private validateTokenShape;
191
+ private assertUsable;
192
+ private lease;
193
+ private recordForLease;
194
+ private assertFingerprint;
195
+ private sameEntryDecision;
196
+ private validateExitDecision;
197
+ private exitIdentity;
198
+ private sameExitDecision;
199
+ }