@pear-protocol/exchanges-sdk 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.
Files changed (90) hide show
  1. package/README.md +63 -2
  2. package/dist/client/lighter/rest.js +18 -1
  3. package/dist/helper/factory.js +6 -5
  4. package/dist/helper/hyperliquid/helper.js +23 -0
  5. package/dist/helper/hyperliquid/index.js +1 -0
  6. package/dist/helper/hyperliquid/types.js +1 -0
  7. package/dist/helper/index.js +1 -0
  8. package/dist/index.d.ts +817 -49
  9. package/dist/sdk.js +33 -20
  10. package/dist/status/base.js +10 -0
  11. package/dist/status/binance/status.js +14 -0
  12. package/dist/status/bybit/status.js +14 -0
  13. package/dist/status/factory.js +26 -0
  14. package/dist/status/hyperliquid/status.js +37 -0
  15. package/dist/status/index.js +7 -0
  16. package/dist/status/lighter/status.js +33 -0
  17. package/dist/status/okx/status.js +14 -0
  18. package/dist/syncer/base.js +2 -0
  19. package/dist/syncer/hyperliquid/syncer.js +1 -2
  20. package/dist/syncer/lighter/syncer.js +1 -1
  21. package/dist/tracker/hyperliquid/tracker.js +1 -2
  22. package/dist/tracker/index.js +2 -0
  23. package/dist/tracker/lighter/tracker.js +1 -2
  24. package/package.json +4 -4
  25. package/dist/client/base-ws.d.ts +0 -30
  26. package/dist/client/binance/exchange-ws.d.ts +0 -19
  27. package/dist/client/binance/rest.d.ts +0 -13
  28. package/dist/client/binance/types.d.ts +0 -103
  29. package/dist/client/binance/ws.d.ts +0 -30
  30. package/dist/client/bybit/exchange-ws.d.ts +0 -20
  31. package/dist/client/bybit/rest.d.ts +0 -11
  32. package/dist/client/bybit/types.d.ts +0 -75
  33. package/dist/client/bybit/ws.d.ts +0 -17
  34. package/dist/client/exchange-ws.d.ts +0 -12
  35. package/dist/client/hmac.d.ts +0 -4
  36. package/dist/client/hyperliquid/exchange-ws.d.ts +0 -15
  37. package/dist/client/hyperliquid/rest.d.ts +0 -3
  38. package/dist/client/hyperliquid/types.d.ts +0 -188
  39. package/dist/client/hyperliquid/ws.d.ts +0 -10
  40. package/dist/client/index.d.ts +0 -31
  41. package/dist/client/lighter/constants.d.ts +0 -4
  42. package/dist/client/lighter/exchange-ws.d.ts +0 -15
  43. package/dist/client/lighter/rest.d.ts +0 -59
  44. package/dist/client/lighter/types.d.ts +0 -53
  45. package/dist/client/lighter/ws.d.ts +0 -10
  46. package/dist/client/okx/exchange-ws.d.ts +0 -20
  47. package/dist/client/okx/rest.d.ts +0 -10
  48. package/dist/client/okx/types.d.ts +0 -77
  49. package/dist/client/okx/ws.d.ts +0 -17
  50. package/dist/helper/factory.d.ts +0 -11
  51. package/dist/helper/index.d.ts +0 -8
  52. package/dist/helper/lighter/ethereum/abi.d.ts +0 -66
  53. package/dist/helper/lighter/ethereum/index.d.ts +0 -8
  54. package/dist/helper/lighter/ethereum/types.d.ts +0 -23
  55. package/dist/helper/lighter/helper.d.ts +0 -10
  56. package/dist/helper/lighter/index.d.ts +0 -7
  57. package/dist/helper/lighter/types.d.ts +0 -64
  58. package/dist/helper/types.d.ts +0 -12
  59. package/dist/sdk.d.ts +0 -44
  60. package/dist/syncer/base.d.ts +0 -47
  61. package/dist/syncer/binance/syncer.d.ts +0 -31
  62. package/dist/syncer/bybit/syncer.d.ts +0 -28
  63. package/dist/syncer/factory.d.ts +0 -22
  64. package/dist/syncer/hyperliquid/syncer.d.ts +0 -28
  65. package/dist/syncer/index.d.ts +0 -29
  66. package/dist/syncer/lighter/syncer.d.ts +0 -37
  67. package/dist/syncer/okx/syncer.d.ts +0 -29
  68. package/dist/tracker/base.d.ts +0 -79
  69. package/dist/tracker/binance/const.d.ts +0 -4
  70. package/dist/tracker/binance/mapper.d.ts +0 -14
  71. package/dist/tracker/binance/tracker.d.ts +0 -60
  72. package/dist/tracker/binance/types.d.ts +0 -6
  73. package/dist/tracker/bybit/mapper.d.ts +0 -15
  74. package/dist/tracker/bybit/tracker.d.ts +0 -51
  75. package/dist/tracker/bybit/types.d.ts +0 -7
  76. package/dist/tracker/hyperliquid/const.d.ts +0 -3
  77. package/dist/tracker/hyperliquid/mapper.d.ts +0 -12
  78. package/dist/tracker/hyperliquid/tracker.d.ts +0 -62
  79. package/dist/tracker/hyperliquid/types.d.ts +0 -23
  80. package/dist/tracker/index.d.ts +0 -38
  81. package/dist/tracker/lighter/const.d.ts +0 -3
  82. package/dist/tracker/lighter/mapper.d.ts +0 -16
  83. package/dist/tracker/lighter/tracker.d.ts +0 -53
  84. package/dist/tracker/lighter/types.d.ts +0 -16
  85. package/dist/tracker/okx/mapper.d.ts +0 -16
  86. package/dist/tracker/okx/tracker.d.ts +0 -51
  87. package/dist/tracker/okx/types.d.ts +0 -8
  88. package/dist/tracker/types.d.ts +0 -63
  89. package/dist/tracker/utils.d.ts +0 -11
  90. package/dist/types.d.ts +0 -50
