@yuants/vendor-hyperliquid 0.8.4 → 0.9.1
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/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/services/interest-rate-service.js +45 -0
- package/dist/services/interest-rate-service.js.map +1 -0
- package/dist/services/ohlc-service.js +80 -0
- package/dist/services/ohlc-service.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/services/interest-rate-service.d.ts +2 -0
- package/lib/services/interest-rate-service.d.ts.map +1 -0
- package/lib/services/interest-rate-service.js +47 -0
- package/lib/services/interest-rate-service.js.map +1 -0
- package/lib/services/ohlc-service.d.ts +2 -0
- package/lib/services/ohlc-service.d.ts.map +1 -0
- package/lib/services/ohlc-service.js +82 -0
- package/lib/services/ohlc-service.js.map +1 -0
- package/package.json +15 -15
- package/temp/package-deps.json +20 -18
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,kCAAkC,CAAC;AAC1C,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,0BAA0B,CAAC;AAClC,OAAO,mBAAmB,CAAC","sourcesContent":["import './services/exchange';\nimport './services/markets/interest-rate';\nimport './services/markets/ohlc';\nimport './services/markets/product';\nimport './services/markets/quote';\nimport './services/quotes';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,kCAAkC,CAAC;AAC1C,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,0BAA0B,CAAC;AAClC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,yBAAyB,CAAC;AACjC,OAAO,kCAAkC,CAAC","sourcesContent":["import './services/exchange';\nimport './services/markets/interest-rate';\nimport './services/markets/ohlc';\nimport './services/markets/product';\nimport './services/markets/quote';\nimport './services/quotes';\nimport './services/ohlc-service';\nimport './services/interest-rate-service';\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { provideInterestRateService } from '@yuants/exchange';
|
|
2
|
+
import { Terminal } from '@yuants/protocol';
|
|
3
|
+
import { decodePath, formatTime } from '@yuants/utils';
|
|
4
|
+
import { getHistoricalFundingRates } from '../api/public-api';
|
|
5
|
+
const terminal = Terminal.fromNodeEnv();
|
|
6
|
+
const INGEST_SERVICE_OPTIONS = {
|
|
7
|
+
concurrent: 1,
|
|
8
|
+
max_pending_requests: 20,
|
|
9
|
+
ingress_token_capacity: 2,
|
|
10
|
+
ingress_token_refill_interval: 1000,
|
|
11
|
+
egress_token_capacity: 1,
|
|
12
|
+
egress_token_refill_interval: 1000,
|
|
13
|
+
};
|
|
14
|
+
const WINDOW_MS = 30 * 24 * 3600000;
|
|
15
|
+
const fetchInterestRateBackward = async (req) => {
|
|
16
|
+
const [, marketType, symbol] = decodePath(req.product_id);
|
|
17
|
+
if (marketType !== 'PERPETUAL' || !symbol)
|
|
18
|
+
throw new Error(`Unsupported product_id: ${req.product_id}`);
|
|
19
|
+
const coin = symbol.split('-')[0];
|
|
20
|
+
if (!coin)
|
|
21
|
+
throw new Error(`Invalid symbol: ${symbol}`);
|
|
22
|
+
const endTime = req.time;
|
|
23
|
+
const startTime = Math.max(0, endTime - WINDOW_MS);
|
|
24
|
+
const res = await getHistoricalFundingRates({ coin, startTime, endTime });
|
|
25
|
+
return (res !== null && res !== void 0 ? res : [])
|
|
26
|
+
.map((v) => {
|
|
27
|
+
const ms = v.time;
|
|
28
|
+
const rate = Number(v.fundingRate);
|
|
29
|
+
return {
|
|
30
|
+
series_id: req.series_id,
|
|
31
|
+
product_id: req.product_id,
|
|
32
|
+
datasource_id: 'HYPERLIQUID',
|
|
33
|
+
created_at: formatTime(ms),
|
|
34
|
+
long_rate: `${-rate}`,
|
|
35
|
+
short_rate: `${rate}`,
|
|
36
|
+
settlement_price: '',
|
|
37
|
+
};
|
|
38
|
+
})
|
|
39
|
+
.filter((x) => Date.parse(x.created_at) < endTime);
|
|
40
|
+
};
|
|
41
|
+
provideInterestRateService(terminal, {
|
|
42
|
+
product_id_prefix: 'HYPERLIQUID/PERPETUAL/',
|
|
43
|
+
direction: 'backward',
|
|
44
|
+
}, fetchInterestRateBackward, INGEST_SERVICE_OPTIONS);
|
|
45
|
+
//# sourceMappingURL=interest-rate-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interest-rate-service.js","sourceRoot":"","sources":["../../src/services/interest-rate-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAmB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,MAAM,sBAAsB,GAAoB;IAC9C,UAAU,EAAE,CAAC;IACb,oBAAoB,EAAE,EAAE;IACxB,sBAAsB,EAAE,CAAC;IACzB,6BAA6B,EAAE,IAAI;IACnC,qBAAqB,EAAE,CAAC;IACxB,4BAA4B,EAAE,IAAI;CACnC,CAAC;AAEF,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,GAAG,OAAQ,CAAC;AAErC,MAAM,yBAAyB,GAAG,KAAK,EAAE,GAIxC,EAA4B,EAAE;IAC7B,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC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B,EAAE,wBAAwB;IAC3C,SAAS,EAAE,UAAU;CACtB,EACD,yBAAyB,EACzB,sBAAsB,CACvB,CAAC","sourcesContent":["import { IInterestRate } from '@yuants/data-interest-rate';\nimport { provideInterestRateService } from '@yuants/exchange';\nimport { IServiceOptions, Terminal } from '@yuants/protocol';\nimport { decodePath, formatTime } from '@yuants/utils';\nimport { getHistoricalFundingRates } from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst INGEST_SERVICE_OPTIONS: IServiceOptions = {\n concurrent: 1,\n max_pending_requests: 20,\n ingress_token_capacity: 2,\n ingress_token_refill_interval: 1000,\n egress_token_capacity: 1,\n egress_token_refill_interval: 1000,\n};\n\nconst WINDOW_MS = 30 * 24 * 3600_000;\n\nconst fetchInterestRateBackward = async (req: {\n product_id: string;\n time: number;\n series_id: string;\n}): Promise<IInterestRate[]> => {\n const [, marketType, symbol] = decodePath(req.product_id);\n if (marketType !== 'PERPETUAL' || !symbol) throw new Error(`Unsupported product_id: ${req.product_id}`);\n\n const coin = symbol.split('-')[0];\n if (!coin) throw new Error(`Invalid symbol: ${symbol}`);\n\n const endTime = req.time;\n const startTime = Math.max(0, endTime - WINDOW_MS);\n\n const res = await getHistoricalFundingRates({ coin, startTime, endTime });\n\n return (res ?? [])\n .map((v): IInterestRate => {\n const ms = v.time;\n const rate = Number(v.fundingRate);\n return {\n series_id: req.series_id,\n product_id: req.product_id,\n datasource_id: 'HYPERLIQUID',\n created_at: formatTime(ms),\n long_rate: `${-rate}`,\n short_rate: `${rate}`,\n settlement_price: '',\n };\n })\n .filter((x) => Date.parse(x.created_at) < endTime);\n};\n\nprovideInterestRateService(\n terminal,\n {\n product_id_prefix: 'HYPERLIQUID/PERPETUAL/',\n direction: 'backward',\n },\n fetchInterestRateBackward,\n INGEST_SERVICE_OPTIONS,\n);\n"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { provideOHLCService } from '@yuants/exchange';
|
|
2
|
+
import { Terminal } from '@yuants/protocol';
|
|
3
|
+
import { convertDurationToOffset, decodePath, formatTime } from '@yuants/utils';
|
|
4
|
+
import { getCandleSnapshot } from '../api/public-api';
|
|
5
|
+
const terminal = Terminal.fromNodeEnv();
|
|
6
|
+
const INGEST_SERVICE_OPTIONS = {
|
|
7
|
+
concurrent: 1,
|
|
8
|
+
max_pending_requests: 20,
|
|
9
|
+
ingress_token_capacity: 2,
|
|
10
|
+
ingress_token_refill_interval: 1000,
|
|
11
|
+
egress_token_capacity: 1,
|
|
12
|
+
egress_token_refill_interval: 1000,
|
|
13
|
+
};
|
|
14
|
+
const DURATION_TO_HYPERLIQUID_INTERVAL = {
|
|
15
|
+
PT1M: '1m',
|
|
16
|
+
PT3M: '3m',
|
|
17
|
+
PT5M: '5m',
|
|
18
|
+
PT15M: '15m',
|
|
19
|
+
PT30M: '30m',
|
|
20
|
+
PT1H: '1h',
|
|
21
|
+
PT2H: '2h',
|
|
22
|
+
PT4H: '4h',
|
|
23
|
+
PT8H: '8h',
|
|
24
|
+
PT12H: '12h',
|
|
25
|
+
P1D: '1d',
|
|
26
|
+
P3D: '3d',
|
|
27
|
+
P1W: '1w',
|
|
28
|
+
P1M: '1M',
|
|
29
|
+
};
|
|
30
|
+
const DEFAULT_BAR_COUNT = 1000;
|
|
31
|
+
const fetchOHLCPageBackward = async (req) => {
|
|
32
|
+
const [, marketType, symbol] = decodePath(req.product_id);
|
|
33
|
+
if (!symbol)
|
|
34
|
+
throw new Error(`Unsupported product_id: ${req.product_id}`);
|
|
35
|
+
if (marketType !== 'PERPETUAL' && marketType !== 'SPOT') {
|
|
36
|
+
throw new Error(`Unsupported product_id: ${req.product_id}`);
|
|
37
|
+
}
|
|
38
|
+
const coin = symbol.split('-')[0];
|
|
39
|
+
if (!coin)
|
|
40
|
+
throw new Error(`Invalid symbol: ${symbol}`);
|
|
41
|
+
const interval = DURATION_TO_HYPERLIQUID_INTERVAL[req.duration];
|
|
42
|
+
if (!interval)
|
|
43
|
+
throw new Error(`Unsupported duration: ${req.duration}`);
|
|
44
|
+
const periodMs = convertDurationToOffset(req.duration);
|
|
45
|
+
const endTime = req.time;
|
|
46
|
+
const startTime = Math.max(0, endTime - DEFAULT_BAR_COUNT * periodMs);
|
|
47
|
+
const res = await getCandleSnapshot({
|
|
48
|
+
req: { coin, interval, startTime, endTime },
|
|
49
|
+
});
|
|
50
|
+
return (res !== null && res !== void 0 ? res : [])
|
|
51
|
+
.map((x) => {
|
|
52
|
+
const createdAtMs = x.t;
|
|
53
|
+
return {
|
|
54
|
+
series_id: req.series_id,
|
|
55
|
+
datasource_id: 'HYPERLIQUID',
|
|
56
|
+
product_id: req.product_id,
|
|
57
|
+
duration: req.duration,
|
|
58
|
+
created_at: formatTime(createdAtMs),
|
|
59
|
+
closed_at: formatTime(createdAtMs + periodMs),
|
|
60
|
+
open: x.o,
|
|
61
|
+
high: x.h,
|
|
62
|
+
low: x.l,
|
|
63
|
+
close: x.c,
|
|
64
|
+
volume: x.v,
|
|
65
|
+
open_interest: '0',
|
|
66
|
+
};
|
|
67
|
+
})
|
|
68
|
+
.filter((x) => Date.parse(x.created_at) < endTime);
|
|
69
|
+
};
|
|
70
|
+
provideOHLCService(terminal, {
|
|
71
|
+
product_id_prefix: 'HYPERLIQUID/PERPETUAL/',
|
|
72
|
+
duration_list: Object.keys(DURATION_TO_HYPERLIQUID_INTERVAL),
|
|
73
|
+
direction: 'backward',
|
|
74
|
+
}, fetchOHLCPageBackward, INGEST_SERVICE_OPTIONS);
|
|
75
|
+
provideOHLCService(terminal, {
|
|
76
|
+
product_id_prefix: 'HYPERLIQUID/SPOT/',
|
|
77
|
+
duration_list: Object.keys(DURATION_TO_HYPERLIQUID_INTERVAL),
|
|
78
|
+
direction: 'backward',
|
|
79
|
+
}, fetchOHLCPageBackward, INGEST_SERVICE_OPTIONS);
|
|
80
|
+
//# sourceMappingURL=ohlc-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ohlc-service.js","sourceRoot":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AC,CAAC;YACT,IAAI,EAAE,CAAC,CAAC,CAAC;YACT,GAAG,EAAE,CAAC,CAAC,CAAC;YACR,KAAK,EAAE,CAAC,CAAC,CAAC;YACV,MAAM,EAAE,CAAC,CAAC,CAAC;YACX,aAAa,EAAE,GAAG;SACnB,CAAC;IACJ,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,kBAAkB,CAChB,QAAQ,EACR;IACE,iBAAiB,EAAE,wBAAwB;IAC3C,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC;IAC5D,SAAS,EAAE,UAAU;CACtB,EACD,qBAAqB,EACrB,sBAAsB,CACvB,CAAC;AAEF,kBAAkB,CAChB,QAAQ,EACR;IACE,iBAAiB,EAAE,mBAAmB;IACtC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC;IAC5D,SAAS,EAAE,UAAU;CACtB,EACD,qBAAqB,EACrB,sBAAsB,CACvB,CAAC","sourcesContent":["import { IOHLC } from '@yuants/data-ohlc';\nimport { provideOHLCService } from '@yuants/exchange';\nimport { IServiceOptions, Terminal } from '@yuants/protocol';\nimport { convertDurationToOffset, decodePath, formatTime } from '@yuants/utils';\nimport { getCandleSnapshot } from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst INGEST_SERVICE_OPTIONS: IServiceOptions = {\n concurrent: 1,\n max_pending_requests: 20,\n ingress_token_capacity: 2,\n ingress_token_refill_interval: 1000,\n egress_token_capacity: 1,\n egress_token_refill_interval: 1000,\n};\n\nconst DURATION_TO_HYPERLIQUID_INTERVAL: Record<string, string> = {\n PT1M: '1m',\n PT3M: '3m',\n PT5M: '5m',\n PT15M: '15m',\n PT30M: '30m',\n PT1H: '1h',\n PT2H: '2h',\n PT4H: '4h',\n PT8H: '8h',\n PT12H: '12h',\n P1D: '1d',\n P3D: '3d',\n P1W: '1w',\n P1M: '1M',\n};\n\nconst DEFAULT_BAR_COUNT = 1000;\n\nconst fetchOHLCPageBackward = async (req: {\n product_id: string;\n duration: string;\n time: number;\n series_id: string;\n}): Promise<IOHLC[]> => {\n const [, marketType, symbol] = decodePath(req.product_id);\n if (!symbol) throw new Error(`Unsupported product_id: ${req.product_id}`);\n if (marketType !== 'PERPETUAL' && marketType !== 'SPOT') {\n throw new Error(`Unsupported product_id: ${req.product_id}`);\n }\n\n const coin = symbol.split('-')[0];\n if (!coin) throw new Error(`Invalid symbol: ${symbol}`);\n\n const interval = DURATION_TO_HYPERLIQUID_INTERVAL[req.duration];\n if (!interval) throw new Error(`Unsupported duration: ${req.duration}`);\n\n const periodMs = convertDurationToOffset(req.duration);\n const endTime = req.time;\n const startTime = Math.max(0, endTime - DEFAULT_BAR_COUNT * periodMs);\n\n const res = await getCandleSnapshot({\n req: { coin, interval, startTime, endTime },\n });\n\n return (res ?? [])\n .map((x): IOHLC => {\n const createdAtMs = x.t;\n return {\n series_id: req.series_id,\n datasource_id: 'HYPERLIQUID',\n product_id: req.product_id,\n duration: req.duration,\n created_at: formatTime(createdAtMs),\n closed_at: formatTime(createdAtMs + periodMs),\n open: x.o,\n high: x.h,\n low: x.l,\n close: x.c,\n volume: x.v,\n open_interest: '0',\n };\n })\n .filter((x) => Date.parse(x.created_at) < endTime);\n};\n\nprovideOHLCService(\n terminal,\n {\n product_id_prefix: 'HYPERLIQUID/PERPETUAL/',\n duration_list: Object.keys(DURATION_TO_HYPERLIQUID_INTERVAL),\n direction: 'backward',\n },\n fetchOHLCPageBackward,\n INGEST_SERVICE_OPTIONS,\n);\n\nprovideOHLCService(\n terminal,\n {\n product_id_prefix: 'HYPERLIQUID/SPOT/',\n duration_list: Object.keys(DURATION_TO_HYPERLIQUID_INTERVAL),\n direction: 'backward',\n },\n fetchOHLCPageBackward,\n INGEST_SERVICE_OPTIONS,\n);\n"]}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,kCAAkC,CAAC;AAC1C,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,0BAA0B,CAAC;AAClC,OAAO,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,kCAAkC,CAAC;AAC1C,OAAO,yBAAyB,CAAC;AACjC,OAAO,4BAA4B,CAAC;AACpC,OAAO,0BAA0B,CAAC;AAClC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,yBAAyB,CAAC;AACjC,OAAO,kCAAkC,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAC7B,4CAA0C;AAC1C,mCAAiC;AACjC,sCAAoC;AACpC,oCAAkC;AAClC,6BAA2B","sourcesContent":["import './services/exchange';\nimport './services/markets/interest-rate';\nimport './services/markets/ohlc';\nimport './services/markets/product';\nimport './services/markets/quote';\nimport './services/quotes';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAC7B,4CAA0C;AAC1C,mCAAiC;AACjC,sCAAoC;AACpC,oCAAkC;AAClC,6BAA2B;AAC3B,mCAAiC;AACjC,4CAA0C","sourcesContent":["import './services/exchange';\nimport './services/markets/interest-rate';\nimport './services/markets/ohlc';\nimport './services/markets/product';\nimport './services/markets/quote';\nimport './services/quotes';\nimport './services/ohlc-service';\nimport './services/interest-rate-service';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interest-rate-service.d.ts","sourceRoot":"","sources":["../../src/services/interest-rate-service.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const exchange_1 = require("@yuants/exchange");
|
|
4
|
+
const protocol_1 = require("@yuants/protocol");
|
|
5
|
+
const utils_1 = require("@yuants/utils");
|
|
6
|
+
const public_api_1 = require("../api/public-api");
|
|
7
|
+
const terminal = protocol_1.Terminal.fromNodeEnv();
|
|
8
|
+
const INGEST_SERVICE_OPTIONS = {
|
|
9
|
+
concurrent: 1,
|
|
10
|
+
max_pending_requests: 20,
|
|
11
|
+
ingress_token_capacity: 2,
|
|
12
|
+
ingress_token_refill_interval: 1000,
|
|
13
|
+
egress_token_capacity: 1,
|
|
14
|
+
egress_token_refill_interval: 1000,
|
|
15
|
+
};
|
|
16
|
+
const WINDOW_MS = 30 * 24 * 3600000;
|
|
17
|
+
const fetchInterestRateBackward = async (req) => {
|
|
18
|
+
const [, marketType, symbol] = (0, utils_1.decodePath)(req.product_id);
|
|
19
|
+
if (marketType !== 'PERPETUAL' || !symbol)
|
|
20
|
+
throw new Error(`Unsupported product_id: ${req.product_id}`);
|
|
21
|
+
const coin = symbol.split('-')[0];
|
|
22
|
+
if (!coin)
|
|
23
|
+
throw new Error(`Invalid symbol: ${symbol}`);
|
|
24
|
+
const endTime = req.time;
|
|
25
|
+
const startTime = Math.max(0, endTime - WINDOW_MS);
|
|
26
|
+
const res = await (0, public_api_1.getHistoricalFundingRates)({ coin, startTime, endTime });
|
|
27
|
+
return (res !== null && res !== void 0 ? res : [])
|
|
28
|
+
.map((v) => {
|
|
29
|
+
const ms = v.time;
|
|
30
|
+
const rate = Number(v.fundingRate);
|
|
31
|
+
return {
|
|
32
|
+
series_id: req.series_id,
|
|
33
|
+
product_id: req.product_id,
|
|
34
|
+
datasource_id: 'HYPERLIQUID',
|
|
35
|
+
created_at: (0, utils_1.formatTime)(ms),
|
|
36
|
+
long_rate: `${-rate}`,
|
|
37
|
+
short_rate: `${rate}`,
|
|
38
|
+
settlement_price: '',
|
|
39
|
+
};
|
|
40
|
+
})
|
|
41
|
+
.filter((x) => Date.parse(x.created_at) < endTime);
|
|
42
|
+
};
|
|
43
|
+
(0, exchange_1.provideInterestRateService)(terminal, {
|
|
44
|
+
product_id_prefix: 'HYPERLIQUID/PERPETUAL/',
|
|
45
|
+
direction: 'backward',
|
|
46
|
+
}, fetchInterestRateBackward, INGEST_SERVICE_OPTIONS);
|
|
47
|
+
//# sourceMappingURL=interest-rate-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interest-rate-service.js","sourceRoot":"","sources":["../../src/services/interest-rate-service.ts"],"names":[],"mappings":";;AACA,+CAA8D;AAC9D,+CAA6D;AAC7D,yCAAuD;AACvD,kDAA8D;AAE9D,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,MAAM,sBAAsB,GAAoB;IAC9C,UAAU,EAAE,CAAC;IACb,oBAAoB,EAAE,EAAE;IACxB,sBAAsB,EAAE,CAAC;IACzB,6BAA6B,EAAE,IAAI;IACnC,qBAAqB,EAAE,CAAC;IACxB,4BAA4B,EAAE,IAAI;CACnC,CAAC;AAEF,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,GAAG,OAAQ,CAAC;AAErC,MAAM,yBAAyB,GAAG,KAAK,EAAE,GAIxC,EAA4B,EAAE;IAC7B,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,IAAA,kBAAU,EAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1D,IAAI,UAAU,KAAK,WAAW,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAExG,MAAM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rate';\nimport { provideInterestRateService } from '@yuants/exchange';\nimport { IServiceOptions, Terminal } from '@yuants/protocol';\nimport { decodePath, formatTime } from '@yuants/utils';\nimport { getHistoricalFundingRates } from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst INGEST_SERVICE_OPTIONS: IServiceOptions = {\n concurrent: 1,\n max_pending_requests: 20,\n ingress_token_capacity: 2,\n ingress_token_refill_interval: 1000,\n egress_token_capacity: 1,\n egress_token_refill_interval: 1000,\n};\n\nconst WINDOW_MS = 30 * 24 * 3600_000;\n\nconst fetchInterestRateBackward = async (req: {\n product_id: string;\n time: number;\n series_id: string;\n}): Promise<IInterestRate[]> => {\n const [, marketType, symbol] = decodePath(req.product_id);\n if (marketType !== 'PERPETUAL' || !symbol) throw new Error(`Unsupported product_id: ${req.product_id}`);\n\n const coin = symbol.split('-')[0];\n if (!coin) throw new Error(`Invalid symbol: ${symbol}`);\n\n const endTime = req.time;\n const startTime = Math.max(0, endTime - WINDOW_MS);\n\n const res = await getHistoricalFundingRates({ coin, startTime, endTime });\n\n return (res ?? [])\n .map((v): IInterestRate => {\n const ms = v.time;\n const rate = Number(v.fundingRate);\n return {\n series_id: req.series_id,\n product_id: req.product_id,\n datasource_id: 'HYPERLIQUID',\n created_at: formatTime(ms),\n long_rate: `${-rate}`,\n short_rate: `${rate}`,\n settlement_price: '',\n };\n })\n .filter((x) => Date.parse(x.created_at) < endTime);\n};\n\nprovideInterestRateService(\n terminal,\n {\n product_id_prefix: 'HYPERLIQUID/PERPETUAL/',\n direction: 'backward',\n },\n fetchInterestRateBackward,\n INGEST_SERVICE_OPTIONS,\n);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ohlc-service.d.ts","sourceRoot":"","sources":["../../src/services/ohlc-service.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const exchange_1 = require("@yuants/exchange");
|
|
4
|
+
const protocol_1 = require("@yuants/protocol");
|
|
5
|
+
const utils_1 = require("@yuants/utils");
|
|
6
|
+
const public_api_1 = require("../api/public-api");
|
|
7
|
+
const terminal = protocol_1.Terminal.fromNodeEnv();
|
|
8
|
+
const INGEST_SERVICE_OPTIONS = {
|
|
9
|
+
concurrent: 1,
|
|
10
|
+
max_pending_requests: 20,
|
|
11
|
+
ingress_token_capacity: 2,
|
|
12
|
+
ingress_token_refill_interval: 1000,
|
|
13
|
+
egress_token_capacity: 1,
|
|
14
|
+
egress_token_refill_interval: 1000,
|
|
15
|
+
};
|
|
16
|
+
const DURATION_TO_HYPERLIQUID_INTERVAL = {
|
|
17
|
+
PT1M: '1m',
|
|
18
|
+
PT3M: '3m',
|
|
19
|
+
PT5M: '5m',
|
|
20
|
+
PT15M: '15m',
|
|
21
|
+
PT30M: '30m',
|
|
22
|
+
PT1H: '1h',
|
|
23
|
+
PT2H: '2h',
|
|
24
|
+
PT4H: '4h',
|
|
25
|
+
PT8H: '8h',
|
|
26
|
+
PT12H: '12h',
|
|
27
|
+
P1D: '1d',
|
|
28
|
+
P3D: '3d',
|
|
29
|
+
P1W: '1w',
|
|
30
|
+
P1M: '1M',
|
|
31
|
+
};
|
|
32
|
+
const DEFAULT_BAR_COUNT = 1000;
|
|
33
|
+
const fetchOHLCPageBackward = async (req) => {
|
|
34
|
+
const [, marketType, symbol] = (0, utils_1.decodePath)(req.product_id);
|
|
35
|
+
if (!symbol)
|
|
36
|
+
throw new Error(`Unsupported product_id: ${req.product_id}`);
|
|
37
|
+
if (marketType !== 'PERPETUAL' && marketType !== 'SPOT') {
|
|
38
|
+
throw new Error(`Unsupported product_id: ${req.product_id}`);
|
|
39
|
+
}
|
|
40
|
+
const coin = symbol.split('-')[0];
|
|
41
|
+
if (!coin)
|
|
42
|
+
throw new Error(`Invalid symbol: ${symbol}`);
|
|
43
|
+
const interval = DURATION_TO_HYPERLIQUID_INTERVAL[req.duration];
|
|
44
|
+
if (!interval)
|
|
45
|
+
throw new Error(`Unsupported duration: ${req.duration}`);
|
|
46
|
+
const periodMs = (0, utils_1.convertDurationToOffset)(req.duration);
|
|
47
|
+
const endTime = req.time;
|
|
48
|
+
const startTime = Math.max(0, endTime - DEFAULT_BAR_COUNT * periodMs);
|
|
49
|
+
const res = await (0, public_api_1.getCandleSnapshot)({
|
|
50
|
+
req: { coin, interval, startTime, endTime },
|
|
51
|
+
});
|
|
52
|
+
return (res !== null && res !== void 0 ? res : [])
|
|
53
|
+
.map((x) => {
|
|
54
|
+
const createdAtMs = x.t;
|
|
55
|
+
return {
|
|
56
|
+
series_id: req.series_id,
|
|
57
|
+
datasource_id: 'HYPERLIQUID',
|
|
58
|
+
product_id: req.product_id,
|
|
59
|
+
duration: req.duration,
|
|
60
|
+
created_at: (0, utils_1.formatTime)(createdAtMs),
|
|
61
|
+
closed_at: (0, utils_1.formatTime)(createdAtMs + periodMs),
|
|
62
|
+
open: x.o,
|
|
63
|
+
high: x.h,
|
|
64
|
+
low: x.l,
|
|
65
|
+
close: x.c,
|
|
66
|
+
volume: x.v,
|
|
67
|
+
open_interest: '0',
|
|
68
|
+
};
|
|
69
|
+
})
|
|
70
|
+
.filter((x) => Date.parse(x.created_at) < endTime);
|
|
71
|
+
};
|
|
72
|
+
(0, exchange_1.provideOHLCService)(terminal, {
|
|
73
|
+
product_id_prefix: 'HYPERLIQUID/PERPETUAL/',
|
|
74
|
+
duration_list: Object.keys(DURATION_TO_HYPERLIQUID_INTERVAL),
|
|
75
|
+
direction: 'backward',
|
|
76
|
+
}, fetchOHLCPageBackward, INGEST_SERVICE_OPTIONS);
|
|
77
|
+
(0, exchange_1.provideOHLCService)(terminal, {
|
|
78
|
+
product_id_prefix: 'HYPERLIQUID/SPOT/',
|
|
79
|
+
duration_list: Object.keys(DURATION_TO_HYPERLIQUID_INTERVAL),
|
|
80
|
+
direction: 'backward',
|
|
81
|
+
}, fetchOHLCPageBackward, INGEST_SERVICE_OPTIONS);
|
|
82
|
+
//# sourceMappingURL=ohlc-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ohlc-service.js","sourceRoot":"","sources":["../../src/services/ohlc-service.ts"],"names":[],"mappings":";;AACA,+CAAsD;AACtD,+CAA6D;AAC7D,yCAAgF;AAChF,kDAAsD;AAEtD,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,MAAM,sBAAsB,GAAoB;IAC9C,UAAU,EAAE,CAAC;IACb,oBAAoB,EAAE,EAAE;IACxB,sBAAsB,EAAE,CAAC;IACzB,6BAA6B,EAAE,IAAI;IACnC,qBAAqB,EAAE,CAAC;IACxB,4BAA4B,EAAE,IAAI;CACnC,CAAC;AAEF,MAAM,gCAAgC,GAA2B;IAC/D,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;IACZ,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;CACV,CAAC;AAEF,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,MAAM,qBAAqB,GAAG,KAAK,EAAE,GAKpC,EAAoB,EAAE;IACrB,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,IAAA,kBAAU,EAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1D,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1E,IAAI,UAAU,KAAK,WAAW,IAAI,UAAU,KAAK,MAAM,EAAE;QACvD,MAAM,IAAI,KAAK,CAAC,2BAA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,CAAC,CAAC,CAAC;YACT,GAAG,EAAE,CAAC,CAAC,CAAC;YACR,KAAK,EAAE,CAAC,CAAC,CAAC;YACV,MAAM,EAAE,CAAC,CAAC,CAAC;YACX,aAAa,EAAE,GAAG;SACnB,CAAC;IACJ,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,IAAA,6BAAkB,EAChB,QAAQ,EACR;IACE,iBAAiB,EAAE,wBAAwB;IAC3C,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC;IAC5D,SAAS,EAAE,UAAU;CACtB,EACD,qBAAqB,EACrB,sBAAsB,CACvB,CAAC;AAEF,IAAA,6BAAkB,EAChB,QAAQ,EACR;IACE,iBAAiB,EAAE,mBAAmB;IACtC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC;IAC5D,SAAS,EAAE,UAAU;CACtB,EACD,qBAAqB,EACrB,sBAAsB,CACvB,CAAC","sourcesContent":["import { IOHLC } from '@yuants/data-ohlc';\nimport { provideOHLCService } from '@yuants/exchange';\nimport { IServiceOptions, Terminal } from '@yuants/protocol';\nimport { convertDurationToOffset, decodePath, formatTime } from '@yuants/utils';\nimport { getCandleSnapshot } from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst INGEST_SERVICE_OPTIONS: IServiceOptions = {\n concurrent: 1,\n max_pending_requests: 20,\n ingress_token_capacity: 2,\n ingress_token_refill_interval: 1000,\n egress_token_capacity: 1,\n egress_token_refill_interval: 1000,\n};\n\nconst DURATION_TO_HYPERLIQUID_INTERVAL: Record<string, string> = {\n PT1M: '1m',\n PT3M: '3m',\n PT5M: '5m',\n PT15M: '15m',\n PT30M: '30m',\n PT1H: '1h',\n PT2H: '2h',\n PT4H: '4h',\n PT8H: '8h',\n PT12H: '12h',\n P1D: '1d',\n P3D: '3d',\n P1W: '1w',\n P1M: '1M',\n};\n\nconst DEFAULT_BAR_COUNT = 1000;\n\nconst fetchOHLCPageBackward = async (req: {\n product_id: string;\n duration: string;\n time: number;\n series_id: string;\n}): Promise<IOHLC[]> => {\n const [, marketType, symbol] = decodePath(req.product_id);\n if (!symbol) throw new Error(`Unsupported product_id: ${req.product_id}`);\n if (marketType !== 'PERPETUAL' && marketType !== 'SPOT') {\n throw new Error(`Unsupported product_id: ${req.product_id}`);\n }\n\n const coin = symbol.split('-')[0];\n if (!coin) throw new Error(`Invalid symbol: ${symbol}`);\n\n const interval = DURATION_TO_HYPERLIQUID_INTERVAL[req.duration];\n if (!interval) throw new Error(`Unsupported duration: ${req.duration}`);\n\n const periodMs = convertDurationToOffset(req.duration);\n const endTime = req.time;\n const startTime = Math.max(0, endTime - DEFAULT_BAR_COUNT * periodMs);\n\n const res = await getCandleSnapshot({\n req: { coin, interval, startTime, endTime },\n });\n\n return (res ?? [])\n .map((x): IOHLC => {\n const createdAtMs = x.t;\n return {\n series_id: req.series_id,\n datasource_id: 'HYPERLIQUID',\n product_id: req.product_id,\n duration: req.duration,\n created_at: formatTime(createdAtMs),\n closed_at: formatTime(createdAtMs + periodMs),\n open: x.o,\n high: x.h,\n low: x.l,\n close: x.c,\n volume: x.v,\n open_interest: '0',\n };\n })\n .filter((x) => Date.parse(x.created_at) < endTime);\n};\n\nprovideOHLCService(\n terminal,\n {\n product_id_prefix: 'HYPERLIQUID/PERPETUAL/',\n duration_list: Object.keys(DURATION_TO_HYPERLIQUID_INTERVAL),\n direction: 'backward',\n },\n fetchOHLCPageBackward,\n INGEST_SERVICE_OPTIONS,\n);\n\nprovideOHLCService(\n terminal,\n {\n product_id_prefix: 'HYPERLIQUID/SPOT/',\n duration_list: Object.keys(DURATION_TO_HYPERLIQUID_INTERVAL),\n direction: 'backward',\n },\n fetchOHLCPageBackward,\n INGEST_SERVICE_OPTIONS,\n);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuants/vendor-hyperliquid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -8,23 +8,23 @@
|
|
|
8
8
|
"temp"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@yuants/cache": "0.3.
|
|
12
|
-
"@yuants/protocol": "0.53.
|
|
13
|
-
"@yuants/transfer": "0.2.
|
|
14
|
-
"@yuants/data-account": "0.11.
|
|
15
|
-
"@yuants/utils": "0.
|
|
16
|
-
"@yuants/sql": "0.9.
|
|
17
|
-
"@yuants/data-product": "0.5.
|
|
18
|
-
"@yuants/data-interest-rate": "0.
|
|
19
|
-
"@yuants/data-order": "0.7.
|
|
20
|
-
"@yuants/data-series": "0.3.
|
|
21
|
-
"@yuants/data-quote": "0.4.
|
|
22
|
-
"@yuants/exchange": "0.8.
|
|
11
|
+
"@yuants/cache": "0.3.5",
|
|
12
|
+
"@yuants/protocol": "0.53.4",
|
|
13
|
+
"@yuants/transfer": "0.2.41",
|
|
14
|
+
"@yuants/data-account": "0.11.1",
|
|
15
|
+
"@yuants/utils": "0.16.0",
|
|
16
|
+
"@yuants/sql": "0.9.32",
|
|
17
|
+
"@yuants/data-product": "0.5.2",
|
|
18
|
+
"@yuants/data-interest-rate": "0.2.0",
|
|
19
|
+
"@yuants/data-order": "0.7.2",
|
|
20
|
+
"@yuants/data-series": "0.3.54",
|
|
21
|
+
"@yuants/data-quote": "0.4.1",
|
|
22
|
+
"@yuants/exchange": "0.8.2",
|
|
23
23
|
"rxjs": "~7.5.6",
|
|
24
24
|
"hyperliquid": "~1.6.2",
|
|
25
25
|
"ethers": "~6.13.5",
|
|
26
26
|
"@msgpack/msgpack": "~3.1.2",
|
|
27
|
-
"@yuants/data-ohlc": "0.
|
|
27
|
+
"@yuants/data-ohlc": "0.5.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@microsoft/api-extractor": "~7.30.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@rushstack/heft-node-rig": "~1.10.7",
|
|
34
34
|
"@types/heft-jest": "1.0.3",
|
|
35
35
|
"@types/node": "22",
|
|
36
|
-
"@yuants/extension": "0.2.
|
|
36
|
+
"@yuants/extension": "0.2.33",
|
|
37
37
|
"@yuants/tool-kit": "0.2.1",
|
|
38
38
|
"typescript": "~4.7.4",
|
|
39
39
|
"ts-node": "~10.9.2"
|
package/temp/package-deps.json
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"apps/vendor-hyperliquid/AGENTS.md": "f0f3df594ce55fbaf78fb040f2850d1abee3449a",
|
|
3
|
-
"apps/vendor-hyperliquid/CHANGELOG.json": "
|
|
4
|
-
"apps/vendor-hyperliquid/CHANGELOG.md": "
|
|
3
|
+
"apps/vendor-hyperliquid/CHANGELOG.json": "f14c2b209a66306af1d4921730f9a7dbeae768ab",
|
|
4
|
+
"apps/vendor-hyperliquid/CHANGELOG.md": "092de078f56c74d5ed97445cd287c7db63be2708",
|
|
5
5
|
"apps/vendor-hyperliquid/SESSION_NOTES.md": "5969eb7dceb736977bf0b36aa24f5cc1f5585656",
|
|
6
6
|
"apps/vendor-hyperliquid/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
|
|
7
7
|
"apps/vendor-hyperliquid/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
|
|
8
8
|
"apps/vendor-hyperliquid/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
|
|
9
9
|
"apps/vendor-hyperliquid/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
|
|
10
10
|
"apps/vendor-hyperliquid/etc/vendor-hyperliquid.api.md": "66675bd88afa1fe945f0d4023984c1c9c3e60a34",
|
|
11
|
-
"apps/vendor-hyperliquid/package.json": "
|
|
11
|
+
"apps/vendor-hyperliquid/package.json": "78300ffe221a065859fb7ee5dd36073bee544f21",
|
|
12
12
|
"apps/vendor-hyperliquid/src/api/client.ts": "90eb3b63394c9729cc442e0ee5482bfd494aafdd",
|
|
13
13
|
"apps/vendor-hyperliquid/src/api/private-api.ts": "8fd176063af8f345aeab94444850e82979cef680",
|
|
14
14
|
"apps/vendor-hyperliquid/src/api/public-api.ts": "fbbb982308eea89a51b93cc21442de6ba45cfd60",
|
|
15
15
|
"apps/vendor-hyperliquid/src/api/sign.ts": "94f4e5604a01d197d164b42415b17789ab2b6889",
|
|
16
16
|
"apps/vendor-hyperliquid/src/api/types.ts": "70347eb8b5e691770073dd043788ed5fae0c3eb4",
|
|
17
17
|
"apps/vendor-hyperliquid/src/cli.ts": "9bf6b5559a6c6f33da20e74cc6c5d702c60ec891",
|
|
18
|
-
"apps/vendor-hyperliquid/src/index.ts": "
|
|
18
|
+
"apps/vendor-hyperliquid/src/index.ts": "3465b7797a0b49e2b0ff29467220e47bb587dcb6",
|
|
19
19
|
"apps/vendor-hyperliquid/src/services/accounts/perp.ts": "ee8784d7331889b97069d5b3f452340b2e19ee55",
|
|
20
20
|
"apps/vendor-hyperliquid/src/services/accounts/spot.ts": "814857d05bdda34ca7827fc69c2564db1f5f5d3d",
|
|
21
21
|
"apps/vendor-hyperliquid/src/services/exchange.ts": "e36dcefff1e239e6b44c7ea1aa0632f59cbce653",
|
|
22
|
+
"apps/vendor-hyperliquid/src/services/interest-rate-service.ts": "95dd36d49da90dda75c4e93a2dbdb38e9c28474e",
|
|
22
23
|
"apps/vendor-hyperliquid/src/services/markets/interest-rate.ts": "a93246729016cbe8486bc45b5a00aff57fab07ec",
|
|
23
24
|
"apps/vendor-hyperliquid/src/services/markets/ohlc.ts": "6cea84e64ff68ef3a760b35d2e637b66a1ca1615",
|
|
24
25
|
"apps/vendor-hyperliquid/src/services/markets/product.ts": "406d7686f062288a63bcc2aa3146b0f0942ad724",
|
|
25
26
|
"apps/vendor-hyperliquid/src/services/markets/quote.ts": "9f7391d6253a1ff46cab63567a708954efde4f88",
|
|
27
|
+
"apps/vendor-hyperliquid/src/services/ohlc-service.ts": "ba7652ab67998b432d546cb5a7224e0fd8ceacc4",
|
|
26
28
|
"apps/vendor-hyperliquid/src/services/orders/cancelOrder.ts": "eeb8b166a712c64df45873b83b0587238c249992",
|
|
27
29
|
"apps/vendor-hyperliquid/src/services/orders/listOrders.ts": "9ffd16181d23d98d5397e76b0a3f63f2bf7792ce",
|
|
28
30
|
"apps/vendor-hyperliquid/src/services/orders/modifyOrder.ts": "01fc9d965578f216f6e5beae4e52f7640c1d4a28",
|
|
@@ -31,19 +33,19 @@
|
|
|
31
33
|
"apps/vendor-hyperliquid/src/services/utils.ts": "a115e2f972368033e6eb7325602092dbd448c9c3",
|
|
32
34
|
"apps/vendor-hyperliquid/tsconfig.json": "fc376462cd03b4f9676999e8b78dd8e7e90bbbd3",
|
|
33
35
|
"apps/vendor-hyperliquid/.rush/temp/shrinkwrap-deps.json": "d9e7e51571c2f9512f75f378953ef8175952ed5c",
|
|
34
|
-
"libraries/cache/temp/package-deps.json": "
|
|
35
|
-
"libraries/protocol/temp/package-deps.json": "
|
|
36
|
-
"libraries/transfer/temp/package-deps.json": "
|
|
37
|
-
"libraries/data-account/temp/package-deps.json": "
|
|
38
|
-
"libraries/utils/temp/package-deps.json": "
|
|
39
|
-
"libraries/sql/temp/package-deps.json": "
|
|
40
|
-
"libraries/data-product/temp/package-deps.json": "
|
|
41
|
-
"libraries/data-interest-rate/temp/package-deps.json": "
|
|
42
|
-
"libraries/data-order/temp/package-deps.json": "
|
|
43
|
-
"libraries/data-series/temp/package-deps.json": "
|
|
44
|
-
"libraries/data-quote/temp/package-deps.json": "
|
|
45
|
-
"libraries/exchange/temp/package-deps.json": "
|
|
46
|
-
"libraries/data-ohlc/temp/package-deps.json": "
|
|
47
|
-
"libraries/extension/temp/package-deps.json": "
|
|
36
|
+
"libraries/cache/temp/package-deps.json": "2e6c6db8f750a2e173a3c4b9a57d22fbd6f9181d",
|
|
37
|
+
"libraries/protocol/temp/package-deps.json": "a30b39ceb4cd530ed6bc4e97433f995b026b26d9",
|
|
38
|
+
"libraries/transfer/temp/package-deps.json": "6d0942aa4c50b35a8e47a500fe494fb4a08a99e5",
|
|
39
|
+
"libraries/data-account/temp/package-deps.json": "363f171a8ec4ae558e4b20626b06bc8ae145ce8a",
|
|
40
|
+
"libraries/utils/temp/package-deps.json": "7a9e2336d7ad44e827d81e9722767d6cdf99fc1f",
|
|
41
|
+
"libraries/sql/temp/package-deps.json": "252d819797cb0a4bbc579075867624b05b19dabb",
|
|
42
|
+
"libraries/data-product/temp/package-deps.json": "4f525fda6d65677f9fbdcd1b4480970dd6ff9e5b",
|
|
43
|
+
"libraries/data-interest-rate/temp/package-deps.json": "0aa2057c1c5c432be87e97b8df22984bdcab307c",
|
|
44
|
+
"libraries/data-order/temp/package-deps.json": "daedd350fe85f0564f7739c73689fb09664132de",
|
|
45
|
+
"libraries/data-series/temp/package-deps.json": "71b373ec83ce1188001e341aefaca704aa4a5c38",
|
|
46
|
+
"libraries/data-quote/temp/package-deps.json": "07e342d9dba4d5f5d89b62c74f079425b560cb1f",
|
|
47
|
+
"libraries/exchange/temp/package-deps.json": "5267eb70cd2e7df4a645f94133ad3428b52c567e",
|
|
48
|
+
"libraries/data-ohlc/temp/package-deps.json": "2115e384567d1b0958c085f455da9bed5a638780",
|
|
49
|
+
"libraries/extension/temp/package-deps.json": "fcddc4a668ecf969ca593c67ff02543fe69a6829",
|
|
48
50
|
"tools/toolkit/temp/package-deps.json": "23e053490eb8feade23e4d45de4e54883e322711"
|
|
49
51
|
}
|