@pear-protocol/exchanges-sdk 0.0.17 → 0.1.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/README.md +73 -137
- package/dist/client/base-ws.d.ts +30 -0
- package/dist/client/base-ws.js +113 -0
- package/dist/client/binance/exchange-ws.d.ts +19 -0
- package/dist/client/binance/exchange-ws.js +26 -0
- package/dist/{account/exchanges → client}/binance/rest.d.ts +2 -6
- package/dist/{account/exchanges → client}/binance/rest.js +4 -11
- package/dist/client/binance/types.d.ts +68 -0
- package/dist/client/binance/types.js +1 -0
- package/dist/client/binance/ws.d.ts +30 -0
- package/dist/client/binance/ws.js +54 -0
- package/dist/client/bybit/exchange-ws.d.ts +20 -0
- package/dist/client/bybit/exchange-ws.js +28 -0
- package/dist/{account/exchanges → client}/bybit/rest.js +3 -2
- package/dist/{account/exchanges → client}/bybit/types.d.ts +1 -9
- package/dist/client/bybit/types.js +1 -0
- package/dist/client/bybit/ws.d.ts +17 -0
- package/dist/client/bybit/ws.js +50 -0
- package/dist/client/exchange-ws.d.ts +12 -0
- package/dist/client/exchange-ws.js +10 -0
- package/dist/client/hyperliquid/exchange-ws.d.ts +15 -0
- package/dist/client/hyperliquid/exchange-ws.js +21 -0
- package/dist/client/hyperliquid/rest.d.ts +3 -0
- package/dist/client/hyperliquid/rest.js +12 -0
- package/dist/{account/exchanges → client}/hyperliquid/types.d.ts +18 -39
- package/dist/client/hyperliquid/types.js +1 -0
- package/dist/client/hyperliquid/ws.d.ts +10 -0
- package/dist/client/hyperliquid/ws.js +16 -0
- package/dist/client/index.d.ts +31 -0
- package/dist/client/index.js +47 -0
- package/dist/client/lighter/constants.d.ts +4 -0
- package/dist/client/lighter/constants.js +4 -0
- package/dist/client/lighter/exchange-ws.d.ts +15 -0
- package/dist/client/lighter/exchange-ws.js +21 -0
- package/dist/client/lighter/rest.d.ts +56 -0
- package/dist/client/lighter/rest.js +27 -0
- package/dist/client/lighter/types.d.ts +32 -0
- package/dist/client/lighter/types.js +1 -0
- package/dist/client/lighter/ws.d.ts +10 -0
- package/dist/client/lighter/ws.js +17 -0
- package/dist/client/okx/exchange-ws.d.ts +20 -0
- package/dist/client/okx/exchange-ws.js +28 -0
- package/dist/{account/exchanges → client}/okx/rest.js +2 -2
- package/dist/{account/exchanges → client}/okx/types.d.ts +1 -10
- package/dist/client/okx/types.js +1 -0
- package/dist/client/okx/ws.d.ts +17 -0
- package/dist/client/okx/ws.js +61 -0
- package/dist/helper/factory.d.ts +10 -0
- package/dist/helper/factory.js +12 -0
- package/dist/helper/index.d.ts +7 -0
- package/dist/helper/index.js +2 -0
- package/dist/helper/lighter/ethereum/abi.d.ts +66 -0
- package/dist/helper/lighter/ethereum/abi.js +40 -0
- package/dist/helper/lighter/ethereum/index.d.ts +8 -0
- package/dist/helper/lighter/ethereum/index.js +34 -0
- package/dist/helper/lighter/ethereum/types.d.ts +23 -0
- package/dist/helper/lighter/ethereum/types.js +1 -0
- package/dist/helper/lighter/helper.d.ts +9 -0
- package/dist/helper/lighter/helper.js +67 -0
- package/dist/helper/lighter/index.d.ts +6 -0
- package/dist/helper/lighter/index.js +2 -0
- package/dist/helper/lighter/types.d.ts +63 -0
- package/dist/helper/lighter/types.js +35 -0
- package/dist/helper/types.d.ts +11 -0
- package/dist/helper/types.js +1 -0
- package/dist/index.d.ts +37 -24
- package/dist/index.js +6 -21
- package/dist/sdk.d.ts +43 -0
- package/dist/sdk.js +52 -0
- package/dist/syncer/base.d.ts +33 -0
- package/dist/syncer/base.js +14 -0
- package/dist/syncer/index.d.ts +18 -0
- package/dist/syncer/index.js +1 -0
- package/dist/tracker/base.d.ts +79 -0
- package/dist/tracker/base.js +120 -0
- package/dist/tracker/binance/const.d.ts +4 -0
- package/dist/tracker/binance/const.js +4 -0
- package/dist/{account/exchanges → tracker}/binance/mapper.d.ts +4 -1
- package/dist/{account/exchanges → tracker}/binance/mapper.js +7 -6
- package/dist/tracker/binance/tracker.d.ts +60 -0
- package/dist/tracker/binance/tracker.js +181 -0
- package/dist/tracker/binance/types.d.ts +6 -0
- package/dist/{account/exchanges → tracker}/bybit/mapper.d.ts +5 -3
- package/dist/{account/exchanges → tracker}/bybit/mapper.js +11 -10
- package/dist/tracker/bybit/tracker.d.ts +51 -0
- package/dist/tracker/bybit/tracker.js +138 -0
- package/dist/tracker/bybit/types.d.ts +7 -0
- package/dist/{account/exchanges → tracker}/hyperliquid/mapper.d.ts +6 -4
- package/dist/{account/exchanges → tracker}/hyperliquid/mapper.js +18 -16
- package/dist/tracker/hyperliquid/tracker.d.ts +62 -0
- package/dist/tracker/hyperliquid/tracker.js +219 -0
- package/dist/tracker/hyperliquid/types.d.ts +23 -0
- package/dist/tracker/index.d.ts +38 -0
- package/dist/tracker/index.js +81 -0
- package/dist/tracker/lighter/const.d.ts +3 -0
- package/dist/tracker/lighter/const.js +3 -0
- package/dist/tracker/lighter/mapper.d.ts +16 -0
- package/dist/tracker/lighter/mapper.js +77 -0
- package/dist/tracker/lighter/tracker.d.ts +53 -0
- package/dist/tracker/lighter/tracker.js +150 -0
- package/dist/tracker/lighter/types.d.ts +16 -0
- package/dist/tracker/lighter/types.js +6 -0
- package/dist/{account/exchanges → tracker}/okx/mapper.d.ts +5 -3
- package/dist/{account/exchanges → tracker}/okx/mapper.js +11 -10
- package/dist/tracker/okx/tracker.d.ts +51 -0
- package/dist/tracker/okx/tracker.js +134 -0
- package/dist/tracker/okx/types.d.ts +8 -0
- package/dist/tracker/types.d.ts +63 -0
- package/dist/{account → tracker}/types.js +6 -4
- package/dist/tracker/utils.d.ts +11 -0
- package/dist/{account → tracker}/utils.js +0 -2
- package/dist/types.d.ts +50 -0
- package/dist/types.js +1 -0
- package/package.json +8 -4
- package/dist/account/account-manager.d.ts +0 -31
- package/dist/account/account-manager.js +0 -119
- package/dist/account/exchange-account.d.ts +0 -35
- package/dist/account/exchange-account.js +0 -158
- package/dist/account/exchanges/base.d.ts +0 -48
- package/dist/account/exchanges/base.js +0 -41
- package/dist/account/exchanges/binance/asset-tracker.d.ts +0 -26
- package/dist/account/exchanges/binance/asset-tracker.js +0 -38
- package/dist/account/exchanges/binance/const.d.ts +0 -10
- package/dist/account/exchanges/binance/const.js +0 -10
- package/dist/account/exchanges/binance/orchestrator.d.ts +0 -31
- package/dist/account/exchanges/binance/orchestrator.js +0 -91
- package/dist/account/exchanges/binance/state-handler.d.ts +0 -33
- package/dist/account/exchanges/binance/state-handler.js +0 -113
- package/dist/account/exchanges/binance/types.d.ts +0 -5
- package/dist/account/exchanges/binance/ws.d.ts +0 -23
- package/dist/account/exchanges/binance/ws.js +0 -69
- package/dist/account/exchanges/bybit/asset-tracker.d.ts +0 -26
- package/dist/account/exchanges/bybit/asset-tracker.js +0 -37
- package/dist/account/exchanges/bybit/const.d.ts +0 -7
- package/dist/account/exchanges/bybit/const.js +0 -7
- package/dist/account/exchanges/bybit/orchestrator.d.ts +0 -22
- package/dist/account/exchanges/bybit/orchestrator.js +0 -66
- package/dist/account/exchanges/bybit/state-handler.d.ts +0 -23
- package/dist/account/exchanges/bybit/state-handler.js +0 -70
- package/dist/account/exchanges/bybit/ws.d.ts +0 -19
- package/dist/account/exchanges/bybit/ws.js +0 -83
- package/dist/account/exchanges/hyperliquid/asset-tracker.d.ts +0 -35
- package/dist/account/exchanges/hyperliquid/asset-tracker.js +0 -83
- package/dist/account/exchanges/hyperliquid/orchestrator.d.ts +0 -26
- package/dist/account/exchanges/hyperliquid/orchestrator.js +0 -102
- package/dist/account/exchanges/hyperliquid/state-handler.d.ts +0 -25
- package/dist/account/exchanges/hyperliquid/state-handler.js +0 -104
- package/dist/account/exchanges/index.d.ts +0 -11
- package/dist/account/exchanges/index.js +0 -32
- package/dist/account/exchanges/okx/asset-tracker.d.ts +0 -26
- package/dist/account/exchanges/okx/asset-tracker.js +0 -34
- package/dist/account/exchanges/okx/const.d.ts +0 -7
- package/dist/account/exchanges/okx/const.js +0 -7
- package/dist/account/exchanges/okx/orchestrator.d.ts +0 -22
- package/dist/account/exchanges/okx/orchestrator.js +0 -57
- package/dist/account/exchanges/okx/state-handler.d.ts +0 -24
- package/dist/account/exchanges/okx/state-handler.js +0 -78
- package/dist/account/exchanges/okx/ws.d.ts +0 -20
- package/dist/account/exchanges/okx/ws.js +0 -103
- package/dist/account/index.d.ts +0 -11
- package/dist/account/index.js +0 -4
- package/dist/account/types.d.ts +0 -5
- package/dist/account/utils.d.ts +0 -10
- package/dist/credentials.d.ts +0 -28
- package/dist/credentials.js +0 -46
- package/dist/types-Caz2X4h0.d.ts +0 -151
- package/dist/utils/ws.d.ts +0 -10
- package/dist/utils/ws.js +0 -42
- /package/dist/{account/exchanges → client}/bybit/rest.d.ts +0 -0
- /package/dist/{utils → client}/hmac.d.ts +0 -0
- /package/dist/{utils → client}/hmac.js +0 -0
- /package/dist/{account/exchanges → client}/okx/rest.d.ts +0 -0
- /package/dist/{account/exchanges → tracker}/binance/types.js +0 -0
- /package/dist/{account/exchanges → tracker}/bybit/types.js +0 -0
- /package/dist/{account/exchanges → tracker}/hyperliquid/const.d.ts +0 -0
- /package/dist/{account/exchanges → tracker}/hyperliquid/const.js +0 -0
- /package/dist/{account/exchanges → tracker}/hyperliquid/types.js +0 -0
- /package/dist/{account/exchanges → tracker}/okx/types.js +0 -0
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { S as StateUpdate, g as SupportedCredentials } from '../../types-Caz2X4h0.js';
|
|
2
|
-
import '@pear-protocol/types';
|
|
3
|
-
import './bybit/types.js';
|
|
4
|
-
import './hyperliquid/types.js';
|
|
5
|
-
import './okx/types.js';
|
|
6
|
-
|
|
7
|
-
type StateUpdateHandler = (update: StateUpdate) => void;
|
|
8
|
-
type ErrorHandler = (error: Error) => void;
|
|
9
|
-
type OrchestratorConfig = {
|
|
10
|
-
onStateUpdate: StateUpdateHandler;
|
|
11
|
-
onError: ErrorHandler;
|
|
12
|
-
demo: boolean;
|
|
13
|
-
};
|
|
14
|
-
interface Orchestrator {
|
|
15
|
-
stop: () => Promise<void>;
|
|
16
|
-
isConnected: boolean;
|
|
17
|
-
onAssetTracked: (coin: string) => void;
|
|
18
|
-
onAssetUntracked: (coin: string) => void;
|
|
19
|
-
trackAsset: (coin: string) => void;
|
|
20
|
-
untrackAsset: (coin: string) => boolean;
|
|
21
|
-
getTrackedCoins: () => ReadonlySet<string>;
|
|
22
|
-
start: () => Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
declare abstract class BaseOrchestrator implements Orchestrator {
|
|
25
|
-
protected onStateUpdate: StateUpdateHandler;
|
|
26
|
-
protected onError: ErrorHandler;
|
|
27
|
-
protected demo: boolean;
|
|
28
|
-
protected credentials: SupportedCredentials | null;
|
|
29
|
-
protected stopped: boolean;
|
|
30
|
-
protected trackedCoins: Set<string>;
|
|
31
|
-
constructor(config: OrchestratorConfig);
|
|
32
|
-
/** Awaitable first-time connection. Errors propagate to caller. */
|
|
33
|
-
start(): Promise<void>;
|
|
34
|
-
abstract stop(): Promise<void>;
|
|
35
|
-
abstract get isConnected(): boolean;
|
|
36
|
-
abstract onAssetTracked(coin: string): void;
|
|
37
|
-
abstract onAssetUntracked(coin: string): void;
|
|
38
|
-
/** Subclass implements the actual async init (REST fetches, WS connect, etc.) */
|
|
39
|
-
protected abstract initAsync(): Promise<void>;
|
|
40
|
-
/** Subclass cleans up connections on stop. */
|
|
41
|
-
protected abstract cleanupConnections(): void | Promise<void>;
|
|
42
|
-
trackAsset(coin: string): void;
|
|
43
|
-
untrackAsset(coin: string): boolean;
|
|
44
|
-
getTrackedCoins(): ReadonlySet<string>;
|
|
45
|
-
protected canUntrackAsset(_coin: string): boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export { BaseOrchestrator, type Orchestrator, type OrchestratorConfig };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
class BaseOrchestrator {
|
|
2
|
-
onStateUpdate;
|
|
3
|
-
onError;
|
|
4
|
-
demo;
|
|
5
|
-
credentials = null;
|
|
6
|
-
stopped = false;
|
|
7
|
-
trackedCoins = /* @__PURE__ */ new Set();
|
|
8
|
-
constructor(config) {
|
|
9
|
-
this.onStateUpdate = config.onStateUpdate;
|
|
10
|
-
this.onError = config.onError;
|
|
11
|
-
this.demo = config.demo;
|
|
12
|
-
}
|
|
13
|
-
/** Awaitable first-time connection. Errors propagate to caller. */
|
|
14
|
-
async start() {
|
|
15
|
-
await this.initAsync();
|
|
16
|
-
}
|
|
17
|
-
trackAsset(coin) {
|
|
18
|
-
if (this.trackedCoins.has(coin)) return;
|
|
19
|
-
this.trackedCoins.add(coin);
|
|
20
|
-
if (this.isConnected) {
|
|
21
|
-
this.onAssetTracked(coin);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
untrackAsset(coin) {
|
|
25
|
-
if (!this.trackedCoins.has(coin)) return true;
|
|
26
|
-
if (!this.canUntrackAsset(coin)) return false;
|
|
27
|
-
this.trackedCoins.delete(coin);
|
|
28
|
-
if (this.isConnected) {
|
|
29
|
-
this.onAssetUntracked(coin);
|
|
30
|
-
}
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
getTrackedCoins() {
|
|
34
|
-
return this.trackedCoins;
|
|
35
|
-
}
|
|
36
|
-
canUntrackAsset(_coin) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export { BaseOrchestrator };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { BinanceCredentialsDTO } from '@pear-protocol/types';
|
|
2
|
-
import { S as StateUpdate, h as TrackedAssetInfo } from '../../../types-Caz2X4h0.js';
|
|
3
|
-
import '../bybit/types.js';
|
|
4
|
-
import '../hyperliquid/types.js';
|
|
5
|
-
import '../okx/types.js';
|
|
6
|
-
|
|
7
|
-
type OnStateUpdate = (update: StateUpdate) => void;
|
|
8
|
-
type OnError = (error: Error) => void;
|
|
9
|
-
declare class BinanceAssetTracker {
|
|
10
|
-
private onStateUpdate;
|
|
11
|
-
private onError;
|
|
12
|
-
private getCreds;
|
|
13
|
-
private getDemo;
|
|
14
|
-
private trackedAssetInfos;
|
|
15
|
-
constructor(deps: {
|
|
16
|
-
onStateUpdate: OnStateUpdate;
|
|
17
|
-
onError: OnError;
|
|
18
|
-
getCreds: () => BinanceCredentialsDTO;
|
|
19
|
-
getDemo: () => boolean;
|
|
20
|
-
});
|
|
21
|
-
getInfos(): Map<string, TrackedAssetInfo>;
|
|
22
|
-
onAssetTracked(coin: string): void;
|
|
23
|
-
onAssetUntracked(coin: string): void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { BinanceAssetTracker };
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { fetchPositionRisk } from './rest';
|
|
2
|
-
|
|
3
|
-
class BinanceAssetTracker {
|
|
4
|
-
onStateUpdate;
|
|
5
|
-
onError;
|
|
6
|
-
getCreds;
|
|
7
|
-
getDemo;
|
|
8
|
-
trackedAssetInfos = /* @__PURE__ */ new Map();
|
|
9
|
-
constructor(deps) {
|
|
10
|
-
this.onStateUpdate = deps.onStateUpdate;
|
|
11
|
-
this.onError = deps.onError;
|
|
12
|
-
this.getCreds = deps.getCreds;
|
|
13
|
-
this.getDemo = deps.getDemo;
|
|
14
|
-
}
|
|
15
|
-
getInfos() {
|
|
16
|
-
return this.trackedAssetInfos;
|
|
17
|
-
}
|
|
18
|
-
onAssetTracked(coin) {
|
|
19
|
-
fetchPositionRisk(this.getCreds(), coin, this.getDemo()).then((risk) => {
|
|
20
|
-
if (!risk) return;
|
|
21
|
-
const leverage = risk.leverage;
|
|
22
|
-
const marginType = risk.marginType;
|
|
23
|
-
const info = { coin, leverage, marginType };
|
|
24
|
-
this.trackedAssetInfos.set(coin, info);
|
|
25
|
-
const trackedAssets = /* @__PURE__ */ new Map();
|
|
26
|
-
trackedAssets.set(coin, info);
|
|
27
|
-
this.onStateUpdate({ trackedAssets });
|
|
28
|
-
}).catch((err) => {
|
|
29
|
-
this.onError(err instanceof Error ? err : new Error(String(err)));
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
onAssetUntracked(coin) {
|
|
33
|
-
this.trackedAssetInfos.delete(coin);
|
|
34
|
-
this.onStateUpdate({ trackedAssets: new Map(this.trackedAssetInfos) });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { BinanceAssetTracker };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare const BASE_URL = "https://fapi.binance.com";
|
|
2
|
-
declare const BASE_URL_TESTNET = "https://testnet.binancefuture.com";
|
|
3
|
-
declare const USER_DATA_STREAM_URL = "wss://fstream.binance.com/ws";
|
|
4
|
-
declare const USER_DATA_STREAM_URL_TESTNET = "wss://stream.binancefuture.com/ws";
|
|
5
|
-
declare const WS_API_URL = "wss://ws-fapi.binance.com/ws-fapi/v1";
|
|
6
|
-
declare const WS_API_URL_TESTNET = "wss://testnet.binancefuture.com/ws-fapi/v1";
|
|
7
|
-
declare const DEFAULT_LISTEN_KEY_REFRESH_MS: number;
|
|
8
|
-
declare const DEFAULT_ACCOUNT_POLL_MS = 1000;
|
|
9
|
-
|
|
10
|
-
export { BASE_URL, BASE_URL_TESTNET, DEFAULT_ACCOUNT_POLL_MS, DEFAULT_LISTEN_KEY_REFRESH_MS, USER_DATA_STREAM_URL, USER_DATA_STREAM_URL_TESTNET, WS_API_URL, WS_API_URL_TESTNET };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const BASE_URL = "https://fapi.binance.com";
|
|
2
|
-
const BASE_URL_TESTNET = "https://testnet.binancefuture.com";
|
|
3
|
-
const USER_DATA_STREAM_URL = "wss://fstream.binance.com/ws";
|
|
4
|
-
const USER_DATA_STREAM_URL_TESTNET = "wss://stream.binancefuture.com/ws";
|
|
5
|
-
const WS_API_URL = "wss://ws-fapi.binance.com/ws-fapi/v1";
|
|
6
|
-
const WS_API_URL_TESTNET = "wss://testnet.binancefuture.com/ws-fapi/v1";
|
|
7
|
-
const DEFAULT_LISTEN_KEY_REFRESH_MS = 25 * 60 * 1e3;
|
|
8
|
-
const DEFAULT_ACCOUNT_POLL_MS = 1e3;
|
|
9
|
-
|
|
10
|
-
export { BASE_URL, BASE_URL_TESTNET, DEFAULT_ACCOUNT_POLL_MS, DEFAULT_LISTEN_KEY_REFRESH_MS, USER_DATA_STREAM_URL, USER_DATA_STREAM_URL_TESTNET, WS_API_URL, WS_API_URL_TESTNET };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { g as SupportedCredentials } from '../../../types-Caz2X4h0.js';
|
|
2
|
-
import { BaseOrchestrator, OrchestratorConfig } from '../base.js';
|
|
3
|
-
import '@pear-protocol/types';
|
|
4
|
-
import '../bybit/types.js';
|
|
5
|
-
import '../hyperliquid/types.js';
|
|
6
|
-
import '../okx/types.js';
|
|
7
|
-
|
|
8
|
-
type BinanceOrchestratorConfig = OrchestratorConfig & {
|
|
9
|
-
listenKeyRefreshMs?: number;
|
|
10
|
-
accountPollMs?: number;
|
|
11
|
-
};
|
|
12
|
-
declare class BinanceOrchestrator extends BaseOrchestrator {
|
|
13
|
-
private ws;
|
|
14
|
-
private listenKeyTimer;
|
|
15
|
-
private pollTimer;
|
|
16
|
-
private creds;
|
|
17
|
-
private readonly listenKeyRefreshMs;
|
|
18
|
-
private readonly accountPollMs;
|
|
19
|
-
private stateHandler;
|
|
20
|
-
private assetTracker;
|
|
21
|
-
constructor(config: BinanceOrchestratorConfig, credentials: SupportedCredentials);
|
|
22
|
-
protected initAsync(): Promise<void>;
|
|
23
|
-
protected cleanupConnections(): void;
|
|
24
|
-
stop(): Promise<void>;
|
|
25
|
-
get isConnected(): boolean;
|
|
26
|
-
onAssetTracked(coin: string): void;
|
|
27
|
-
onAssetUntracked(coin: string): void;
|
|
28
|
-
private pollAccountStatus;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { BinanceOrchestrator };
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { BaseOrchestrator } from '../base';
|
|
2
|
-
import { BinanceAssetTracker } from './asset-tracker';
|
|
3
|
-
import { DEFAULT_LISTEN_KEY_REFRESH_MS, DEFAULT_ACCOUNT_POLL_MS } from './const';
|
|
4
|
-
import { fetchAccountStatus, fetchAllPositionRisk, fetchMultiAssetsMargin, createListenKey, keepAliveListenKey } from './rest';
|
|
5
|
-
import { BinanceStateHandler } from './state-handler';
|
|
6
|
-
import './types';
|
|
7
|
-
import { BinanceWs } from './ws';
|
|
8
|
-
|
|
9
|
-
class BinanceOrchestrator extends BaseOrchestrator {
|
|
10
|
-
ws = null;
|
|
11
|
-
listenKeyTimer = null;
|
|
12
|
-
pollTimer = null;
|
|
13
|
-
creds;
|
|
14
|
-
listenKeyRefreshMs;
|
|
15
|
-
accountPollMs;
|
|
16
|
-
stateHandler;
|
|
17
|
-
assetTracker;
|
|
18
|
-
constructor(config, credentials) {
|
|
19
|
-
super(config);
|
|
20
|
-
this.credentials = credentials;
|
|
21
|
-
this.creds = credentials;
|
|
22
|
-
this.listenKeyRefreshMs = config.listenKeyRefreshMs ?? DEFAULT_LISTEN_KEY_REFRESH_MS;
|
|
23
|
-
this.accountPollMs = config.accountPollMs ?? DEFAULT_ACCOUNT_POLL_MS;
|
|
24
|
-
this.assetTracker = new BinanceAssetTracker({
|
|
25
|
-
onStateUpdate: (update) => this.onStateUpdate(update),
|
|
26
|
-
onError: (err) => this.onError(err),
|
|
27
|
-
getCreds: () => this.creds,
|
|
28
|
-
getDemo: () => this.demo
|
|
29
|
-
});
|
|
30
|
-
this.stateHandler = new BinanceStateHandler({
|
|
31
|
-
onStateUpdate: (update) => this.onStateUpdate(update),
|
|
32
|
-
onError: (err) => this.onError(err),
|
|
33
|
-
getCreds: () => this.creds,
|
|
34
|
-
getDemo: () => this.demo,
|
|
35
|
-
getTrackedCoins: () => this.trackedCoins,
|
|
36
|
-
getTrackedAssetInfos: () => this.assetTracker.getInfos()
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
async initAsync() {
|
|
40
|
-
const [snapshot, positionRisk, multiAssetsMargin] = await Promise.all([
|
|
41
|
-
fetchAccountStatus(this.creds, this.demo),
|
|
42
|
-
fetchAllPositionRisk(this.creds, this.demo),
|
|
43
|
-
fetchMultiAssetsMargin(this.creds, this.demo)
|
|
44
|
-
]);
|
|
45
|
-
this.stateHandler.setMultiAssetsMargin(multiAssetsMargin);
|
|
46
|
-
this.stateHandler.handleAccountStatus(snapshot);
|
|
47
|
-
this.stateHandler.handlePositionRisk(positionRisk, false);
|
|
48
|
-
const listenKey = await createListenKey(this.creds.read.api_key, this.demo);
|
|
49
|
-
this.ws = new BinanceWs(
|
|
50
|
-
{
|
|
51
|
-
onUserDataEvent: (event) => this.stateHandler.handleUserDataEvent(event),
|
|
52
|
-
onWsApiResponse: (_id, result) => this.stateHandler.handleAccountStatus(result)
|
|
53
|
-
},
|
|
54
|
-
this.demo
|
|
55
|
-
);
|
|
56
|
-
await this.ws.connectUserDataStream(listenKey);
|
|
57
|
-
this.listenKeyTimer = setInterval(() => {
|
|
58
|
-
keepAliveListenKey(this.creds.read.api_key, this.demo).catch(
|
|
59
|
-
(err) => this.onError(err instanceof Error ? err : new Error(String(err)))
|
|
60
|
-
);
|
|
61
|
-
}, this.listenKeyRefreshMs);
|
|
62
|
-
await this.ws.connectWsApi(this.creds);
|
|
63
|
-
this.pollAccountStatus();
|
|
64
|
-
this.pollTimer = setInterval(() => this.pollAccountStatus(), this.accountPollMs);
|
|
65
|
-
}
|
|
66
|
-
cleanupConnections() {
|
|
67
|
-
if (this.listenKeyTimer) clearInterval(this.listenKeyTimer);
|
|
68
|
-
if (this.pollTimer) clearInterval(this.pollTimer);
|
|
69
|
-
this.ws?.close();
|
|
70
|
-
}
|
|
71
|
-
async stop() {
|
|
72
|
-
this.stopped = true;
|
|
73
|
-
this.cleanupConnections();
|
|
74
|
-
}
|
|
75
|
-
get isConnected() {
|
|
76
|
-
return this.ws?.isConnected ?? false;
|
|
77
|
-
}
|
|
78
|
-
onAssetTracked(coin) {
|
|
79
|
-
this.assetTracker.onAssetTracked(coin);
|
|
80
|
-
}
|
|
81
|
-
onAssetUntracked(coin) {
|
|
82
|
-
this.assetTracker.onAssetUntracked(coin);
|
|
83
|
-
}
|
|
84
|
-
pollAccountStatus() {
|
|
85
|
-
if (!this.ws?.isConnected) return;
|
|
86
|
-
const id = this.ws.nextRequestId();
|
|
87
|
-
this.ws.sendSignedRequest(id, "v2/account.status");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export { BinanceOrchestrator };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { BinanceCredentialsDTO } from '@pear-protocol/types';
|
|
2
|
-
import { S as StateUpdate, h as TrackedAssetInfo, j as BinanceRawAccountStatus, k as BinanceRawPositionRisk, m as BinanceRawUserDataEvent } from '../../../types-Caz2X4h0.js';
|
|
3
|
-
import '../bybit/types.js';
|
|
4
|
-
import '../hyperliquid/types.js';
|
|
5
|
-
import '../okx/types.js';
|
|
6
|
-
|
|
7
|
-
type OnStateUpdate = (update: StateUpdate) => void;
|
|
8
|
-
type OnError = (error: Error) => void;
|
|
9
|
-
declare class BinanceStateHandler {
|
|
10
|
-
private onStateUpdate;
|
|
11
|
-
private onError;
|
|
12
|
-
private getCreds;
|
|
13
|
-
private getDemo;
|
|
14
|
-
private getTrackedCoins;
|
|
15
|
-
private getTrackedAssetInfos;
|
|
16
|
-
private currentPositions;
|
|
17
|
-
private accountType;
|
|
18
|
-
constructor(deps: {
|
|
19
|
-
onStateUpdate: OnStateUpdate;
|
|
20
|
-
onError: OnError;
|
|
21
|
-
getCreds: () => BinanceCredentialsDTO;
|
|
22
|
-
getDemo: () => boolean;
|
|
23
|
-
getTrackedCoins: () => ReadonlySet<string>;
|
|
24
|
-
getTrackedAssetInfos: () => Map<string, TrackedAssetInfo>;
|
|
25
|
-
});
|
|
26
|
-
setMultiAssetsMargin(value: boolean): void;
|
|
27
|
-
handleAccountStatus(result: BinanceRawAccountStatus): void;
|
|
28
|
-
handlePositionRisk(risk: BinanceRawPositionRisk[], merge: boolean): void;
|
|
29
|
-
handleUserDataEvent(event: BinanceRawUserDataEvent): void;
|
|
30
|
-
private refreshAllPositions;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { BinanceStateHandler };
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { positionKey } from '../../utils';
|
|
2
|
-
import { mapBalance, mapPositions, mergePositions } from './mapper';
|
|
3
|
-
import { fetchPositionRisk } from './rest';
|
|
4
|
-
import { BinanceAccountType } from './types';
|
|
5
|
-
|
|
6
|
-
class BinanceStateHandler {
|
|
7
|
-
onStateUpdate;
|
|
8
|
-
onError;
|
|
9
|
-
getCreds;
|
|
10
|
-
getDemo;
|
|
11
|
-
getTrackedCoins;
|
|
12
|
-
getTrackedAssetInfos;
|
|
13
|
-
currentPositions = /* @__PURE__ */ new Map();
|
|
14
|
-
accountType = BinanceAccountType.SINGLE_ASSET;
|
|
15
|
-
constructor(deps) {
|
|
16
|
-
this.onStateUpdate = deps.onStateUpdate;
|
|
17
|
-
this.onError = deps.onError;
|
|
18
|
-
this.getCreds = deps.getCreds;
|
|
19
|
-
this.getDemo = deps.getDemo;
|
|
20
|
-
this.getTrackedCoins = deps.getTrackedCoins;
|
|
21
|
-
this.getTrackedAssetInfos = deps.getTrackedAssetInfos;
|
|
22
|
-
}
|
|
23
|
-
setMultiAssetsMargin(value) {
|
|
24
|
-
this.accountType = value ? BinanceAccountType.MULTI_ASSET : BinanceAccountType.SINGLE_ASSET;
|
|
25
|
-
}
|
|
26
|
-
handleAccountStatus(result) {
|
|
27
|
-
const balance = { ...mapBalance(result), accountType: this.accountType };
|
|
28
|
-
this.onStateUpdate({ balance });
|
|
29
|
-
}
|
|
30
|
-
handlePositionRisk(risk, merge) {
|
|
31
|
-
let positions = mapPositions(risk);
|
|
32
|
-
if (merge && this.currentPositions.size > 0) {
|
|
33
|
-
positions = mergePositions(positions, this.currentPositions);
|
|
34
|
-
}
|
|
35
|
-
this.currentPositions = positions;
|
|
36
|
-
const leverageSettings = /* @__PURE__ */ new Map();
|
|
37
|
-
for (const p of risk) {
|
|
38
|
-
if (p.symbol && p.leverage) {
|
|
39
|
-
leverageSettings.set(p.symbol, p.leverage);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
this.onStateUpdate({ positions, leverageSettings });
|
|
43
|
-
}
|
|
44
|
-
handleUserDataEvent(event) {
|
|
45
|
-
if (event.e === "ACCOUNT_CONFIG_UPDATE" && event.ac) {
|
|
46
|
-
const symbol = event.ac.s ?? "";
|
|
47
|
-
const leverage = event.ac.l ?? "0";
|
|
48
|
-
if (symbol && leverage !== "0") {
|
|
49
|
-
const leverageSettings = /* @__PURE__ */ new Map();
|
|
50
|
-
leverageSettings.set(symbol, leverage);
|
|
51
|
-
const trackedAssetInfos = this.getTrackedAssetInfos();
|
|
52
|
-
const existing = trackedAssetInfos.get(symbol);
|
|
53
|
-
if (existing) {
|
|
54
|
-
const updated = { ...existing, leverage };
|
|
55
|
-
trackedAssetInfos.set(symbol, updated);
|
|
56
|
-
const trackedAssets = /* @__PURE__ */ new Map();
|
|
57
|
-
trackedAssets.set(symbol, updated);
|
|
58
|
-
this.onStateUpdate({ leverageSettings, trackedAssets });
|
|
59
|
-
} else {
|
|
60
|
-
this.onStateUpdate({ leverageSettings });
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
this.refreshAllPositions();
|
|
64
|
-
}
|
|
65
|
-
if (event.e === "ACCOUNT_UPDATE") {
|
|
66
|
-
this.refreshAllPositions();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
refreshAllPositions() {
|
|
70
|
-
const creds = this.getCreds();
|
|
71
|
-
const demo = this.getDemo();
|
|
72
|
-
const symbols = /* @__PURE__ */ new Set();
|
|
73
|
-
for (const pos of this.currentPositions.values()) {
|
|
74
|
-
symbols.add(pos.symbol);
|
|
75
|
-
}
|
|
76
|
-
for (const coin of this.getTrackedCoins()) {
|
|
77
|
-
symbols.add(coin);
|
|
78
|
-
}
|
|
79
|
-
if (symbols.size === 0) return;
|
|
80
|
-
const promises = Array.from(symbols).map((symbol) => fetchPositionRisk(creds, symbol, demo).catch(() => void 0));
|
|
81
|
-
Promise.all(promises).then((results) => {
|
|
82
|
-
const freshPositions = /* @__PURE__ */ new Map();
|
|
83
|
-
for (const risk of results) {
|
|
84
|
-
if (!risk) continue;
|
|
85
|
-
const amt = risk.positionAmt ?? "0";
|
|
86
|
-
if (amt === "0" || amt === "") continue;
|
|
87
|
-
const symbol = risk.symbol ?? "";
|
|
88
|
-
const side = amt.startsWith("-") ? "short" : "long";
|
|
89
|
-
freshPositions.set(positionKey(symbol, side), {
|
|
90
|
-
symbol,
|
|
91
|
-
side,
|
|
92
|
-
size: amt,
|
|
93
|
-
entryPrice: risk.entryPrice ?? "0",
|
|
94
|
-
unrealizedPnl: risk.unRealizedProfit ?? "0",
|
|
95
|
-
leverage: risk.leverage ?? "0",
|
|
96
|
-
marginType: risk.marginType,
|
|
97
|
-
liquidationPrice: risk.liquidationPrice || null
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
for (const [key, pos] of this.currentPositions) {
|
|
101
|
-
if (!symbols.has(pos.symbol) && !freshPositions.has(key)) {
|
|
102
|
-
freshPositions.set(key, pos);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
this.currentPositions = freshPositions;
|
|
106
|
-
this.onStateUpdate({ positions: freshPositions });
|
|
107
|
-
}).catch((err) => {
|
|
108
|
-
this.onError(err instanceof Error ? err : new Error(String(err)));
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export { BinanceStateHandler };
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { f as BinanceAccountType, l as BinanceAssetIndex, o as BinanceMultiAssetsMarginResponse, j as BinanceRawAccountStatus, p as BinanceRawAsset, k as BinanceRawPositionRisk, m as BinanceRawUserDataEvent, n as BinanceWsHandlers } from '../../../types-Caz2X4h0.js';
|
|
2
|
-
import '@pear-protocol/types';
|
|
3
|
-
import '../bybit/types.js';
|
|
4
|
-
import '../hyperliquid/types.js';
|
|
5
|
-
import '../okx/types.js';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BinanceCredentialsDTO } from '@pear-protocol/types';
|
|
2
|
-
import { n as BinanceWsHandlers } from '../../../types-Caz2X4h0.js';
|
|
3
|
-
import '../bybit/types.js';
|
|
4
|
-
import '../hyperliquid/types.js';
|
|
5
|
-
import '../okx/types.js';
|
|
6
|
-
|
|
7
|
-
declare class BinanceWs {
|
|
8
|
-
private userDataWs;
|
|
9
|
-
private wsApiWs;
|
|
10
|
-
private requestId;
|
|
11
|
-
private handlers;
|
|
12
|
-
private demo;
|
|
13
|
-
private creds;
|
|
14
|
-
constructor(handlers: BinanceWsHandlers, demo: boolean);
|
|
15
|
-
connectUserDataStream(listenKey: string): Promise<void>;
|
|
16
|
-
connectWsApi(creds: BinanceCredentialsDTO): Promise<void>;
|
|
17
|
-
nextRequestId(): number;
|
|
18
|
-
sendSignedRequest(id: number, method: string, params?: Record<string, unknown>): Promise<void>;
|
|
19
|
-
close(): void;
|
|
20
|
-
get isConnected(): boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { BinanceWs };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { hmacSha256Hex } from '../../../utils/hmac';
|
|
2
|
-
import { createWs, waitForOpen, sendWs, ReconnectingWebSocket } from '../../../utils/ws';
|
|
3
|
-
import { USER_DATA_STREAM_URL_TESTNET, USER_DATA_STREAM_URL, WS_API_URL_TESTNET, WS_API_URL } from './const';
|
|
4
|
-
|
|
5
|
-
class BinanceWs {
|
|
6
|
-
userDataWs = null;
|
|
7
|
-
wsApiWs = null;
|
|
8
|
-
requestId = 1;
|
|
9
|
-
handlers;
|
|
10
|
-
demo;
|
|
11
|
-
creds = null;
|
|
12
|
-
constructor(handlers, demo) {
|
|
13
|
-
this.handlers = handlers;
|
|
14
|
-
this.demo = demo;
|
|
15
|
-
}
|
|
16
|
-
async connectUserDataStream(listenKey) {
|
|
17
|
-
const url = this.demo ? USER_DATA_STREAM_URL_TESTNET : USER_DATA_STREAM_URL;
|
|
18
|
-
this.userDataWs = createWs(`${url}/${listenKey}`);
|
|
19
|
-
this.userDataWs.addEventListener("message", (event) => {
|
|
20
|
-
try {
|
|
21
|
-
this.handlers.onUserDataEvent(JSON.parse(event.data));
|
|
22
|
-
} catch {
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
await waitForOpen(this.userDataWs);
|
|
26
|
-
}
|
|
27
|
-
async connectWsApi(creds) {
|
|
28
|
-
this.creds = creds;
|
|
29
|
-
const url = this.demo ? WS_API_URL_TESTNET : WS_API_URL;
|
|
30
|
-
this.wsApiWs = createWs(url);
|
|
31
|
-
this.wsApiWs.addEventListener("message", (event) => {
|
|
32
|
-
try {
|
|
33
|
-
const msg = JSON.parse(event.data);
|
|
34
|
-
if (msg.id !== void 0 && msg.result !== void 0) {
|
|
35
|
-
this.handlers.onWsApiResponse(msg.id, msg.result);
|
|
36
|
-
}
|
|
37
|
-
} catch {
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
await waitForOpen(this.wsApiWs);
|
|
41
|
-
}
|
|
42
|
-
nextRequestId() {
|
|
43
|
-
return this.requestId++;
|
|
44
|
-
}
|
|
45
|
-
async sendSignedRequest(id, method, params = {}) {
|
|
46
|
-
if (!this.creds) return;
|
|
47
|
-
const timestamp = Date.now();
|
|
48
|
-
const allParams = { ...params, apiKey: this.creds.read.api_key, timestamp };
|
|
49
|
-
const queryString = Object.keys(allParams).sort().map((k) => `${k}=${allParams[k]}`).join("&");
|
|
50
|
-
const signature = await hmacSha256Hex(this.creds.read.api_secret, queryString);
|
|
51
|
-
sendWs(this.wsApiWs, { id, method, params: { ...allParams, signature } });
|
|
52
|
-
}
|
|
53
|
-
close() {
|
|
54
|
-
this.creds = null;
|
|
55
|
-
if (this.userDataWs) {
|
|
56
|
-
this.userDataWs.close();
|
|
57
|
-
this.userDataWs = null;
|
|
58
|
-
}
|
|
59
|
-
if (this.wsApiWs) {
|
|
60
|
-
this.wsApiWs.close();
|
|
61
|
-
this.wsApiWs = null;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
get isConnected() {
|
|
65
|
-
return this.userDataWs?.readyState === ReconnectingWebSocket.OPEN && this.wsApiWs?.readyState === ReconnectingWebSocket.OPEN;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export { BinanceWs };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { BybitCredentialsDTO } from '@pear-protocol/types';
|
|
2
|
-
import { S as StateUpdate, h as TrackedAssetInfo } from '../../../types-Caz2X4h0.js';
|
|
3
|
-
import './types.js';
|
|
4
|
-
import '../hyperliquid/types.js';
|
|
5
|
-
import '../okx/types.js';
|
|
6
|
-
|
|
7
|
-
type OnStateUpdate = (update: StateUpdate) => void;
|
|
8
|
-
type OnError = (error: Error) => void;
|
|
9
|
-
declare class BybitAssetTracker {
|
|
10
|
-
private onStateUpdate;
|
|
11
|
-
private onError;
|
|
12
|
-
private getCreds;
|
|
13
|
-
private getDemo;
|
|
14
|
-
private trackedAssetInfos;
|
|
15
|
-
constructor(deps: {
|
|
16
|
-
onStateUpdate: OnStateUpdate;
|
|
17
|
-
onError: OnError;
|
|
18
|
-
getCreds: () => BybitCredentialsDTO;
|
|
19
|
-
getDemo: () => boolean;
|
|
20
|
-
});
|
|
21
|
-
getInfos(): Map<string, TrackedAssetInfo>;
|
|
22
|
-
onAssetTracked(coin: string): void;
|
|
23
|
-
onAssetUntracked(coin: string): void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { BybitAssetTracker };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { fetchPositionLeverage } from './rest';
|
|
2
|
-
|
|
3
|
-
class BybitAssetTracker {
|
|
4
|
-
onStateUpdate;
|
|
5
|
-
onError;
|
|
6
|
-
getCreds;
|
|
7
|
-
getDemo;
|
|
8
|
-
trackedAssetInfos = /* @__PURE__ */ new Map();
|
|
9
|
-
constructor(deps) {
|
|
10
|
-
this.onStateUpdate = deps.onStateUpdate;
|
|
11
|
-
this.onError = deps.onError;
|
|
12
|
-
this.getCreds = deps.getCreds;
|
|
13
|
-
this.getDemo = deps.getDemo;
|
|
14
|
-
}
|
|
15
|
-
getInfos() {
|
|
16
|
-
return this.trackedAssetInfos;
|
|
17
|
-
}
|
|
18
|
-
onAssetTracked(coin) {
|
|
19
|
-
fetchPositionLeverage(this.getCreds(), coin, this.getDemo()).then((pos) => {
|
|
20
|
-
const leverage = pos?.leverage || "1";
|
|
21
|
-
const marginType = pos?.tradeMode === "1" ? "cross" : "isolated";
|
|
22
|
-
const info = { coin, leverage, marginType };
|
|
23
|
-
this.trackedAssetInfos.set(coin, info);
|
|
24
|
-
const trackedAssets = /* @__PURE__ */ new Map();
|
|
25
|
-
trackedAssets.set(coin, info);
|
|
26
|
-
this.onStateUpdate({ trackedAssets });
|
|
27
|
-
}).catch((err) => {
|
|
28
|
-
this.onError(err instanceof Error ? err : new Error(String(err)));
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
onAssetUntracked(coin) {
|
|
32
|
-
this.trackedAssetInfos.delete(coin);
|
|
33
|
-
this.onStateUpdate({ trackedAssets: new Map(this.trackedAssetInfos) });
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { BybitAssetTracker };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
declare const BASE_URL = "https://api.bybit.com";
|
|
2
|
-
declare const BASE_URL_DEMO = "https://api-demo.bybit.com";
|
|
3
|
-
declare const WS_URL = "wss://stream.bybit.com/v5/private";
|
|
4
|
-
declare const WS_URL_DEMO = "wss://stream-demo.bybit.com/v5/private";
|
|
5
|
-
declare const DEFAULT_PING_INTERVAL_MS = 20000;
|
|
6
|
-
|
|
7
|
-
export { BASE_URL, BASE_URL_DEMO, DEFAULT_PING_INTERVAL_MS, WS_URL, WS_URL_DEMO };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const BASE_URL = "https://api.bybit.com";
|
|
2
|
-
const BASE_URL_DEMO = "https://api-demo.bybit.com";
|
|
3
|
-
const WS_URL = "wss://stream.bybit.com/v5/private";
|
|
4
|
-
const WS_URL_DEMO = "wss://stream-demo.bybit.com/v5/private";
|
|
5
|
-
const DEFAULT_PING_INTERVAL_MS = 2e4;
|
|
6
|
-
|
|
7
|
-
export { BASE_URL, BASE_URL_DEMO, DEFAULT_PING_INTERVAL_MS, WS_URL, WS_URL_DEMO };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { g as SupportedCredentials } from '../../../types-Caz2X4h0.js';
|
|
2
|
-
import { BaseOrchestrator, OrchestratorConfig } from '../base.js';
|
|
3
|
-
import '@pear-protocol/types';
|
|
4
|
-
import './types.js';
|
|
5
|
-
import '../hyperliquid/types.js';
|
|
6
|
-
import '../okx/types.js';
|
|
7
|
-
|
|
8
|
-
declare class BybitOrchestrator extends BaseOrchestrator {
|
|
9
|
-
private ws;
|
|
10
|
-
private creds;
|
|
11
|
-
private stateHandler;
|
|
12
|
-
private assetTracker;
|
|
13
|
-
constructor(config: OrchestratorConfig, credentials: SupportedCredentials);
|
|
14
|
-
protected initAsync(): Promise<void>;
|
|
15
|
-
protected cleanupConnections(): void;
|
|
16
|
-
stop(): Promise<void>;
|
|
17
|
-
get isConnected(): boolean;
|
|
18
|
-
onAssetTracked(coin: string): void;
|
|
19
|
-
onAssetUntracked(coin: string): void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { BybitOrchestrator };
|