@pear-protocol/exchanges-sdk 0.1.7 → 0.1.9

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,23 +0,0 @@
1
- import { WalletClient, Transport, Chain, Account } from 'viem';
2
-
3
- type WalletClientWithAccount = WalletClient<Transport, Chain | undefined, Account>;
4
- type ChangePubKeyParams = {
5
- accountIndex: number;
6
- apiKeyIndex: number;
7
- pubKey: `0x${string}`;
8
- };
9
- type DepositParams = {
10
- to: `0x${string}`;
11
- assetIndex: number;
12
- routeType: number;
13
- amount: bigint;
14
- value?: bigint;
15
- };
16
- type WithdrawParams = {
17
- accountIndex: number;
18
- assetIndex: number;
19
- routeType: number;
20
- baseAmount: bigint;
21
- };
22
-
23
- export type { ChangePubKeyParams, DepositParams, WalletClientWithAccount, WithdrawParams };
@@ -1,10 +0,0 @@
1
- import PearSDK from '@pear-protocol/core-sdk';
2
- import { LighterHelper } from './types.js';
3
- import '../../client/lighter/rest.js';
4
- import './ethereum/types.js';
5
- import 'viem';
6
- import '../../client/lighter/types.js';
7
-
8
- declare function createLighterHelper(sdk: PearSDK): LighterHelper;
9
-
10
- export { createLighterHelper };
@@ -1,7 +0,0 @@
1
- export { createLighterHelper } from './helper.js';
2
- export { ASSET_DECIMALS, ApproveIntegratorParams, ApproveIntegratorResult, AssetId, ConnectWalletParams, ConnectWalletResult, DepositParams, LighterHelper, LighterLookupResult, RouteType, WithdrawParams, getAssetDecimals } from './types.js';
3
- export { ApiKey } from '../../client/lighter/rest.js';
4
- export { WalletClientWithAccount } from './ethereum/types.js';
5
- import '@pear-protocol/core-sdk';
6
- import 'viem';
7
- import '../../client/lighter/types.js';
@@ -1,64 +0,0 @@
1
- import { WalletClientWithAccount } from './ethereum/types.js';
2
- export { ApiKey } from '../../client/lighter/rest.js';
3
- import 'viem';
4
- import '../../client/lighter/types.js';
5
-
6
- declare const AssetId: {
7
- readonly ETH: 1;
8
- readonly LIT: 2;
9
- readonly USDC: 3;
10
- readonly LINK: 5;
11
- readonly UNI: 6;
12
- readonly AAVE: 7;
13
- readonly SKY: 8;
14
- readonly LDO: 9;
15
- };
16
- type AssetId = (typeof AssetId)[keyof typeof AssetId];
17
- declare const RouteType: {
18
- readonly PERP: 0;
19
- readonly SPOT: 1;
20
- };
21
- type RouteType = (typeof RouteType)[keyof typeof RouteType];
22
- declare const ASSET_DECIMALS: Record<number, number>;
23
- declare function getAssetDecimals(assetId: number): number;
24
- type ConnectWalletParams = {
25
- accountIndex: number;
26
- };
27
- type DepositParams = {
28
- to: `0x${string}`;
29
- assetId: number;
30
- routeType: number;
31
- amount: string;
32
- nativeValue?: string;
33
- };
34
- type WithdrawParams = {
35
- accountIndex: number;
36
- assetId: number;
37
- routeType: number;
38
- amount: string;
39
- };
40
- type ConnectWalletResult = {
41
- txHash: string;
42
- apiKeyIndex: number;
43
- apiPrivateKey: string;
44
- };
45
- type ApproveIntegratorParams = {
46
- accountIndex: number;
47
- apiKeyIndex: number;
48
- apiPrivateKey: string;
49
- };
50
- type ApproveIntegratorResult = {
51
- txHash: string;
52
- };
53
- interface LighterHelper {
54
- lookupAccount(l1Address: string): Promise<LighterLookupResult>;
55
- checkIntegratorApproval(accountIndex: number, integratorAccountIndex: number): Promise<boolean>;
56
- connectWallet(walletClient: WalletClientWithAccount, params: ConnectWalletParams): Promise<ConnectWalletResult>;
57
- approveIntegrator(walletClient: WalletClientWithAccount, params: ApproveIntegratorParams): Promise<ApproveIntegratorResult>;
58
- }
59
- type LighterLookupResult = {
60
- mainAccountIndex: number;
61
- subAccountIndexes: number[];
62
- };
63
-
64
- export { ASSET_DECIMALS, type ApproveIntegratorParams, type ApproveIntegratorResult, AssetId, type ConnectWalletParams, type ConnectWalletResult, type DepositParams, type LighterHelper, type LighterLookupResult, RouteType, WalletClientWithAccount, type WithdrawParams, getAssetDecimals };
@@ -1,12 +0,0 @@
1
- import { LighterHelper } from './lighter/types.js';
2
- import './lighter/ethereum/types.js';
3
- import 'viem';
4
- import '../client/lighter/rest.js';
5
- import '../client/lighter/types.js';
6
-
7
- type ExchangeHelperMap = {
8
- lighter: LighterHelper;
9
- };
10
- type ExchangeHelperExchange = keyof ExchangeHelperMap;
11
-
12
- export type { ExchangeHelperExchange, ExchangeHelperMap };
package/dist/sdk.d.ts DELETED
@@ -1,44 +0,0 @@
1
- import { Connector } from '@pear-protocol/types';
2
- import { ExchangeHelperExchange, ExchangeHelperMap } from './helper/types.js';
3
- import { AccountSyncer } from './syncer/base.js';
4
- import { ExchangesSDKConfig, ExchangeConnection } from './types.js';
5
- import { AccountTracker } from './tracker/base.js';
6
- import './helper/lighter/types.js';
7
- import './helper/lighter/ethereum/types.js';
8
- import 'viem';
9
- import './client/lighter/rest.js';
10
- import './client/lighter/types.js';
11
- import '@pear-protocol/core-sdk';
12
- import './client/index.js';
13
- import './client/binance/exchange-ws.js';
14
- import './client/base-ws.js';
15
- import 'partysocket';
16
- import './client/exchange-ws.js';
17
- import './client/binance/ws.js';
18
- import './client/bybit/exchange-ws.js';
19
- import './client/bybit/ws.js';
20
- import './client/hyperliquid/exchange-ws.js';
21
- import './client/hyperliquid/ws.js';
22
- import './client/lighter/exchange-ws.js';
23
- import './client/lighter/ws.js';
24
- import './client/okx/exchange-ws.js';
25
- import './client/okx/ws.js';
26
- import './tracker/types.js';
27
- import './tracker/binance/types.js';
28
- import './tracker/bybit/types.js';
29
- import './tracker/hyperliquid/types.js';
30
- import './tracker/lighter/types.js';
31
- import './tracker/okx/types.js';
32
-
33
- declare class ExchangesSDK {
34
- private sdk;
35
- private demo;
36
- constructor(config: ExchangesSDKConfig);
37
- connect(tradeAccountId: string, exchange: Connector): Promise<ExchangeConnection>;
38
- createTracker(connection: ExchangeConnection): AccountTracker;
39
- createHelper<E extends ExchangeHelperExchange>(exchange: E): ExchangeHelperMap[E];
40
- createSyncer(connection: ExchangeConnection): AccountSyncer;
41
- private fetchCredentials;
42
- }
43
-
44
- export { ExchangesSDK };
@@ -1,47 +0,0 @@
1
- import PearSDK from '@pear-protocol/core-sdk';
2
- import { Connector, HttpTypes } from '@pear-protocol/types';
3
- import { ExchangeWsByConnector } from '../client/index.js';
4
- import { SupportedCredentials } from '../types.js';
5
- import '../client/binance/exchange-ws.js';
6
- import '../client/base-ws.js';
7
- import 'partysocket';
8
- import '../client/exchange-ws.js';
9
- import '../client/binance/ws.js';
10
- import '../client/bybit/exchange-ws.js';
11
- import '../client/bybit/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
-
19
- interface AccountSyncerConfig {
20
- sdk: PearSDK;
21
- connector: Connector;
22
- credentials: SupportedCredentials;
23
- ws: ExchangeWsByConnector[Connector];
24
- demo: boolean;
25
- }
26
- interface AccountSyncer {
27
- synchronize(): Promise<void>;
28
- }
29
- interface ListExternalFillsParams {
30
- since: Date;
31
- instruments: HttpTypes.Instrument[];
32
- openPositions: HttpTypes.OpenPositionLite[];
33
- provisionalFills: HttpTypes.ProvisionalFill[];
34
- }
35
- declare abstract class BaseAccountSyncer<ExternalFill> implements AccountSyncer {
36
- protected sdk: PearSDK;
37
- protected connector: Connector;
38
- protected credentials: SupportedCredentials;
39
- protected ws: ExchangeWsByConnector[Connector];
40
- protected demo: boolean;
41
- constructor(config: AccountSyncerConfig);
42
- protected abstract listExternalFills(params: ListExternalFillsParams): Promise<HttpTypes.UnknownExternalFill[]>;
43
- protected abstract isReduceOnly(fill: ExternalFill): boolean;
44
- synchronize(): Promise<void>;
45
- }
46
-
47
- export { type AccountSyncer, type AccountSyncerConfig, BaseAccountSyncer, type ListExternalFillsParams };
@@ -1,31 +0,0 @@
1
- import { HttpTypes } from '@pear-protocol/types';
2
- import { BinanceRawUserTrade } from '../../client/binance/types.js';
3
- import { BaseAccountSyncer, AccountSyncerConfig, ListExternalFillsParams } from '../base.js';
4
- import '@pear-protocol/core-sdk';
5
- import '../../client/index.js';
6
- import '../../types.js';
7
- import '../../client/binance/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/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 '../../client/okx/exchange-ws.js';
19
- import '../../client/okx/ws.js';
20
-
21
- declare class BinanceAccountSyncer extends BaseAccountSyncer<BinanceRawUserTrade> {
22
- private readonly creds;
23
- constructor(config: AccountSyncerConfig);
24
- protected listExternalFills({ since, instruments, openPositions, provisionalFills, }: ListExternalFillsParams): Promise<HttpTypes.UnknownExternalFill[]>;
25
- protected isReduceOnly(trade: BinanceRawUserTrade): boolean;
26
- private collectRequestedInstrumentIds;
27
- private mapOrdersBySymbolOrderId;
28
- private orderKey;
29
- }
30
-
31
- export { BinanceAccountSyncer };
@@ -1,28 +0,0 @@
1
- import { HttpTypes } from '@pear-protocol/types';
2
- import { BybitRawExecution } from '../../client/bybit/types.js';
3
- import { BaseAccountSyncer, AccountSyncerConfig, ListExternalFillsParams } from '../base.js';
4
- import '@pear-protocol/core-sdk';
5
- import '../../client/index.js';
6
- import '../../types.js';
7
- import '../../client/binance/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/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 '../../client/okx/exchange-ws.js';
19
- import '../../client/okx/ws.js';
20
-
21
- declare class BybitAccountSyncer extends BaseAccountSyncer<BybitRawExecution> {
22
- private readonly creds;
23
- constructor(config: AccountSyncerConfig);
24
- protected listExternalFills({ since }: ListExternalFillsParams): Promise<HttpTypes.UnknownExternalFill[]>;
25
- protected isReduceOnly(execution: BybitRawExecution): boolean;
26
- }
27
-
28
- export { BybitAccountSyncer };
@@ -1,22 +0,0 @@
1
- import { Connector } from '@pear-protocol/types';
2
- import { AccountSyncerConfig, AccountSyncer } from './base.js';
3
- import '@pear-protocol/core-sdk';
4
- import '../client/index.js';
5
- import '../types.js';
6
- import '../client/binance/exchange-ws.js';
7
- import '../client/base-ws.js';
8
- import 'partysocket';
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/lighter/ws.js';
17
- import '../client/okx/exchange-ws.js';
18
- import '../client/okx/ws.js';
19
-
20
- declare function createAccountSyncer(exchange: Connector, config: AccountSyncerConfig): AccountSyncer;
21
-
22
- export { createAccountSyncer };
@@ -1,28 +0,0 @@
1
- import { HttpTypes } from '@pear-protocol/types';
2
- import { UserFillsByTimeResponse } from '../../client/hyperliquid/types.js';
3
- import { BaseAccountSyncer, AccountSyncerConfig, ListExternalFillsParams } from '../base.js';
4
- import '@pear-protocol/core-sdk';
5
- import '../../client/index.js';
6
- import '../../types.js';
7
- import '../../client/binance/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/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 '../../client/okx/exchange-ws.js';
19
- import '../../client/okx/ws.js';
20
-
21
- declare class HyperliquidAccountSyncer extends BaseAccountSyncer<UserFillsByTimeResponse> {
22
- private readonly address;
23
- constructor(config: AccountSyncerConfig);
24
- protected listExternalFills({ since, instruments, }: ListExternalFillsParams): Promise<HttpTypes.UnknownExternalFill[]>;
25
- protected isReduceOnly(fill: UserFillsByTimeResponse): boolean;
26
- }
27
-
28
- export { HyperliquidAccountSyncer };
@@ -1,29 +0,0 @@
1
- export { AccountSyncer, AccountSyncerConfig, BaseAccountSyncer, ListExternalFillsParams } from './base.js';
2
- export { BinanceAccountSyncer } from './binance/syncer.js';
3
- export { BybitAccountSyncer } from './bybit/syncer.js';
4
- export { createAccountSyncer } from './factory.js';
5
- export { HyperliquidAccountSyncer } from './hyperliquid/syncer.js';
6
- export { LighterAccountSyncer } from './lighter/syncer.js';
7
- export { OkxAccountSyncer } from './okx/syncer.js';
8
- import '@pear-protocol/core-sdk';
9
- import '@pear-protocol/types';
10
- import '../client/index.js';
11
- import '../types.js';
12
- import '../client/binance/exchange-ws.js';
13
- import '../client/base-ws.js';
14
- import 'partysocket';
15
- import '../client/exchange-ws.js';
16
- import '../client/binance/ws.js';
17
- import '../client/bybit/exchange-ws.js';
18
- import '../client/bybit/ws.js';
19
- import '../client/hyperliquid/exchange-ws.js';
20
- import '../client/hyperliquid/ws.js';
21
- import '../client/lighter/exchange-ws.js';
22
- import '../client/lighter/ws.js';
23
- import '../client/okx/exchange-ws.js';
24
- import '../client/okx/ws.js';
25
- import '../client/binance/types.js';
26
- import '../client/bybit/types.js';
27
- import '../client/hyperliquid/types.js';
28
- import '../client/lighter/types.js';
29
- import '../client/okx/types.js';
@@ -1,37 +0,0 @@
1
- import { HttpTypes } from '@pear-protocol/types';
2
- import { LighterRawTrade } from '../../client/lighter/types.js';
3
- import { BaseAccountSyncer, AccountSyncerConfig, ListExternalFillsParams } from '../base.js';
4
- import '@pear-protocol/core-sdk';
5
- import '../../client/index.js';
6
- import '../../types.js';
7
- import '../../client/binance/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/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 '../../client/okx/exchange-ws.js';
19
- import '../../client/okx/ws.js';
20
-
21
- declare class LighterAccountSyncer extends BaseAccountSyncer<LighterRawTrade> {
22
- private readonly accountIndex;
23
- private readonly apiKeyIndex;
24
- private readonly apiPrivateKey;
25
- constructor(config: AccountSyncerConfig);
26
- protected listExternalFills({ since, instruments, }: ListExternalFillsParams): Promise<HttpTypes.UnknownExternalFill[]>;
27
- protected isReduceOnly(trade: LighterRawTrade): boolean;
28
- private getAccountSide;
29
- private getClientOrderId;
30
- private isMaker;
31
- private getPositionSizeBefore;
32
- private getTradeFee;
33
- private getIntegratorFee;
34
- private feeTickToDecimal;
35
- }
36
-
37
- export { LighterAccountSyncer };
@@ -1,29 +0,0 @@
1
- import { HttpTypes } from '@pear-protocol/types';
2
- import { OkxRawFill } from '../../client/okx/types.js';
3
- import { BaseAccountSyncer, AccountSyncerConfig, ListExternalFillsParams } from '../base.js';
4
- import '@pear-protocol/core-sdk';
5
- import '../../client/index.js';
6
- import '../../types.js';
7
- import '../../client/binance/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/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 '../../client/okx/exchange-ws.js';
19
- import '../../client/okx/ws.js';
20
-
21
- declare class OkxAccountSyncer extends BaseAccountSyncer<OkxRawFill> {
22
- private readonly creds;
23
- constructor(config: AccountSyncerConfig);
24
- protected listExternalFills({ since, instruments, }: ListExternalFillsParams): Promise<HttpTypes.UnknownExternalFill[]>;
25
- protected isReduceOnly(fill: OkxRawFill): boolean;
26
- private contractsToBase;
27
- }
28
-
29
- export { OkxAccountSyncer };
@@ -1,79 +0,0 @@
1
- import { SupportedCredentials } from '../types.js';
2
- import { BalanceCallback, PositionsCallback, TrackedAssetCallback, AccountBalance, AccountPosition, TrackedAssetInfo, StateUpdate } from './types.js';
3
- import '@pear-protocol/core-sdk';
4
- import '@pear-protocol/types';
5
- import '../client/binance/exchange-ws.js';
6
- import '../client/base-ws.js';
7
- import 'partysocket';
8
- import '../client/exchange-ws.js';
9
- import '../client/binance/ws.js';
10
- import '../client/bybit/exchange-ws.js';
11
- import '../client/bybit/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 './binance/types.js';
19
- import './bybit/types.js';
20
- import './hyperliquid/types.js';
21
- import './lighter/types.js';
22
- import './okx/types.js';
23
-
24
- type ErrorHandler = (error: Error) => void;
25
- type AccountTrackerConfig = {
26
- demo: boolean;
27
- onError?: ErrorHandler;
28
- };
29
- interface AccountTracker {
30
- start(): Promise<void>;
31
- disconnect(): Promise<void>;
32
- readonly isConnected: boolean;
33
- readonly isInitialized: boolean;
34
- readonly hasListeners: boolean;
35
- trackBalance(cb: BalanceCallback): () => void;
36
- trackPosition(cb: PositionsCallback): () => void;
37
- trackAsset(asset: string, cb: TrackedAssetCallback): () => void;
38
- getBalance(): AccountBalance | null;
39
- getPositions(): AccountPosition[];
40
- getTrackedAsset(coin: string): TrackedAssetInfo | null;
41
- }
42
- declare abstract class BaseAccountTracker implements AccountTracker {
43
- protected onError: ErrorHandler;
44
- protected demo: boolean;
45
- protected credentials: SupportedCredentials | null;
46
- private balance;
47
- private positions;
48
- private initialized;
49
- private balanceListeners;
50
- private positionListeners;
51
- private assetEntries;
52
- constructor(config: AccountTrackerConfig);
53
- disconnect(): Promise<void>;
54
- get isInitialized(): boolean;
55
- get hasListeners(): boolean;
56
- trackBalance(cb: BalanceCallback): () => void;
57
- trackPosition(cb: PositionsCallback): () => void;
58
- trackAsset(asset: string, cb: TrackedAssetCallback): () => void;
59
- private releaseAssetListener;
60
- protected get trackedCoins(): ReadonlySet<string>;
61
- getBalance(): AccountBalance | null;
62
- getPositions(): AccountPosition[];
63
- getTrackedAsset(coin: string): TrackedAssetInfo | null;
64
- protected onStateUpdate(update: StateUpdate): void;
65
- private applyBalanceUpdate;
66
- private applyPositionsUpdate;
67
- private applyTrackedAssetsUpdate;
68
- private getOrCreateAssetEntry;
69
- private positionSnapshot;
70
- private notify;
71
- private broadcast;
72
- abstract start(): Promise<void>;
73
- abstract get isConnected(): boolean;
74
- protected abstract ensureAssetTracked(asset: string): void;
75
- protected abstract releaseAsset(asset: string): void;
76
- protected abstract cleanupConnections(): void | Promise<void>;
77
- }
78
-
79
- export { type AccountTracker, type AccountTrackerConfig, BaseAccountTracker };
@@ -1,4 +0,0 @@
1
- declare const DEFAULT_LISTEN_KEY_REFRESH_MS: number;
2
- declare const DEFAULT_ACCOUNT_POLL_MS = 1000;
3
-
4
- export { DEFAULT_ACCOUNT_POLL_MS, DEFAULT_LISTEN_KEY_REFRESH_MS };
@@ -1,14 +0,0 @@
1
- import { BinanceRawAccountStatus, BinanceRawPositionRisk } from '../../client/binance/types.js';
2
- import { AccountBalance, AccountPosition } from '../types.js';
3
- import '@pear-protocol/types';
4
- import './types.js';
5
- import '../bybit/types.js';
6
- import '../hyperliquid/types.js';
7
- import '../lighter/types.js';
8
- import '../okx/types.js';
9
-
10
- declare function mapBalance(raw: BinanceRawAccountStatus): Omit<AccountBalance, 'accountType'>;
11
- declare function mapPositions(raw: BinanceRawPositionRisk[]): Map<string, AccountPosition>;
12
- declare function mergePositions(incoming: Map<string, AccountPosition>, existing: Map<string, AccountPosition>): Map<string, AccountPosition>;
13
-
14
- export { mapBalance, mapPositions, mergePositions };
@@ -1,60 +0,0 @@
1
- import { BinanceUserDataWs, BinanceWsApi } from '../../client/binance/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 '@pear-protocol/core-sdk';
8
- import '../../client/binance/exchange-ws.js';
9
- import '../../client/exchange-ws.js';
10
- import '../../client/bybit/exchange-ws.js';
11
- import '../../client/bybit/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 './types.js';
20
- import '../bybit/types.js';
21
- import '../hyperliquid/types.js';
22
- import '../lighter/types.js';
23
- import '../okx/types.js';
24
-
25
- type BinanceAccountTrackerConfig = AccountTrackerConfig & {
26
- credentials: SupportedCredentials;
27
- userDataWs: BinanceUserDataWs;
28
- wsApiWs: BinanceWsApi;
29
- listenKeyRefreshMs?: number;
30
- accountPollMs?: number;
31
- };
32
- declare class BinanceAccountTracker extends BaseAccountTracker {
33
- private readonly creds;
34
- private readonly userDataWs;
35
- private readonly wsApiWs;
36
- private readonly listenKeyRefreshMs;
37
- private readonly accountPollMs;
38
- private userDataListenerId;
39
- private wsApiListenerId;
40
- private listenKeyTimer;
41
- private pollTimer;
42
- private currentPositions;
43
- private accountType;
44
- private trackedAssetInfos;
45
- constructor(config: BinanceAccountTrackerConfig);
46
- start(): Promise<void>;
47
- protected cleanupConnections(): Promise<void>;
48
- get isConnected(): boolean;
49
- protected ensureAssetTracked(coin: string): void;
50
- protected releaseAsset(coin: string): void;
51
- private pollAccountStatus;
52
- private routeUserData;
53
- private routeWsApi;
54
- private handleAccountStatus;
55
- private handlePositionRisk;
56
- private handleUserDataEvent;
57
- private refreshAllPositions;
58
- }
59
-
60
- export { BinanceAccountTracker, type BinanceAccountTrackerConfig };
@@ -1,6 +0,0 @@
1
- declare enum BinanceAccountType {
2
- MULTI_ASSET = "MULTI_ASSET",
3
- SINGLE_ASSET = "SINGLE_ASSET"
4
- }
5
-
6
- export { BinanceAccountType };
@@ -1,15 +0,0 @@
1
- import { BybitRawWallet, BybitRawCoin, BybitRawPosition } from '../../client/bybit/types.js';
2
- import { AccountBalance, AccountPosition } from '../types.js';
3
- import { BybitAccountType } from './types.js';
4
- import '../binance/types.js';
5
- import '../hyperliquid/types.js';
6
- import '../lighter/types.js';
7
- import '../okx/types.js';
8
-
9
- declare function buildBalance(raw: BybitRawWallet, coins: Map<string, BybitRawCoin>, accountType: BybitAccountType | null): AccountBalance | null;
10
- declare function mergeRawCoins(existing: Map<string, BybitRawCoin>, incoming: BybitRawCoin[]): Map<string, BybitRawCoin>;
11
- declare function mapSinglePosition(p: BybitRawPosition, size: string): AccountPosition;
12
- declare function mapPositions(raw: BybitRawPosition[]): Map<string, AccountPosition>;
13
- declare function mapPositionUpdates(raw: BybitRawPosition[]): Map<string, AccountPosition>;
14
-
15
- export { buildBalance, mapPositionUpdates, mapPositions, mapSinglePosition, mergeRawCoins };