@reefclaw/connect 0.1.7 → 0.1.8
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/assets/plugin/ccxt/binance-public.d.ts +2 -1
- package/assets/plugin/ccxt/intel-public.d.ts +25 -0
- package/assets/plugin/ccxt/intel-public.js +80 -0
- package/assets/plugin/ccxt/public-market-data-api.d.ts +12 -0
- package/assets/plugin/ccxt/public-market-data-api.js +9 -0
- package/assets/plugin/config/plugin-config-io.d.ts +15 -0
- package/assets/plugin/index.js +110 -14
- package/assets/plugin/ingest/position-auto-capture.d.ts +5 -0
- package/assets/plugin/ingest/position-auto-capture.js +8 -2
- package/assets/plugin/ingest/position-decisions-client.d.ts +4 -0
- package/assets/plugin/ingest/readiness-reporter.d.ts +28 -5
- package/assets/plugin/ingest/readiness-reporter.js +40 -19
- package/assets/plugin/live/bracket-id.d.ts +9 -0
- package/assets/plugin/live/bracket-id.js +18 -0
- package/assets/plugin/tools/close-position.d.ts +2 -2
- package/assets/plugin/tools/create-order.d.ts +2 -2
- package/assets/plugin/tools/fetch-ohlcv.d.ts +2 -2
- package/assets/plugin/tools/fetch-ticker.d.ts +2 -2
- package/assets/plugin/tools/get-crypto-metrics.d.ts +2 -2
- package/assets/plugin/tools/get-market-structure.d.ts +2 -2
- package/assets/plugin/tools/get-orderbook.d.ts +2 -2
- package/assets/plugin/tools/get-volume-analysis.d.ts +2 -2
- package/assets/plugin/tools/helpers.d.ts +5 -4
- package/assets/plugin/tools/helpers.js +2 -1
- package/assets/plugin/types.d.ts +20 -1
- package/assets/plugin/venues/hyperliquid/hl-public.d.ts +52 -0
- package/assets/plugin/venues/hyperliquid/hl-public.js +285 -0
- package/assets/plugin/venues/registry.d.ts +19 -0
- package/assets/plugin/venues/registry.js +40 -0
- package/assets/shared/fills.d.ts +5 -1
- package/assets/shared/index.d.ts +2 -0
- package/assets/shared/index.js +1 -0
- package/assets/shared/readiness.d.ts +6 -1
- package/assets/shared/readiness.js +9 -0
- package/assets/shared/venues/symbols.d.ts +43 -0
- package/assets/shared/venues/symbols.js +123 -0
- package/package.json +1 -1
|
@@ -13,6 +13,15 @@ export const READINESS_CHECK_COPY = {
|
|
|
13
13
|
phase: 'connect',
|
|
14
14
|
fixHint: 'Your agent host is geo-blocked by Binance (HTTP 451). Run OpenClaw from a Binance-permitted region — most EU / several Asia VPS regions work.',
|
|
15
15
|
},
|
|
16
|
+
// Dormant until the Hyperliquid venue ships (docs/HYPERLIQUID_INTEGRATION_PLAN.md
|
|
17
|
+
// Phase 1): the reporter probes only the CONFIGURED venue, so this id is never
|
|
18
|
+
// emitted while venue='binance'. Landed early so older webapps render it via the
|
|
19
|
+
// string-widened ReadinessCheck.id the moment a newer plugin starts sending it.
|
|
20
|
+
hyperliquid_reachable: {
|
|
21
|
+
label: 'Hyperliquid reachable',
|
|
22
|
+
phase: 'connect',
|
|
23
|
+
fixHint: 'Your agent host cannot reach the Hyperliquid API (api.hyperliquid.xyz). Check outbound HTTPS/DNS/firewall; if the host region is restricted, run OpenClaw from a permitted region.',
|
|
24
|
+
},
|
|
16
25
|
clock_in_sync: {
|
|
17
26
|
label: 'Host clock in sync',
|
|
18
27
|
phase: 'connect',
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export type VenueId = 'binance' | 'hyperliquid';
|
|
2
|
+
export declare const VENUE_IDS: readonly VenueId[];
|
|
3
|
+
export declare function isVenueId(value: unknown): value is VenueId;
|
|
4
|
+
/** Parse a raw config value into a venue.
|
|
5
|
+
* Absent/empty → 'binance' (every pre-venue config file keeps today's
|
|
6
|
+
* behavior byte-identically). An unrecognized string is surfaced to the
|
|
7
|
+
* caller instead of being silently coerced — mis-spelling a venue must be
|
|
8
|
+
* loud, never quietly become "trade on Binance". */
|
|
9
|
+
export declare function parseVenue(raw: unknown): {
|
|
10
|
+
venue: VenueId;
|
|
11
|
+
unrecognized?: string;
|
|
12
|
+
};
|
|
13
|
+
/** `FillEvent.exchange` / webapp `trades.exchange` value — half of the
|
|
14
|
+
* audit-trail idempotency key `(exchange, exchange_trade_id)` (migration
|
|
15
|
+
* 0042). 'binance_futures' is the historical literal on every existing row;
|
|
16
|
+
* NEVER change these strings once a venue has written rows. */
|
|
17
|
+
export declare const FILL_EXCHANGE_ID: Record<VenueId, string>;
|
|
18
|
+
export declare function fillExchangeId(venue: VenueId): string;
|
|
19
|
+
/** Quote/settle asset of the venue's linear perps. */
|
|
20
|
+
export declare const VENUE_QUOTE_ASSET: Record<VenueId, string>;
|
|
21
|
+
/** Prefix that namespaces Hyperliquid rows inside the intel symbol column. */
|
|
22
|
+
export declare const HL_INTEL_PREFIX = "HL_";
|
|
23
|
+
/** Canonical symbol → the venue's CCXT unified symbol.
|
|
24
|
+
* 'BTC/USDT' (binance) → 'BTC/USDT:USDT'; 'BTC/USDC' (hyperliquid) →
|
|
25
|
+
* 'BTC/USDC:USDC'. Accepts an already-suffixed input (idempotent). */
|
|
26
|
+
export declare function toCcxtSymbol(venue: VenueId, canonical: string): string;
|
|
27
|
+
/** Canonical symbol → intel DB symbol.
|
|
28
|
+
* binance: 'BTC/USDT' → 'BTCUSDT' (the historical concatenated form intel has
|
|
29
|
+
* always stored); hyperliquid: 'BTC/USDC' → 'HL_BTC' (namespaced coin, case
|
|
30
|
+
* preserved). */
|
|
31
|
+
export declare function toIntelSymbol(venue: VenueId, canonical: string): string;
|
|
32
|
+
/** Inverse of toIntelSymbol. 'HL_'-prefixed → hyperliquid; everything else is
|
|
33
|
+
* the historical Binance namespace. Binance symbols that are not
|
|
34
|
+
* USDT-concatenated (none exist in INTEL_SYMBOLS today) come back verbatim as
|
|
35
|
+
* canonical — honest passthrough, not a guess. */
|
|
36
|
+
export declare function fromIntelSymbol(intelSymbol: string): {
|
|
37
|
+
venue: VenueId;
|
|
38
|
+
canonical: string;
|
|
39
|
+
};
|
|
40
|
+
/** The Hyperliquid venue-native coin name for a canonical symbol
|
|
41
|
+
* ('BTC/USDC' → 'BTC'). Orders address assets by integer index resolved from
|
|
42
|
+
* `meta.universe` at runtime — the coin name is the stable half. */
|
|
43
|
+
export declare function toHyperliquidCoin(canonical: string): string;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Venue identity + symbol-coordinate mapping for multi-venue support.
|
|
2
|
+
//
|
|
3
|
+
// Phase 0 of docs/HYPERLIQUID_INTEGRATION_PLAN.md (§5.3): the single source of
|
|
4
|
+
// truth for how one market is named across the four coordinate systems —
|
|
5
|
+
//
|
|
6
|
+
// layer binance hyperliquid
|
|
7
|
+
// canonical (agent/webapp) 'BTC/USDT' 'BTC/USDC'
|
|
8
|
+
// CCXT unified 'BTC/USDT:USDT' 'BTC/USDC:USDC'
|
|
9
|
+
// venue-native 'BTCUSDT' coin 'BTC' (asset index via meta)
|
|
10
|
+
// intel DB symbol 'BTCUSDT' 'HL_BTC'
|
|
11
|
+
//
|
|
12
|
+
// The intel namespace ('HL_' prefix) is deliberate: a distinct symbol string IS
|
|
13
|
+
// venue isolation to the entire symbol-keyed intel read stack (context, cache
|
|
14
|
+
// keys, conditions, facts, regime, API routes) with zero schema migration —
|
|
15
|
+
// see the plan §5.3 for the trade-off vs an `exchange` column.
|
|
16
|
+
//
|
|
17
|
+
// Scattered `.replace('USDT', …)` conversions are the anti-pattern this module
|
|
18
|
+
// replaces at NEW call sites (existing Binance sites migrate opportunistically,
|
|
19
|
+
// never in the Phase 0 no-behavior-change window).
|
|
20
|
+
//
|
|
21
|
+
// Case rule: Hyperliquid coin names are case-sensitive ('kPEPE' = 1000 PEPE);
|
|
22
|
+
// the intel symbol preserves the venue's exact casing after the 'HL_' prefix
|
|
23
|
+
// ('HL_kPEPE') so round-trips are lossless. Never uppercase an HL coin.
|
|
24
|
+
export const VENUE_IDS = ['binance', 'hyperliquid'];
|
|
25
|
+
export function isVenueId(value) {
|
|
26
|
+
return value === 'binance' || value === 'hyperliquid';
|
|
27
|
+
}
|
|
28
|
+
/** Parse a raw config value into a venue.
|
|
29
|
+
* Absent/empty → 'binance' (every pre-venue config file keeps today's
|
|
30
|
+
* behavior byte-identically). An unrecognized string is surfaced to the
|
|
31
|
+
* caller instead of being silently coerced — mis-spelling a venue must be
|
|
32
|
+
* loud, never quietly become "trade on Binance". */
|
|
33
|
+
export function parseVenue(raw) {
|
|
34
|
+
if (raw === undefined || raw === null || raw === '')
|
|
35
|
+
return { venue: 'binance' };
|
|
36
|
+
if (isVenueId(raw))
|
|
37
|
+
return { venue: raw };
|
|
38
|
+
return { venue: 'binance', unrecognized: String(raw) };
|
|
39
|
+
}
|
|
40
|
+
/** `FillEvent.exchange` / webapp `trades.exchange` value — half of the
|
|
41
|
+
* audit-trail idempotency key `(exchange, exchange_trade_id)` (migration
|
|
42
|
+
* 0042). 'binance_futures' is the historical literal on every existing row;
|
|
43
|
+
* NEVER change these strings once a venue has written rows. */
|
|
44
|
+
export const FILL_EXCHANGE_ID = {
|
|
45
|
+
binance: 'binance_futures',
|
|
46
|
+
hyperliquid: 'hyperliquid',
|
|
47
|
+
};
|
|
48
|
+
export function fillExchangeId(venue) {
|
|
49
|
+
return FILL_EXCHANGE_ID[venue];
|
|
50
|
+
}
|
|
51
|
+
/** Quote/settle asset of the venue's linear perps. */
|
|
52
|
+
export const VENUE_QUOTE_ASSET = {
|
|
53
|
+
binance: 'USDT',
|
|
54
|
+
hyperliquid: 'USDC',
|
|
55
|
+
};
|
|
56
|
+
/** Prefix that namespaces Hyperliquid rows inside the intel symbol column. */
|
|
57
|
+
export const HL_INTEL_PREFIX = 'HL_';
|
|
58
|
+
/** Strip a CCXT settle suffix ('BTC/USDT:USDT' → 'BTC/USDT'). Same regex as
|
|
59
|
+
* webapp/src/lib/symbols.ts normalizeSymbol — kept inline so this module has
|
|
60
|
+
* zero imports and survives the sync-copy deploy boundary. */
|
|
61
|
+
function stripSettleSuffix(symbol) {
|
|
62
|
+
return symbol.replace(/:[A-Z]+$/, '');
|
|
63
|
+
}
|
|
64
|
+
function splitCanonical(canonical) {
|
|
65
|
+
const stripped = stripSettleSuffix(canonical.trim());
|
|
66
|
+
const parts = stripped.split('/');
|
|
67
|
+
if (parts.length !== 2 || parts[0].length === 0 || parts[1].length === 0) {
|
|
68
|
+
throw new Error(`Not a canonical BASE/QUOTE symbol: '${canonical}'`);
|
|
69
|
+
}
|
|
70
|
+
return { base: parts[0], quote: parts[1] };
|
|
71
|
+
}
|
|
72
|
+
/** Canonical symbol → the venue's CCXT unified symbol.
|
|
73
|
+
* 'BTC/USDT' (binance) → 'BTC/USDT:USDT'; 'BTC/USDC' (hyperliquid) →
|
|
74
|
+
* 'BTC/USDC:USDC'. Accepts an already-suffixed input (idempotent). */
|
|
75
|
+
export function toCcxtSymbol(venue, canonical) {
|
|
76
|
+
const { base, quote } = splitCanonical(canonical);
|
|
77
|
+
if (quote !== VENUE_QUOTE_ASSET[venue]) {
|
|
78
|
+
throw new Error(`Symbol '${canonical}' is not ${VENUE_QUOTE_ASSET[venue]}-quoted — not a ${venue} linear perp`);
|
|
79
|
+
}
|
|
80
|
+
return `${base}/${quote}:${quote}`;
|
|
81
|
+
}
|
|
82
|
+
/** Canonical symbol → intel DB symbol.
|
|
83
|
+
* binance: 'BTC/USDT' → 'BTCUSDT' (the historical concatenated form intel has
|
|
84
|
+
* always stored); hyperliquid: 'BTC/USDC' → 'HL_BTC' (namespaced coin, case
|
|
85
|
+
* preserved). */
|
|
86
|
+
export function toIntelSymbol(venue, canonical) {
|
|
87
|
+
const { base, quote } = splitCanonical(canonical);
|
|
88
|
+
if (venue === 'hyperliquid') {
|
|
89
|
+
if (quote !== VENUE_QUOTE_ASSET.hyperliquid) {
|
|
90
|
+
throw new Error(`Symbol '${canonical}' is not USDC-quoted — not a Hyperliquid perp`);
|
|
91
|
+
}
|
|
92
|
+
return `${HL_INTEL_PREFIX}${base}`;
|
|
93
|
+
}
|
|
94
|
+
return `${base}${quote}`;
|
|
95
|
+
}
|
|
96
|
+
/** Inverse of toIntelSymbol. 'HL_'-prefixed → hyperliquid; everything else is
|
|
97
|
+
* the historical Binance namespace. Binance symbols that are not
|
|
98
|
+
* USDT-concatenated (none exist in INTEL_SYMBOLS today) come back verbatim as
|
|
99
|
+
* canonical — honest passthrough, not a guess. */
|
|
100
|
+
export function fromIntelSymbol(intelSymbol) {
|
|
101
|
+
if (intelSymbol.startsWith(HL_INTEL_PREFIX)) {
|
|
102
|
+
const coin = intelSymbol.slice(HL_INTEL_PREFIX.length);
|
|
103
|
+
if (coin.length === 0) {
|
|
104
|
+
throw new Error(`Malformed intel symbol '${intelSymbol}' — empty coin after HL_ prefix`);
|
|
105
|
+
}
|
|
106
|
+
return { venue: 'hyperliquid', canonical: `${coin}/${VENUE_QUOTE_ASSET.hyperliquid}` };
|
|
107
|
+
}
|
|
108
|
+
if (intelSymbol.endsWith(VENUE_QUOTE_ASSET.binance) && intelSymbol.length > 4) {
|
|
109
|
+
const base = intelSymbol.slice(0, -VENUE_QUOTE_ASSET.binance.length);
|
|
110
|
+
return { venue: 'binance', canonical: `${base}/${VENUE_QUOTE_ASSET.binance}` };
|
|
111
|
+
}
|
|
112
|
+
return { venue: 'binance', canonical: intelSymbol };
|
|
113
|
+
}
|
|
114
|
+
/** The Hyperliquid venue-native coin name for a canonical symbol
|
|
115
|
+
* ('BTC/USDC' → 'BTC'). Orders address assets by integer index resolved from
|
|
116
|
+
* `meta.universe` at runtime — the coin name is the stable half. */
|
|
117
|
+
export function toHyperliquidCoin(canonical) {
|
|
118
|
+
const { base, quote } = splitCanonical(canonical);
|
|
119
|
+
if (quote !== VENUE_QUOTE_ASSET.hyperliquid) {
|
|
120
|
+
throw new Error(`Symbol '${canonical}' is not USDC-quoted — not a Hyperliquid perp`);
|
|
121
|
+
}
|
|
122
|
+
return base;
|
|
123
|
+
}
|