@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,17 +0,0 @@
1
- import { BybitCredentialsDTO } from '@pear-protocol/types';
2
- import { BaseWs, WsMessage } from '../base-ws.js';
3
- import 'partysocket';
4
-
5
- type BybitWsConfig = {
6
- demo: boolean;
7
- };
8
- declare class BybitWs extends BaseWs {
9
- private readonly demo;
10
- constructor(config: BybitWsConfig);
11
- protected getWsUrl(): string;
12
- protected getPingIntervalMs(): number;
13
- protected buildPingMessage(): WsMessage;
14
- authenticate(creds: BybitCredentialsDTO): Promise<void>;
15
- }
16
-
17
- export { BybitWs, type BybitWsConfig };
@@ -1,12 +0,0 @@
1
- import { Connector } from '@pear-protocol/types';
2
- import { BaseWs } from './base-ws.js';
3
- import 'partysocket';
4
-
5
- declare abstract class ExchangeWs {
6
- abstract readonly exchange: Connector;
7
- protected abstract connections(): BaseWs[];
8
- destroy(): void;
9
- get isConnected(): boolean;
10
- }
11
-
12
- export { ExchangeWs };
@@ -1,4 +0,0 @@
1
- declare function hmacSha256Hex(secret: string, message: string): Promise<string>;
2
- declare function hmacSha256Base64(secret: string, message: string): Promise<string>;
3
-
4
- export { hmacSha256Base64, hmacSha256Hex };
@@ -1,15 +0,0 @@
1
- import { BaseWs } from '../base-ws.js';
2
- import { ExchangeWs } from '../exchange-ws.js';
3
- import { HyperliquidWs } from './ws.js';
4
- import 'partysocket';
5
- import '@pear-protocol/types';
6
-
7
- declare class HyperliquidExchangeWs extends ExchangeWs {
8
- main: HyperliquidWs;
9
- readonly exchange: "hyperliquid";
10
- constructor(main: HyperliquidWs);
11
- protected connections(): BaseWs[];
12
- static create(): Promise<HyperliquidExchangeWs>;
13
- }
14
-
15
- export { HyperliquidExchangeWs };
@@ -1,3 +0,0 @@
1
- declare function fetchInfo<T>(body: Record<string, unknown>): Promise<T>;
2
-
3
- export { fetchInfo };
@@ -1,188 +0,0 @@
1
- type LeverageInfo = {
2
- type: 'isolated';
3
- value: number;
4
- rawUsd: string;
5
- } | {
6
- type: 'cross';
7
- value: number;
8
- };
9
- type MetaResponse = {
10
- universe: {
11
- szDecimals: number;
12
- name: string;
13
- maxLeverage: number;
14
- marginTableId: number;
15
- onlyIsolated?: true;
16
- isDelisted?: true;
17
- }[];
18
- marginTables: [
19
- id: number,
20
- table: {
21
- description: string;
22
- marginTiers: {
23
- lowerBound: string;
24
- maxLeverage: number;
25
- }[];
26
- }
27
- ][];
28
- collateralToken: number;
29
- };
30
- type AllPerpMetasResponse = MetaResponse[];
31
- type ClearinghouseStateResponse = {
32
- marginSummary: {
33
- accountValue: string;
34
- totalNtlPos: string;
35
- totalRawUsd: string;
36
- totalMarginUsed: string;
37
- };
38
- crossMarginSummary: {
39
- accountValue: string;
40
- totalNtlPos: string;
41
- totalRawUsd: string;
42
- totalMarginUsed: string;
43
- };
44
- crossMaintenanceMarginUsed: string;
45
- withdrawable: string;
46
- assetPositions: {
47
- type: 'oneWay';
48
- position: {
49
- coin: string;
50
- szi: string;
51
- leverage: LeverageInfo;
52
- entryPx: string;
53
- positionValue: string;
54
- unrealizedPnl: string;
55
- returnOnEquity: string;
56
- liquidationPx: string | null;
57
- marginUsed: string;
58
- maxLeverage: number;
59
- cumFunding: {
60
- allTime: string;
61
- sinceOpen: string;
62
- sinceChange: string;
63
- };
64
- };
65
- }[];
66
- time: number;
67
- };
68
- type AssetPosition = ClearinghouseStateResponse['assetPositions'][number];
69
- type SpotClearinghouseStateResponse = {
70
- balances: {
71
- coin: string;
72
- token: number;
73
- total: string;
74
- hold: string;
75
- entryNtl: string;
76
- }[];
77
- };
78
- type AllDexsClearinghouseStateEvent = {
79
- user: `0x${string}`;
80
- clearinghouseStates: [dex: string, state: ClearinghouseStateResponse][];
81
- };
82
- type ActiveAssetDataEvent = {
83
- user: `0x${string}`;
84
- coin: string;
85
- leverage: LeverageInfo;
86
- maxTradeSzs: [min: string, max: string];
87
- availableToTrade: [min: string, max: string];
88
- markPx: string;
89
- };
90
- type SpotStateEvent = {
91
- user: `0x${string}`;
92
- spotState: SpotClearinghouseStateResponse;
93
- };
94
- type WebData3Event = {
95
- userState: {
96
- agentAddress: `0x${string}` | null;
97
- agentValidUntil: number | null;
98
- cumLedger: string;
99
- serverTime: number;
100
- isVault: boolean;
101
- user: `0x${string}`;
102
- optOutOfSpotDusting?: true;
103
- dexAbstractionEnabled?: boolean;
104
- abstraction?: 'dexAbstraction' | 'unifiedAccount' | 'portfolioMargin' | 'disabled';
105
- };
106
- perpDexStates: {
107
- totalVaultEquity: string;
108
- perpsAtOpenInterestCap?: unknown;
109
- leadingVaults?: unknown;
110
- }[];
111
- };
112
- type UserFillsByTimeResponse = {
113
- /** Asset symbol. */
114
- coin: string;
115
- /**
116
- * Price.
117
- * @pattern ^[0-9]+(\.[0-9]+)?$
118
- */
119
- px: string;
120
- /**
121
- * Size.
122
- * @pattern ^[0-9]+(\.[0-9]+)?$
123
- */
124
- sz: string;
125
- /** Order side ("B" = Bid/Buy, "A" = Ask/Sell). */
126
- side: 'B' | 'A';
127
- /** Timestamp when the trade occurred (in ms since epoch). */
128
- time: number;
129
- /**
130
- * Start position size.
131
- * @pattern ^-?[0-9]+(\.[0-9]+)?$
132
- */
133
- startPosition: string;
134
- /** Direction indicator for frontend display. */
135
- dir: string;
136
- /**
137
- * Realized PnL.
138
- * @pattern ^-?[0-9]+(\.[0-9]+)?$
139
- */
140
- closedPnl: string;
141
- /**
142
- * L1 transaction hash.
143
- * @pattern ^0x[a-fA-F0-9]{64}$
144
- */
145
- hash: `0x${string}`;
146
- /** Order ID. */
147
- oid: number;
148
- /** Indicates if the fill was a taker order. */
149
- crossed: boolean;
150
- /**
151
- * Fee charged or rebate received (negative indicates rebate).
152
- * @pattern ^-?[0-9]+(\.[0-9]+)?$
153
- */
154
- fee: string;
155
- /**
156
- * Optional fee charged by the UI builder.
157
- * @pattern ^-?[0-9]+(\.[0-9]+)?$
158
- */
159
- builderFee?: string;
160
- /** Unique transaction identifier for a partial fill of an order. */
161
- tid: number;
162
- /** Token in which the fee is denominated (e.g., "USDC"). */
163
- feeToken: string;
164
- /** ID of the TWAP. */
165
- twapId: number | null;
166
- /**
167
- * Client Order ID.
168
- * @pattern ^0x[a-fA-F0-9]{32}$
169
- */
170
- cloid?: `0x${string}`;
171
- /** Liquidation details. */
172
- liquidation?: {
173
- /**
174
- * Address of the liquidated user.
175
- * @pattern ^0x[a-fA-F0-9]{40}$
176
- */
177
- liquidatedUser: `0x${string}`;
178
- /**
179
- * Mark price at the time of liquidation.
180
- * @pattern ^[0-9]+(\.[0-9]+)?$
181
- */
182
- markPx: string;
183
- /** Liquidation method. */
184
- method: 'market' | 'backstop';
185
- };
186
- };
187
-
188
- export type { ActiveAssetDataEvent, AllDexsClearinghouseStateEvent, AllPerpMetasResponse, AssetPosition, ClearinghouseStateResponse, LeverageInfo, MetaResponse, SpotClearinghouseStateResponse, SpotStateEvent, UserFillsByTimeResponse, WebData3Event };
@@ -1,10 +0,0 @@
1
- import { BaseWs } from '../base-ws.js';
2
- import 'partysocket';
3
-
4
- declare class HyperliquidWs extends BaseWs {
5
- protected getWsUrl(): string;
6
- protected getPingIntervalMs(): number;
7
- protected buildPingMessage(): null;
8
- }
9
-
10
- export { HyperliquidWs };
@@ -1,31 +0,0 @@
1
- import { Connector } from '@pear-protocol/types';
2
- import { SupportedCredentials } from '../types.js';
3
- import { BinanceExchangeWs } from './binance/exchange-ws.js';
4
- import { BybitExchangeWs } from './bybit/exchange-ws.js';
5
- import { HyperliquidExchangeWs } from './hyperliquid/exchange-ws.js';
6
- import { LighterExchangeWs } from './lighter/exchange-ws.js';
7
- import { OkxExchangeWs } from './okx/exchange-ws.js';
8
- export { BaseWs, MessageListener, OpenListener, WsMessage } from './base-ws.js';
9
- export { BinanceUserDataWs, BinanceUserDataWsConfig, BinanceWsApi, BinanceWsApiConfig } from './binance/ws.js';
10
- export { BybitWs, BybitWsConfig } from './bybit/ws.js';
11
- export { ExchangeWs } from './exchange-ws.js';
12
- export { HyperliquidWs } from './hyperliquid/ws.js';
13
- export { LighterWs } from './lighter/ws.js';
14
- export { OkxWs, OkxWsConfig } from './okx/ws.js';
15
- import '@pear-protocol/core-sdk';
16
- import 'partysocket';
17
-
18
- type ExchangeWsByConnector = {
19
- binance: BinanceExchangeWs;
20
- bybit: BybitExchangeWs;
21
- okx: OkxExchangeWs;
22
- hyperliquid: HyperliquidExchangeWs;
23
- lighter: LighterExchangeWs;
24
- };
25
- type CreateExchangeWsConfig = {
26
- demo: boolean;
27
- credentials: SupportedCredentials;
28
- };
29
- declare function createExchangeWs<E extends Connector>(exchange: E, config: CreateExchangeWsConfig): Promise<ExchangeWsByConnector[E]>;
30
-
31
- export { BinanceExchangeWs, BybitExchangeWs, type CreateExchangeWsConfig, type ExchangeWsByConnector, HyperliquidExchangeWs, LighterExchangeWs, OkxExchangeWs, createExchangeWs };
@@ -1,4 +0,0 @@
1
- declare const LIGHTER_BASE_URL = "https://mainnet.zklighter.elliot.ai";
2
- declare const LIGHTER_WS_URL = "wss://mainnet.zklighter.elliot.ai/stream";
3
-
4
- export { LIGHTER_BASE_URL, LIGHTER_WS_URL };
@@ -1,15 +0,0 @@
1
- import { BaseWs } from '../base-ws.js';
2
- import { ExchangeWs } from '../exchange-ws.js';
3
- import { LighterWs } from './ws.js';
4
- import 'partysocket';
5
- import '@pear-protocol/types';
6
-
7
- declare class LighterExchangeWs extends ExchangeWs {
8
- main: LighterWs;
9
- readonly exchange: "lighter";
10
- constructor(main: LighterWs);
11
- protected connections(): BaseWs[];
12
- static create(): Promise<LighterExchangeWs>;
13
- }
14
-
15
- export { LighterExchangeWs };
@@ -1,59 +0,0 @@
1
- import { LighterRawTrade } from './types.js';
2
-
3
- type ApiKey = {
4
- account_index: number;
5
- api_key_index: number;
6
- nonce: number;
7
- public_key: string;
8
- transaction_time: number;
9
- };
10
- type LighterSubAccount = {
11
- account_type: number;
12
- index: number;
13
- };
14
- type LighterAccountResponse = {
15
- code: number;
16
- message?: string;
17
- sub_accounts?: LighterSubAccount[];
18
- };
19
- type ApprovedIntegrator = {
20
- account_index: number;
21
- name: string;
22
- max_perps_taker_fee: number;
23
- max_perps_maker_fee: number;
24
- max_spot_taker_fee: number;
25
- max_spot_maker_fee: number;
26
- approval_expiry: number;
27
- };
28
- type RestPosition = {
29
- market_id: number;
30
- symbol: string;
31
- initial_margin_fraction: string;
32
- sign: 1 | -1;
33
- position: string;
34
- avg_entry_price: string;
35
- unrealized_pnl: string;
36
- liquidation_price: string;
37
- margin_mode: 0 | 1;
38
- };
39
- type DetailedAccountResponse = {
40
- code: number;
41
- message?: string;
42
- accounts: {
43
- positions: RestPosition[];
44
- approved_integrators?: ApprovedIntegrator[];
45
- }[];
46
- };
47
- type OrderBookDetail = {
48
- symbol: string;
49
- market_id: number;
50
- status: 'active' | 'inactive';
51
- default_initial_margin_fraction: number;
52
- };
53
- declare function fetchApiKeys(accountIndex: number): Promise<ApiKey[]>;
54
- declare function fetchAccountsByL1Address(l1Address: string): Promise<LighterAccountResponse>;
55
- declare function fetchAccount(accountIndex: number): Promise<DetailedAccountResponse>;
56
- declare function fetchOrderBookDetails(): Promise<OrderBookDetail[]>;
57
- declare function fetchTradesSince(accountIndex: number, authToken: string, since: Date): Promise<LighterRawTrade[]>;
58
-
59
- export { type ApiKey, type ApprovedIntegrator, type DetailedAccountResponse, type LighterAccountResponse, type LighterSubAccount, type OrderBookDetail, type RestPosition, fetchAccount, fetchAccountsByL1Address, fetchApiKeys, fetchOrderBookDetails, fetchTradesSince };
@@ -1,53 +0,0 @@
1
- type RawPosition = {
2
- market_id: number;
3
- symbol: string;
4
- initial_margin_fraction: string;
5
- sign: 1 | -1;
6
- position: string;
7
- avg_entry_price: string;
8
- unrealized_pnl: string;
9
- liquidation_price: string;
10
- margin_mode: 0 | 1;
11
- };
12
- type RawAsset = {
13
- symbol: string;
14
- balance: string;
15
- locked_balance: string;
16
- };
17
- type AccountAllEvent = {
18
- type: 'subscribed/account_all' | 'update/account_all';
19
- assets: Record<string, RawAsset> | null;
20
- positions: Record<string, RawPosition>;
21
- };
22
- type UserStatsEvent = {
23
- type: 'subscribed/user_stats' | 'update/user_stats';
24
- stats: {
25
- collateral: string;
26
- portfolio_value: string;
27
- available_balance: string;
28
- margin_usage: string;
29
- };
30
- };
31
- type LighterRawTrade = {
32
- trade_id: number;
33
- trade_id_str?: string;
34
- type: 'trade' | 'liquidation' | 'deleverage' | 'market-settlement' | string;
35
- market_id: number;
36
- size: string;
37
- price: string;
38
- usd_amount: string;
39
- ask_client_id_str?: string;
40
- bid_client_id_str?: string;
41
- ask_account_id: number;
42
- bid_account_id: number;
43
- is_maker_ask: boolean;
44
- timestamp: number;
45
- taker_fee?: number;
46
- taker_position_size_before?: string;
47
- maker_fee?: number;
48
- maker_position_size_before?: string;
49
- integrator_taker_fee?: number;
50
- integrator_maker_fee?: number;
51
- };
52
-
53
- export type { AccountAllEvent, LighterRawTrade, RawAsset, RawPosition, UserStatsEvent };
@@ -1,10 +0,0 @@
1
- import { BaseWs, WsMessage } from '../base-ws.js';
2
- import 'partysocket';
3
-
4
- declare class LighterWs extends BaseWs {
5
- protected getWsUrl(): string;
6
- protected getPingIntervalMs(): number;
7
- protected buildPingMessage(): WsMessage;
8
- }
9
-
10
- export { LighterWs };
@@ -1,20 +0,0 @@
1
- import { OkxCredentialsDTO } from '@pear-protocol/types';
2
- import { BaseWs } from '../base-ws.js';
3
- import { ExchangeWs } from '../exchange-ws.js';
4
- import { OkxWs } from './ws.js';
5
- import 'partysocket';
6
-
7
- declare class OkxExchangeWs extends ExchangeWs {
8
- main: OkxWs;
9
- private readonly creds;
10
- readonly exchange: "okx";
11
- constructor(main: OkxWs, creds: OkxCredentialsDTO);
12
- protected connections(): BaseWs[];
13
- login(): Promise<void>;
14
- static create(config: {
15
- demo: boolean;
16
- credentials: OkxCredentialsDTO;
17
- }): Promise<OkxExchangeWs>;
18
- }
19
-
20
- export { OkxExchangeWs };
@@ -1,10 +0,0 @@
1
- import { OkxCredentialsDTO } from '@pear-protocol/types';
2
- import { OkxRawAccountConfig, OkxRawBalance, OkxRawFill, OkxRawLeverageInfo, OkxRawPosition } from './types.js';
3
-
4
- declare function fetchAccountConfig(creds: OkxCredentialsDTO, demo: boolean): Promise<OkxRawAccountConfig>;
5
- declare function fetchBalance(creds: OkxCredentialsDTO, demo: boolean): Promise<OkxRawBalance>;
6
- declare function fetchPositions(creds: OkxCredentialsDTO, demo: boolean): Promise<OkxRawPosition[]>;
7
- declare function fetchLeverageInfo(creds: OkxCredentialsDTO, instId: string, demo: boolean): Promise<OkxRawLeverageInfo | undefined>;
8
- declare function fetchFillsHistorySince(creds: OkxCredentialsDTO, since: Date, demo: boolean): Promise<OkxRawFill[]>;
9
-
10
- export { fetchAccountConfig, fetchBalance, fetchFillsHistorySince, fetchLeverageInfo, fetchPositions };
@@ -1,77 +0,0 @@
1
- interface OkxRawAccountConfig {
2
- acctLv: string;
3
- uid: string;
4
- }
5
- interface OkxRawBalanceDetail {
6
- ccy: string;
7
- eq: string;
8
- availEq: string;
9
- availBal: string;
10
- cashBal: string;
11
- frozenBal: string;
12
- ordFrozen: string;
13
- imr: string;
14
- mmr: string;
15
- upl: string;
16
- eqUsd: string;
17
- }
18
- interface OkxRawBalance {
19
- totalEq: string;
20
- adjEq: string;
21
- availEq: string;
22
- mmr: string;
23
- imr: string;
24
- upl: string;
25
- mgnRatio: string;
26
- details: OkxRawBalanceDetail[];
27
- }
28
- interface OkxRawPosition {
29
- instId: string;
30
- instType: string;
31
- posSide: string;
32
- pos: string;
33
- avgPx: string;
34
- upl: string;
35
- lever: string;
36
- mgnMode: string;
37
- liqPx: string;
38
- ccy: string;
39
- }
40
- interface OkxRawLeverageInfo {
41
- instId: string;
42
- lever: string;
43
- mgnMode: string;
44
- }
45
- interface OkxRawFill {
46
- instType: string;
47
- instId: string;
48
- tradeId: string;
49
- ordId: string;
50
- clOrdId: string;
51
- billId: string;
52
- fillPx: string;
53
- fillSz: string;
54
- side: 'buy' | 'sell';
55
- posSide: string;
56
- execType: string;
57
- fee: string;
58
- feeCcy: string;
59
- fillTime: string;
60
- ts: string;
61
- }
62
- interface OkxWsAccountMessage {
63
- arg: {
64
- channel: 'account';
65
- };
66
- data: OkxRawBalance[];
67
- }
68
- interface OkxWsPositionsMessage {
69
- arg: {
70
- channel: 'positions';
71
- };
72
- action?: 'snapshot' | 'update';
73
- data: OkxRawPosition[];
74
- }
75
- type OkxWsMessage = OkxWsAccountMessage | OkxWsPositionsMessage;
76
-
77
- export type { OkxRawAccountConfig, OkxRawBalance, OkxRawBalanceDetail, OkxRawFill, OkxRawLeverageInfo, OkxRawPosition, OkxWsAccountMessage, OkxWsMessage, OkxWsPositionsMessage };
@@ -1,17 +0,0 @@
1
- import { OkxCredentialsDTO } from '@pear-protocol/types';
2
- import { BaseWs } from '../base-ws.js';
3
- import 'partysocket';
4
-
5
- type OkxWsConfig = {
6
- demo: boolean;
7
- };
8
- declare class OkxWs extends BaseWs {
9
- private readonly demo;
10
- constructor(config: OkxWsConfig);
11
- protected getWsUrl(): string;
12
- protected getPingIntervalMs(): number;
13
- protected buildPingMessage(): string;
14
- login(creds: OkxCredentialsDTO): Promise<void>;
15
- }
16
-
17
- export { OkxWs, type OkxWsConfig };
@@ -1,11 +0,0 @@
1
- import PearSDK from '@pear-protocol/core-sdk';
2
- import { ExchangeHelperExchange, ExchangeHelperMap } from './types.js';
3
- import './lighter/types.js';
4
- import './lighter/ethereum/types.js';
5
- import 'viem';
6
- import '../client/lighter/rest.js';
7
- import '../client/lighter/types.js';
8
-
9
- declare function createExchangeHelper<E extends ExchangeHelperExchange>(exchange: E, sdk: PearSDK): ExchangeHelperMap[E];
10
-
11
- export { createExchangeHelper };
@@ -1,8 +0,0 @@
1
- export { createLighterHelper } from './lighter/helper.js';
2
- export { ASSET_DECIMALS, ApproveIntegratorParams, ApproveIntegratorResult, AssetId, ConnectWalletParams, ConnectWalletResult, DepositParams, LighterHelper, LighterLookupResult, RouteType, WithdrawParams, getAssetDecimals } from './lighter/types.js';
3
- export { ExchangeHelperExchange, ExchangeHelperMap } from './types.js';
4
- export { ApiKey } from '../client/lighter/rest.js';
5
- export { WalletClientWithAccount } from './lighter/ethereum/types.js';
6
- import '@pear-protocol/core-sdk';
7
- import '../client/lighter/types.js';
8
- import 'viem';
@@ -1,66 +0,0 @@
1
- declare const LIGHTER_GATEWAY_ADDRESS: "0x3B4D794a66304F130a4Db8F2551B0070dfCf5ca7";
2
- declare const lighterGatewayAbi: readonly [{
3
- readonly inputs: readonly [{
4
- readonly internalType: "uint48";
5
- readonly name: "_accountIndex";
6
- readonly type: "uint48";
7
- }, {
8
- readonly internalType: "uint8";
9
- readonly name: "_apiKeyIndex";
10
- readonly type: "uint8";
11
- }, {
12
- readonly internalType: "bytes";
13
- readonly name: "_pubKey";
14
- readonly type: "bytes";
15
- }];
16
- readonly name: "changePubKey";
17
- readonly outputs: readonly [];
18
- readonly stateMutability: "nonpayable";
19
- readonly type: "function";
20
- }, {
21
- readonly inputs: readonly [{
22
- readonly internalType: "address";
23
- readonly name: "_to";
24
- readonly type: "address";
25
- }, {
26
- readonly internalType: "uint16";
27
- readonly name: "_assetIndex";
28
- readonly type: "uint16";
29
- }, {
30
- readonly internalType: "uint8";
31
- readonly name: "_routeType";
32
- readonly type: "uint8";
33
- }, {
34
- readonly internalType: "uint256";
35
- readonly name: "_amount";
36
- readonly type: "uint256";
37
- }];
38
- readonly name: "deposit";
39
- readonly outputs: readonly [];
40
- readonly stateMutability: "payable";
41
- readonly type: "function";
42
- }, {
43
- readonly inputs: readonly [{
44
- readonly internalType: "uint48";
45
- readonly name: "_accountIndex";
46
- readonly type: "uint48";
47
- }, {
48
- readonly internalType: "uint16";
49
- readonly name: "_assetIndex";
50
- readonly type: "uint16";
51
- }, {
52
- readonly internalType: "uint8";
53
- readonly name: "_routeType";
54
- readonly type: "uint8";
55
- }, {
56
- readonly internalType: "uint64";
57
- readonly name: "_baseAmount";
58
- readonly type: "uint64";
59
- }];
60
- readonly name: "withdraw";
61
- readonly outputs: readonly [];
62
- readonly stateMutability: "nonpayable";
63
- readonly type: "function";
64
- }];
65
-
66
- export { LIGHTER_GATEWAY_ADDRESS, lighterGatewayAbi };
@@ -1,8 +0,0 @@
1
- import { WalletClientWithAccount, ChangePubKeyParams, DepositParams, WithdrawParams } from './types.js';
2
- import 'viem';
3
-
4
- declare function writeChangePubKey(walletClient: WalletClientWithAccount, params: ChangePubKeyParams): Promise<`0x${string}`>;
5
- declare function writeDeposit(walletClient: WalletClientWithAccount, params: DepositParams): Promise<`0x${string}`>;
6
- declare function writeWithdraw(walletClient: WalletClientWithAccount, params: WithdrawParams): Promise<`0x${string}`>;
7
-
8
- export { ChangePubKeyParams, DepositParams, WalletClientWithAccount, WithdrawParams, writeChangePubKey, writeDeposit, writeWithdraw };