@@ -1,51 +0,0 @@
1
- import { BybitExchangeWs } from '../../client/bybit/exchange-ws.js';
2
- import { SupportedCredentials } from '../../types.js';
3
- import { BaseAccountTracker, AccountTrackerConfig } from '../base.js';
4
- import '@pear-protocol/types';
5
- import '../../client/base-ws.js';
6
- import 'partysocket';
7
- import '../../client/exchange-ws.js';
8
- import '../../client/bybit/ws.js';
9
- import '@pear-protocol/core-sdk';
10
- import '../../client/binance/exchange-ws.js';
11
- import '../../client/binance/ws.js';
12
- import '../../client/hyperliquid/exchange-ws.js';
13
- import '../../client/hyperliquid/ws.js';
14
- import '../../client/lighter/exchange-ws.js';
15
- import '../../client/lighter/ws.js';
16
- import '../../client/okx/exchange-ws.js';
17
- import '../../client/okx/ws.js';
18
- import '../types.js';
19
- import '../binance/types.js';
20
- import './types.js';
21
- import '../hyperliquid/types.js';
22
- import '../lighter/types.js';
23
- import '../okx/types.js';
24
-
25
- type BybitAccountTrackerConfig = AccountTrackerConfig & {
26
- credentials: SupportedCredentials;
27
- ws: BybitExchangeWs;
28
- };
29
- declare class BybitAccountTracker extends BaseAccountTracker {
30
- private readonly creds;
31
- private readonly ws;
32
- private messageListenerId;
33
- private openListenerId;
34
- private rawCoins;
35
- private lastWallet;
36
- private accountType;
37
- private trackedAssetInfos;
38
- constructor(config: BybitAccountTrackerConfig);
39
- start(): Promise<void>;
40
- protected cleanupConnections(): Promise<void>;
41
- get isConnected(): boolean;
42
- protected ensureAssetTracked(coin: string): void;
43
- protected releaseAsset(coin: string): void;
44
- private subscribe;
45
- private handleInitialData;
46
- private routeRaw;
47
- private handleMessage;
48
- private handleWalletUpdate;
49
- }
50
-
51
- export { BybitAccountTracker, type BybitAccountTrackerConfig };
@@ -1,7 +0,0 @@
1
- declare enum BybitAccountType {
2
- ISOLATED_MARGIN = "ISOLATED_MARGIN",
3
- REGULAR_MARGIN = "REGULAR_MARGIN",
4
- PORTFOLIO_MARGIN = "PORTFOLIO_MARGIN"
5
- }
6
-
7
- export { BybitAccountType };
@@ -1,3 +0,0 @@
1
- declare const LOCKED_TRACKED_COINS: readonly ["BTC"];
2
-
3
- export { LOCKED_TRACKED_COINS };
@@ -1,12 +0,0 @@
1
- import { AssetPosition } from '../../client/hyperliquid/types.js';
2
- import { AccountBalance, AccountPosition } from '../types.js';
3
- import { AggregatedClearinghouseSummary, HyperliquidCoinBalance, HyperliquidAccountType } from './types.js';
4
- import '../binance/types.js';
5
- import '../bybit/types.js';
6
- import '../lighter/types.js';
7
- import '../okx/types.js';
8
-
9
- declare function mapBalance(summary: AggregatedClearinghouseSummary, spotCoinBalances: Map<string, HyperliquidCoinBalance>, accountType: HyperliquidAccountType | null, availableToTradeByCollateral: Map<string, string>): AccountBalance | null;
10
- declare function mapPositions(raw: AssetPosition[]): Map<string, AccountPosition>;
11
-
12
- export { mapBalance, mapPositions };
@@ -1,62 +0,0 @@
1
- import { HyperliquidWs } from '../../client/hyperliquid/ws.js';
2
- import { SupportedCredentials } from '../../types.js';
3
- import { BaseAccountTracker, AccountTrackerConfig } from '../base.js';
4
- import '../../client/base-ws.js';
5
- import 'partysocket';
6
- import '@pear-protocol/core-sdk';
7
- import '@pear-protocol/types';
8
- import '../../client/binance/exchange-ws.js';
9
- import '../../client/exchange-ws.js';
10
- import '../../client/binance/ws.js';
11
- import '../../client/bybit/exchange-ws.js';
12
- import '../../client/bybit/ws.js';
13
- import '../../client/hyperliquid/exchange-ws.js';
14
- import '../../client/lighter/exchange-ws.js';
15
- import '../../client/lighter/ws.js';
16
- import '../../client/okx/exchange-ws.js';
17
- import '../../client/okx/ws.js';
18
- import '../types.js';
19
- import '../binance/types.js';
20
- import '../bybit/types.js';
21
- import './types.js';
22
- import '../lighter/types.js';
23
- import '../okx/types.js';
24
-
25
- type HyperliquidAccountTrackerConfig = AccountTrackerConfig & {
26
- credentials: SupportedCredentials;
27
- ws: HyperliquidWs;
28
- };
29
- declare class HyperliquidAccountTracker extends BaseAccountTracker {
30
- private readonly address;
31
- private readonly ws;
32
- private messageListenerId;
33
- private openListenerId;
34
- private subscribedCoins;
35
- private lastSummary;
36
- private spotCoinBalances;
37
- private accountType;
38
- private symbolToCollateralToken;
39
- private availableToTradeByCollateral;
40
- private trackedAssetData;
41
- constructor(config: HyperliquidAccountTrackerConfig);
42
- start(): Promise<void>;
43
- protected cleanupConnections(): Promise<void>;
44
- get isConnected(): boolean;
45
- protected ensureAssetTracked(coin: string): void;
46
- protected releaseAsset(coin: string): void;
47
- private isLocked;
48
- private addrLower;
49
- private sendStaticSubs;
50
- private resubscribeAll;
51
- private routeRaw;
52
- private handle;
53
- private loadPerpMetas;
54
- private onClearinghouseState;
55
- private onActiveAssetData;
56
- private onWebData3;
57
- private onSpotState;
58
- private buildBalance;
59
- private buildTrackedAssetsMap;
60
- }
61
-
62
- export { HyperliquidAccountTracker, type HyperliquidAccountTrackerConfig };
@@ -1,23 +0,0 @@
1
- declare enum HyperliquidAccountType {
2
- DEFAULT = "default",
3
- DEX_ABSTRACTION = "dexAbstraction",
4
- DISABLED = "disabled",
5
- PORTFOLIO_MARGIN = "portfolioMargin",
6
- UNIFIED_ACCOUNT = "unifiedAccount"
7
- }
8
- interface HyperliquidCoinBalance {
9
- coin: string;
10
- total: string;
11
- hold: string;
12
- }
13
- interface AggregatedClearinghouseSummary {
14
- accountValue: string;
15
- totalMarginUsed: string;
16
- totalRawUsd: string;
17
- crossMaintenanceMarginUsed: string;
18
- withdrawable: string;
19
- totalUnrealizedPnl: string;
20
- }
21
- declare const COLLATERAL_TOKEN_MAP: Record<number, string>;
22
-
23
- export { type AggregatedClearinghouseSummary, COLLATERAL_TOKEN_MAP, HyperliquidAccountType, type HyperliquidCoinBalance };
@@ -1,38 +0,0 @@
1
- import { Connector } from '@pear-protocol/types';
2
- import { ExchangeWsByConnector } from '../client/index.js';
3
- import { SupportedCredentials } from '../types.js';
4
- import { AccountTrackerConfig, AccountTracker } from './base.js';
5
- export { BaseAccountTracker } from './base.js';
6
- export { BinanceAccountTracker, BinanceAccountTrackerConfig } from './binance/tracker.js';
7
- export { BinanceAccountType } from './binance/types.js';
8
- export { BybitAccountTracker, BybitAccountTrackerConfig } from './bybit/tracker.js';
9
- export { BybitAccountType } from './bybit/types.js';
10
- export { HyperliquidAccountTracker, HyperliquidAccountTrackerConfig } from './hyperliquid/tracker.js';
11
- export { HyperliquidAccountType } from './hyperliquid/types.js';
12
- export { LighterAccountTracker, LighterAccountTrackerConfig } from './lighter/tracker.js';
13
- export { LighterAccountType } from './lighter/types.js';
14
- export { OkxAccountTracker, OkxAccountTrackerConfig } from './okx/tracker.js';
15
- export { OkxAccountType } from './okx/types.js';
16
- export { ACCOUNT_TYPE_LABELS, AccountBalance, AccountPosition, AccountType, AssetBalance, BalanceCallback, ExchangeState, MarginMode, PositionsCallback, StateUpdate, TrackedAssetCallback, TrackedAssetInfo } from './types.js';
17
- import '../client/binance/exchange-ws.js';
18
- import '../client/base-ws.js';
19
- import 'partysocket';
20
- import '../client/exchange-ws.js';
21
- import '../client/binance/ws.js';
22
- import '../client/bybit/exchange-ws.js';
23
- import '../client/bybit/ws.js';
24
- import '../client/hyperliquid/exchange-ws.js';
25
- import '../client/hyperliquid/ws.js';
26
- import '../client/lighter/exchange-ws.js';
27
- import '../client/lighter/ws.js';
28
- import '../client/okx/exchange-ws.js';
29
- import '../client/okx/ws.js';
30
- import '@pear-protocol/core-sdk';
31
-
32
- type CreateAccountTrackerConfig<E extends Connector> = AccountTrackerConfig & {
33
- credentials: SupportedCredentials;
34
- ws: ExchangeWsByConnector[E];
35
- };
36
- declare function createAccountTracker<E extends Connector>(exchange: E, config: CreateAccountTrackerConfig<E>): AccountTracker;
37
-
38
- export { AccountTracker, AccountTrackerConfig, type CreateAccountTrackerConfig, createAccountTracker };
@@ -1,3 +0,0 @@
1
- declare const QUOTE_ASSET = "USDC";
2
-
3
- export { QUOTE_ASSET };
@@ -1,16 +0,0 @@
1
- import { RawAsset, RawPosition } from '../../client/lighter/types.js';
2
- import { AccountBalance, AccountPosition, TrackedAssetInfo } from '../types.js';
3
- import { AggregatedLighterSummary } from './types.js';
4
- import '../binance/types.js';
5
- import '../bybit/types.js';
6
- import '../hyperliquid/types.js';
7
- import '../okx/types.js';
8
-
9
- declare function mapBalance(summary: AggregatedLighterSummary, assetsByAssetId: Map<string, RawAsset>): AccountBalance;
10
- declare function mapPositions(raw: Record<string, RawPosition>): {
11
- positions: Map<string, AccountPosition>;
12
- trackedAssets: Map<string, TrackedAssetInfo>;
13
- };
14
- declare function leverageFromImf(imfPct: string): string;
15
-
16
- export { leverageFromImf, mapBalance, mapPositions };
@@ -1,53 +0,0 @@
1
- import { LighterWs } from '../../client/lighter/ws.js';
2
- import { SupportedCredentials } from '../../types.js';
3
- import { BaseAccountTracker, AccountTrackerConfig } from '../base.js';
4
- import '../../client/base-ws.js';
5
- import 'partysocket';
6
- import '@pear-protocol/core-sdk';
7
- import '@pear-protocol/types';
8
- import '../../client/binance/exchange-ws.js';
9
- import '../../client/exchange-ws.js';
10
- import '../../client/binance/ws.js';
11
- import '../../client/bybit/exchange-ws.js';
12
- import '../../client/bybit/ws.js';
13
- import '../../client/hyperliquid/exchange-ws.js';
14
- import '../../client/hyperliquid/ws.js';
15
- import '../../client/lighter/exchange-ws.js';
16
- import '../../client/okx/exchange-ws.js';
17
- import '../../client/okx/ws.js';
18
- import '../types.js';
19
- import '../binance/types.js';
20
- import '../bybit/types.js';
21
- import '../hyperliquid/types.js';
22
- import './types.js';
23
- import '../okx/types.js';
24
-
25
- type LighterAccountTrackerConfig = AccountTrackerConfig & {
26
- credentials: SupportedCredentials;
27
- ws: LighterWs;
28
- };
29
- declare class LighterAccountTracker extends BaseAccountTracker {
30
- private readonly accountIdentifier;
31
- private readonly ws;
32
- private messageListenerId;
33
- private openListenerId;
34
- private pollTimer;
35
- private assetsByAssetId;
36
- private summary;
37
- private hasAssets;
38
- constructor(config: LighterAccountTrackerConfig);
39
- start(): Promise<void>;
40
- protected cleanupConnections(): Promise<void>;
41
- get isConnected(): boolean;
42
- protected ensureAssetTracked(_coin: string): void;
43
- protected releaseAsset(_coin: string): void;
44
- private sendStaticSubs;
45
- private routeRaw;
46
- private handle;
47
- private onAccountAll;
48
- private onUserStats;
49
- private buildBalance;
50
- private pollAccount;
51
- }
52
-
53
- export { LighterAccountTracker, type LighterAccountTrackerConfig };
@@ -1,16 +0,0 @@
1
- declare enum LighterAccountType {
2
- BASIC = "basic"
3
- }
4
- interface LighterCoinBalance {
5
- symbol: string;
6
- balance: string;
7
- lockedBalance: string;
8
- }
9
- interface AggregatedLighterSummary {
10
- collateral: string;
11
- portfolioValue: string;
12
- availableToTrade: string;
13
- marginUsagePct: string;
14
- }
15
-
16
- export { type AggregatedLighterSummary, LighterAccountType, type LighterCoinBalance };
@@ -1,16 +0,0 @@
1
- import { OkxRawBalance, OkxRawBalanceDetail, OkxRawPosition } from '../../client/okx/types.js';
2
- import { AccountBalance, AccountPosition } from '../types.js';
3
- import { OkxAccountType } from './types.js';
4
- import '../binance/types.js';
5
- import '../bybit/types.js';
6
- import '../hyperliquid/types.js';
7
- import '../lighter/types.js';
8
-
9
- declare function mergeRawCoins(existing: Map<string, OkxRawBalanceDetail>, incoming: OkxRawBalanceDetail[]): Map<string, OkxRawBalanceDetail>;
10
- declare function buildBalance(raw: OkxRawBalance, coins: Map<string, OkxRawBalanceDetail>, accountType: OkxAccountType | null): AccountBalance | null;
11
- declare function mapSinglePosition(p: OkxRawPosition): AccountPosition;
12
- declare function mapPositions(raw: OkxRawPosition[]): Map<string, AccountPosition>;
13
- declare function mapPositionUpdates(raw: OkxRawPosition[]): Map<string, AccountPosition>;
14
- declare function acctLvToAccountType(acctLv: string): OkxAccountType | null;
15
-
16
- export { acctLvToAccountType, buildBalance, mapPositionUpdates, mapPositions, mapSinglePosition, mergeRawCoins };
@@ -1,51 +0,0 @@
1
- import { OkxExchangeWs } from '../../client/okx/exchange-ws.js';
2
- import { SupportedCredentials } from '../../types.js';
3
- import { BaseAccountTracker, AccountTrackerConfig } from '../base.js';
4
- import '@pear-protocol/types';
5
- import '../../client/base-ws.js';
6
- import 'partysocket';
7
- import '../../client/exchange-ws.js';
8
- import '../../client/okx/ws.js';
9
- import '@pear-protocol/core-sdk';
10
- import '../../client/binance/exchange-ws.js';
11
- import '../../client/binance/ws.js';
12
- import '../../client/bybit/exchange-ws.js';
13
- import '../../client/bybit/ws.js';
14
- import '../../client/hyperliquid/exchange-ws.js';
15
- import '../../client/hyperliquid/ws.js';
16
- import '../../client/lighter/exchange-ws.js';
17
- import '../../client/lighter/ws.js';
18
- import '../types.js';
19
- import '../binance/types.js';
20
- import '../bybit/types.js';
21
- import '../hyperliquid/types.js';
22
- import '../lighter/types.js';
23
- import './types.js';
24
-
25
- type OkxAccountTrackerConfig = AccountTrackerConfig & {
26
- credentials: SupportedCredentials;
27
- ws: OkxExchangeWs;
28
- };
29
- declare class OkxAccountTracker extends BaseAccountTracker {
30
- private readonly creds;
31
- private readonly ws;
32
- private messageListenerId;
33
- private openListenerId;
34
- private rawCoins;
35
- private lastBalance;
36
- private accountType;
37
- private trackedAssetInfos;
38
- constructor(config: OkxAccountTrackerConfig);
39
- start(): Promise<void>;
40
- protected cleanupConnections(): Promise<void>;
41
- get isConnected(): boolean;
42
- protected ensureAssetTracked(instId: string): void;
43
- protected releaseAsset(instId: string): void;
44
- private subscribe;
45
- private handleInitialData;
46
- private routeRaw;
47
- private handleMessage;
48
- private handleBalanceUpdate;
49
- }
50
-
51
- export { OkxAccountTracker, type OkxAccountTrackerConfig };
@@ -1,8 +0,0 @@
1
- declare enum OkxAccountType {
2
- SPOT = "OKX_SPOT",
3
- SINGLE_CURRENCY_MARGIN = "OKX_SINGLE",
4
- MULTI_CURRENCY_MARGIN = "OKX_MULTI",
5
- PORTFOLIO_MARGIN = "OKX_PORTFOLIO"
6
- }
7
-
8
- export { OkxAccountType };
@@ -1,63 +0,0 @@
1
- import { BinanceAccountType } from './binance/types.js';
2
- import { BybitAccountType } from './bybit/types.js';
3
- import { HyperliquidAccountType } from './hyperliquid/types.js';
4
- import { LighterAccountType } from './lighter/types.js';
5
- import { OkxAccountType } from './okx/types.js';
6
-
7
- type MarginMode = 'cross' | 'isolated';
8
- type AccountType = BinanceAccountType | BybitAccountType | HyperliquidAccountType | LighterAccountType | OkxAccountType;
9
- declare const ACCOUNT_TYPE_LABELS: Record<AccountType, string>;
10
- interface AssetBalance {
11
- asset: string;
12
- free: string;
13
- used: string;
14
- total: string;
15
- walletBalance: string;
16
- usdValue: string;
17
- }
18
- interface AccountBalance {
19
- accountType: AccountType;
20
- free: Record<string, string>;
21
- used: Record<string, string>;
22
- total: Record<string, string>;
23
- availableToTrade: string;
24
- totalEquity: string;
25
- walletBalance: string;
26
- unrealizedPnl: string;
27
- initialMarginUsed: string;
28
- maintenanceMargin: string;
29
- marginRatio: string;
30
- assets: AssetBalance[];
31
- timestamp: number;
32
- }
33
- interface AccountPosition {
34
- symbol: string;
35
- side: 'long' | 'short' | 'both';
36
- size: string;
37
- entryPrice: string;
38
- unrealizedPnl: string;
39
- leverage: string;
40
- marginType: MarginMode;
41
- liquidationPrice: string | null;
42
- }
43
- interface TrackedAssetInfo {
44
- coin: string;
45
- leverage: string;
46
- marginType: MarginMode;
47
- }
48
- interface ExchangeState {
49
- balance: AccountBalance | null;
50
- positions: Map<string, AccountPosition>;
51
- lastUpdated: number;
52
- initialized: boolean;
53
- }
54
- type BalanceCallback = (balance: AccountBalance) => void;
55
- type PositionsCallback = (positions: AccountPosition[]) => void;
56
- type TrackedAssetCallback = (info: TrackedAssetInfo) => void;
57
- interface StateUpdate {
58
- balance?: AccountBalance;
59
- positions?: Map<string, AccountPosition>;
60
- trackedAssets?: Map<string, TrackedAssetInfo>;
61
- }
62
-
63
- export { ACCOUNT_TYPE_LABELS, type AccountBalance, type AccountPosition, type AccountType, type AssetBalance, type BalanceCallback, type ExchangeState, type MarginMode, type PositionsCallback, type StateUpdate, type TrackedAssetCallback, type TrackedAssetInfo };
@@ -1,11 +0,0 @@
1
- import { ExchangeState } from './types.js';
2
- import './binance/types.js';
3
- import './bybit/types.js';
4
- import './hyperliquid/types.js';
5
- import './lighter/types.js';
6
- import './okx/types.js';
7
-
8
- declare function createEmptyState(): ExchangeState;
9
- declare function positionKey(symbol: string, side: string): string;
10
-
11
- export { createEmptyState, positionKey };
package/dist/types.d.ts DELETED
@@ -1,50 +0,0 @@
1
- import PearSDK from '@pear-protocol/core-sdk';
2
- import { BinanceCredentialsDTO, BybitCredentialsDTO, HyperliquidCredentialsDTO, LighterCredentialsDTO, OkxCredentialsDTO } from '@pear-protocol/types';
3
- import { BinanceExchangeWs } from './client/binance/exchange-ws.js';
4
- import { BybitExchangeWs } from './client/bybit/exchange-ws.js';
5
- import { HyperliquidExchangeWs } from './client/hyperliquid/exchange-ws.js';
6
- import { LighterExchangeWs } from './client/lighter/exchange-ws.js';
7
- import { OkxExchangeWs } from './client/okx/exchange-ws.js';
8
- import './client/base-ws.js';
9
- import 'partysocket';
10
- import './client/exchange-ws.js';
11
- import './client/binance/ws.js';
12
- import './client/bybit/ws.js';
13
- import './client/hyperliquid/ws.js';
14
- import './client/lighter/ws.js';
15
- import './client/okx/ws.js';
16
-
17
- type HyperliquidAccountCredentials = HyperliquidCredentialsDTO & {
18
- accountIdentifier: string;
19
- };
20
- type LighterAccountCredentials = LighterCredentialsDTO & {
21
- accountIdentifier: string;
22
- };
23
- type SupportedCredentials = BinanceCredentialsDTO | BybitCredentialsDTO | HyperliquidAccountCredentials | LighterAccountCredentials | OkxCredentialsDTO;
24
- type ExchangesSDKConfig = {
25
- sdk: PearSDK;
26
- demo?: boolean;
27
- };
28
- type ExchangeConnection = {
29
- exchange: 'binance';
30
- credentials: BinanceCredentialsDTO;
31
- ws: BinanceExchangeWs;
32
- } | {
33
- exchange: 'bybit';
34
- credentials: BybitCredentialsDTO;
35
- ws: BybitExchangeWs;
36
- } | {
37
- exchange: 'okx';
38
- credentials: OkxCredentialsDTO;
39
- ws: OkxExchangeWs;
40
- } | {
41
- exchange: 'hyperliquid';
42
- credentials: HyperliquidAccountCredentials;
43
- ws: HyperliquidExchangeWs;
44
- } | {
45
- exchange: 'lighter';
46
- credentials: LighterAccountCredentials;
47
- ws: LighterExchangeWs;
48
- };
49
-
50
- export type { ExchangeConnection, ExchangesSDKConfig, HyperliquidAccountCredentials, LighterAccountCredentials, SupportedCredentials };