@pear-protocol/core-sdk 0.0.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.
@@ -0,0 +1,688 @@
1
+ import { HttpTypes } from '@pear-protocol/types';
2
+ import { HttpClient } from '../http.js';
3
+ import { ClientHeaders } from '../types.js';
4
+
5
+ declare class Info {
6
+ private client;
7
+ constructor(client: HttpClient);
8
+ accounts: {
9
+ list: (headers?: ClientHeaders) => Promise<{
10
+ accounts: {
11
+ id: string;
12
+ alias: string;
13
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ metadata?: Record<string, never> | {
17
+ address: string;
18
+ isSubaccount: boolean;
19
+ } | null | undefined;
20
+ }[];
21
+ }>;
22
+ create: (body: HttpTypes.CreateTradeAccount, headers?: ClientHeaders) => Promise<{
23
+ account: {
24
+ id: string;
25
+ alias: string;
26
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ metadata?: Record<string, never> | {
30
+ address: string;
31
+ isSubaccount: boolean;
32
+ } | null | undefined;
33
+ };
34
+ }>;
35
+ update: (id: string, body: HttpTypes.UpdateTradeAccount, headers?: ClientHeaders) => Promise<{
36
+ account: {
37
+ id: string;
38
+ alias: string;
39
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
40
+ createdAt: string;
41
+ updatedAt: string;
42
+ metadata?: Record<string, never> | {
43
+ address: string;
44
+ isSubaccount: boolean;
45
+ } | null | undefined;
46
+ };
47
+ }>;
48
+ delete: (id: string, headers?: ClientHeaders) => Promise<void>;
49
+ credentials: (id: string, headers?: ClientHeaders) => Promise<{
50
+ connector: "hyperliquid";
51
+ credentials: {
52
+ signer_key: string;
53
+ };
54
+ } | {
55
+ connector: "binanceusdm";
56
+ credentials: {
57
+ api_key: string;
58
+ api_secret: string;
59
+ };
60
+ } | {
61
+ connector: "bybit";
62
+ credentials: {
63
+ api_key: string;
64
+ api_secret: string;
65
+ };
66
+ } | {
67
+ connector: "okx";
68
+ credentials: {
69
+ api_key: string;
70
+ api_secret: string;
71
+ api_pass: string;
72
+ };
73
+ }>;
74
+ };
75
+ users: {
76
+ profile: (headers?: ClientHeaders) => Promise<{
77
+ profile: {
78
+ id: string;
79
+ displayName: string;
80
+ role: "basic" | "pro";
81
+ address?: string | undefined;
82
+ email?: string | undefined;
83
+ };
84
+ preferences: {
85
+ slippageToleranceBps: number;
86
+ };
87
+ }>;
88
+ updatePreferences: (body: HttpTypes.UpdateUserPreferences, headers?: ClientHeaders) => Promise<{
89
+ preferences: {
90
+ slippageToleranceBps: number;
91
+ };
92
+ }>;
93
+ };
94
+ schedules: {
95
+ list: (query: HttpTypes.ScheduleListParamsInput, headers?: ClientHeaders) => Promise<{
96
+ limit: number;
97
+ nextCursor: string | undefined;
98
+ schedules: ({
99
+ id: string;
100
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
101
+ status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "FAILED";
102
+ positionKey: string;
103
+ executionType: "MARKET";
104
+ startAt: string;
105
+ endAt: string;
106
+ createdAt: string;
107
+ updatedAt: string;
108
+ strategy: "TWAP";
109
+ intent: "OPEN";
110
+ sliceIntervalMs: number;
111
+ sliceLegs: {
112
+ symbol: string;
113
+ side: "BUY" | "SELL";
114
+ mode: "QUANTITY" | "USD";
115
+ stepAmount: string;
116
+ }[];
117
+ targetNotional: string;
118
+ remainingNotional: string;
119
+ lastSliceAt?: string | undefined;
120
+ cancelledAt?: string | undefined;
121
+ cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | undefined;
122
+ fills?: {
123
+ id: string;
124
+ tradeAccountId: string;
125
+ symbol: string;
126
+ positionId: string;
127
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
128
+ side: "BUY" | "SELL";
129
+ reduceOnly: boolean;
130
+ quantity: string;
131
+ price: string;
132
+ usd: string;
133
+ timestamp: string;
134
+ cloid?: string | undefined;
135
+ fee?: string | undefined;
136
+ }[] | undefined;
137
+ } | {
138
+ id: string;
139
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
140
+ status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "FAILED";
141
+ positionKey: string;
142
+ executionType: "MARKET";
143
+ startAt: string;
144
+ endAt: string;
145
+ createdAt: string;
146
+ updatedAt: string;
147
+ strategy: "TWAP";
148
+ intent: "CLOSE";
149
+ sliceIntervalMs: number;
150
+ positionId: string;
151
+ sliceLegs: {
152
+ symbol: string;
153
+ stepAmount: string;
154
+ }[];
155
+ initialExposure: Record<string, string>;
156
+ lastSliceAt?: string | undefined;
157
+ cancelledAt?: string | undefined;
158
+ cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | undefined;
159
+ fills?: {
160
+ id: string;
161
+ tradeAccountId: string;
162
+ symbol: string;
163
+ positionId: string;
164
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
165
+ side: "BUY" | "SELL";
166
+ reduceOnly: boolean;
167
+ quantity: string;
168
+ price: string;
169
+ usd: string;
170
+ timestamp: string;
171
+ cloid?: string | undefined;
172
+ fee?: string | undefined;
173
+ }[] | undefined;
174
+ })[];
175
+ }>;
176
+ };
177
+ triggers: {
178
+ list: (query: HttpTypes.TriggerListParamsInput, headers?: ClientHeaders) => Promise<{
179
+ limit: number;
180
+ nextCursor: string | undefined;
181
+ triggers: ({
182
+ id: string;
183
+ tradeAccountId: string;
184
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
185
+ status: "CANCELLED" | "ACTIVE" | "TRIGGERED";
186
+ createdAt: string;
187
+ updatedAt: string;
188
+ intent: "OPEN";
189
+ type: "MARKET";
190
+ condition: {
191
+ type: "ratio_v1";
192
+ data: {
193
+ priceSource: "mid" | "mark";
194
+ symbol_a: string;
195
+ symbol_b: string;
196
+ direction: "ABOVE" | "BELOW";
197
+ threshold: number;
198
+ };
199
+ } | {
200
+ type: "price_v1";
201
+ data: {
202
+ priceSource: "mid" | "mark";
203
+ symbol: string;
204
+ direction: "ABOVE" | "BELOW";
205
+ threshold: number;
206
+ };
207
+ } | {
208
+ type: "index_v1";
209
+ data: {
210
+ priceSource: "mid" | "mark";
211
+ basket: {
212
+ symbol: string;
213
+ weight: number;
214
+ }[];
215
+ direction: "ABOVE" | "BELOW";
216
+ threshold: number;
217
+ };
218
+ } | {
219
+ type: "weighted_ratio_v1";
220
+ data: {
221
+ priceSource: "mid" | "mark";
222
+ basket: {
223
+ symbol: string;
224
+ side: "BUY" | "SELL";
225
+ weight: number;
226
+ }[];
227
+ direction: "ABOVE" | "BELOW";
228
+ threshold: number;
229
+ };
230
+ };
231
+ context: {
232
+ type: "MARKET";
233
+ legs: [{
234
+ symbol: string;
235
+ side: "BUY" | "SELL";
236
+ mode: "QUANTITY" | "USD";
237
+ amount: string;
238
+ }, ...{
239
+ symbol: string;
240
+ side: "BUY" | "SELL";
241
+ mode: "QUANTITY" | "USD";
242
+ amount: string;
243
+ }[]];
244
+ };
245
+ triggeredAt?: string | undefined;
246
+ cancelledAt?: string | undefined;
247
+ cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | undefined;
248
+ fills?: {
249
+ id: string;
250
+ tradeAccountId: string;
251
+ symbol: string;
252
+ positionId: string;
253
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
254
+ side: "BUY" | "SELL";
255
+ reduceOnly: boolean;
256
+ quantity: string;
257
+ price: string;
258
+ usd: string;
259
+ timestamp: string;
260
+ cloid?: string | undefined;
261
+ fee?: string | undefined;
262
+ }[] | undefined;
263
+ } | {
264
+ id: string;
265
+ tradeAccountId: string;
266
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
267
+ status: "CANCELLED" | "ACTIVE" | "TRIGGERED";
268
+ createdAt: string;
269
+ updatedAt: string;
270
+ intent: "ADJUST";
271
+ type: "MARKET";
272
+ condition: {
273
+ type: "ratio_v1";
274
+ data: {
275
+ priceSource: "mid" | "mark";
276
+ symbol_a: string;
277
+ symbol_b: string;
278
+ direction: "ABOVE" | "BELOW";
279
+ threshold: number;
280
+ };
281
+ } | {
282
+ type: "price_v1";
283
+ data: {
284
+ priceSource: "mid" | "mark";
285
+ symbol: string;
286
+ direction: "ABOVE" | "BELOW";
287
+ threshold: number;
288
+ };
289
+ } | {
290
+ type: "index_v1";
291
+ data: {
292
+ priceSource: "mid" | "mark";
293
+ basket: {
294
+ symbol: string;
295
+ weight: number;
296
+ }[];
297
+ direction: "ABOVE" | "BELOW";
298
+ threshold: number;
299
+ };
300
+ } | {
301
+ type: "weighted_ratio_v1";
302
+ data: {
303
+ priceSource: "mid" | "mark";
304
+ basket: {
305
+ symbol: string;
306
+ side: "BUY" | "SELL";
307
+ weight: number;
308
+ }[];
309
+ direction: "ABOVE" | "BELOW";
310
+ threshold: number;
311
+ };
312
+ } | {
313
+ type: "position_value_v1";
314
+ data: {
315
+ priceSource: "mid" | "mark";
316
+ direction: "ABOVE" | "BELOW";
317
+ threshold: number;
318
+ };
319
+ } | {
320
+ type: "position_upnl_value_v1";
321
+ data: {
322
+ priceSource: "mid" | "mark";
323
+ direction: "ABOVE" | "BELOW";
324
+ threshold: number;
325
+ };
326
+ } | {
327
+ type: "position_upnl_percentage_v1";
328
+ data: {
329
+ priceSource: "mid" | "mark";
330
+ direction: "ABOVE" | "BELOW";
331
+ threshold_bps: number;
332
+ };
333
+ };
334
+ context: {
335
+ type: "MARKET";
336
+ position: {
337
+ id: string;
338
+ initialExposure: Record<string, string>;
339
+ };
340
+ legs: [{
341
+ symbol: string;
342
+ side: "BUY" | "SELL";
343
+ mode: "QUANTITY" | "USD";
344
+ amount: string;
345
+ reduceOnly: boolean;
346
+ }, ...{
347
+ symbol: string;
348
+ side: "BUY" | "SELL";
349
+ mode: "QUANTITY" | "USD";
350
+ amount: string;
351
+ reduceOnly: boolean;
352
+ }[]];
353
+ };
354
+ triggeredAt?: string | undefined;
355
+ cancelledAt?: string | undefined;
356
+ cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | undefined;
357
+ fills?: {
358
+ id: string;
359
+ tradeAccountId: string;
360
+ symbol: string;
361
+ positionId: string;
362
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
363
+ side: "BUY" | "SELL";
364
+ reduceOnly: boolean;
365
+ quantity: string;
366
+ price: string;
367
+ usd: string;
368
+ timestamp: string;
369
+ cloid?: string | undefined;
370
+ fee?: string | undefined;
371
+ }[] | undefined;
372
+ } | {
373
+ id: string;
374
+ tradeAccountId: string;
375
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
376
+ status: "CANCELLED" | "ACTIVE" | "TRIGGERED";
377
+ createdAt: string;
378
+ updatedAt: string;
379
+ intent: "CLOSE";
380
+ type: "MARKET";
381
+ condition: {
382
+ type: "ratio_v1";
383
+ data: {
384
+ priceSource: "mid" | "mark";
385
+ symbol_a: string;
386
+ symbol_b: string;
387
+ direction: "ABOVE" | "BELOW";
388
+ threshold: number;
389
+ };
390
+ } | {
391
+ type: "price_v1";
392
+ data: {
393
+ priceSource: "mid" | "mark";
394
+ symbol: string;
395
+ direction: "ABOVE" | "BELOW";
396
+ threshold: number;
397
+ };
398
+ } | {
399
+ type: "index_v1";
400
+ data: {
401
+ priceSource: "mid" | "mark";
402
+ basket: {
403
+ symbol: string;
404
+ weight: number;
405
+ }[];
406
+ direction: "ABOVE" | "BELOW";
407
+ threshold: number;
408
+ };
409
+ } | {
410
+ type: "weighted_ratio_v1";
411
+ data: {
412
+ priceSource: "mid" | "mark";
413
+ basket: {
414
+ symbol: string;
415
+ side: "BUY" | "SELL";
416
+ weight: number;
417
+ }[];
418
+ direction: "ABOVE" | "BELOW";
419
+ threshold: number;
420
+ };
421
+ } | {
422
+ type: "position_value_v1";
423
+ data: {
424
+ priceSource: "mid" | "mark";
425
+ direction: "ABOVE" | "BELOW";
426
+ threshold: number;
427
+ };
428
+ } | {
429
+ type: "position_upnl_value_v1";
430
+ data: {
431
+ priceSource: "mid" | "mark";
432
+ direction: "ABOVE" | "BELOW";
433
+ threshold: number;
434
+ };
435
+ } | {
436
+ type: "position_upnl_percentage_v1";
437
+ data: {
438
+ priceSource: "mid" | "mark";
439
+ direction: "ABOVE" | "BELOW";
440
+ threshold_bps: number;
441
+ };
442
+ };
443
+ context: {
444
+ type: "MARKET";
445
+ position: {
446
+ id: string;
447
+ initialExposure: Record<string, string>;
448
+ };
449
+ };
450
+ triggeredAt?: string | undefined;
451
+ cancelledAt?: string | undefined;
452
+ cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | undefined;
453
+ fills?: {
454
+ id: string;
455
+ tradeAccountId: string;
456
+ symbol: string;
457
+ positionId: string;
458
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
459
+ side: "BUY" | "SELL";
460
+ reduceOnly: boolean;
461
+ quantity: string;
462
+ price: string;
463
+ usd: string;
464
+ timestamp: string;
465
+ cloid?: string | undefined;
466
+ fee?: string | undefined;
467
+ }[] | undefined;
468
+ })[];
469
+ }>;
470
+ };
471
+ positions: {
472
+ list: (query: HttpTypes.PositionListParamsInput, headers?: ClientHeaders) => Promise<{
473
+ positions: {
474
+ id: string;
475
+ tradeAccountId: string;
476
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
477
+ status: "OPEN" | "CLOSED";
478
+ exposure: Record<string, string>;
479
+ initialExposureUSD: Record<string, string>;
480
+ createdAt: string;
481
+ updatedAt: string;
482
+ closedReason?: "USER" | "NETTED" | "LIQUIDATED" | null | undefined;
483
+ closedAt?: string | null | undefined;
484
+ }[];
485
+ }>;
486
+ };
487
+ fills: {
488
+ details: (positionId: string, headers?: ClientHeaders) => Promise<{
489
+ fills: {
490
+ id: string;
491
+ tradeAccountId: string;
492
+ symbol: string;
493
+ positionId: string;
494
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
495
+ side: "BUY" | "SELL";
496
+ reduceOnly: boolean;
497
+ quantity: string;
498
+ price: string;
499
+ usd: string;
500
+ timestamp: string;
501
+ cloid?: string | undefined;
502
+ fee?: string | undefined;
503
+ }[];
504
+ }>;
505
+ list: (query: HttpTypes.FillListParams, headers?: ClientHeaders) => Promise<{
506
+ limit: number;
507
+ nextCursor: string | undefined;
508
+ fills: {
509
+ id: string;
510
+ tradeAccountId: string;
511
+ symbol: string;
512
+ positionId: string;
513
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
514
+ side: "BUY" | "SELL";
515
+ reduceOnly: boolean;
516
+ quantity: string;
517
+ price: string;
518
+ usd: string;
519
+ timestamp: string;
520
+ cloid?: string | undefined;
521
+ fee?: string | undefined;
522
+ }[];
523
+ }>;
524
+ };
525
+ executions: {
526
+ list: (query: HttpTypes.ExecutionListParamsInput, headers?: ClientHeaders) => Promise<{
527
+ limit: number;
528
+ nextCursor: string | undefined;
529
+ executions: ({
530
+ id: string;
531
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
532
+ status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "FAILED" | "IDLE";
533
+ createdAt: string;
534
+ updatedAt: string;
535
+ intent: "OPEN";
536
+ orderType: "MARKET";
537
+ legs: [{
538
+ symbol: string;
539
+ side: "BUY" | "SELL";
540
+ mode: "QUANTITY" | "USD";
541
+ amount: string;
542
+ reduceOnly: boolean;
543
+ }, ...{
544
+ symbol: string;
545
+ side: "BUY" | "SELL";
546
+ mode: "QUANTITY" | "USD";
547
+ amount: string;
548
+ reduceOnly: boolean;
549
+ }[]];
550
+ error?: string | undefined;
551
+ orders?: {
552
+ id: string;
553
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
554
+ status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
555
+ createdAt: string;
556
+ updatedAt: string;
557
+ type: "MARKET";
558
+ symbol: string;
559
+ side: "BUY" | "SELL";
560
+ reduceOnly: boolean;
561
+ leverage: number;
562
+ quantity: string;
563
+ price: string;
564
+ filledQuantity: string;
565
+ error?: string | undefined;
566
+ filledPrice?: string | undefined;
567
+ }[] | undefined;
568
+ } | {
569
+ id: string;
570
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
571
+ status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "FAILED" | "IDLE";
572
+ createdAt: string;
573
+ updatedAt: string;
574
+ intent: "ADJUST";
575
+ orderType: "MARKET";
576
+ position: {
577
+ id: string;
578
+ exposure: Record<string, string>;
579
+ };
580
+ legs: [{
581
+ symbol: string;
582
+ side: "BUY" | "SELL";
583
+ mode: "QUANTITY" | "USD";
584
+ amount: string;
585
+ reduceOnly: boolean;
586
+ }, ...{
587
+ symbol: string;
588
+ side: "BUY" | "SELL";
589
+ mode: "QUANTITY" | "USD";
590
+ amount: string;
591
+ reduceOnly: boolean;
592
+ }[]];
593
+ error?: string | undefined;
594
+ orders?: {
595
+ id: string;
596
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
597
+ status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
598
+ createdAt: string;
599
+ updatedAt: string;
600
+ type: "MARKET";
601
+ symbol: string;
602
+ side: "BUY" | "SELL";
603
+ reduceOnly: boolean;
604
+ leverage: number;
605
+ quantity: string;
606
+ price: string;
607
+ filledQuantity: string;
608
+ error?: string | undefined;
609
+ filledPrice?: string | undefined;
610
+ }[] | undefined;
611
+ } | {
612
+ id: string;
613
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
614
+ status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "FAILED" | "IDLE";
615
+ createdAt: string;
616
+ updatedAt: string;
617
+ intent: "CLOSE";
618
+ orderType: "MARKET";
619
+ position: {
620
+ id: string;
621
+ exposure: Record<string, string>;
622
+ };
623
+ error?: string | undefined;
624
+ orders?: {
625
+ id: string;
626
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
627
+ status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
628
+ createdAt: string;
629
+ updatedAt: string;
630
+ type: "MARKET";
631
+ symbol: string;
632
+ side: "BUY" | "SELL";
633
+ reduceOnly: boolean;
634
+ leverage: number;
635
+ quantity: string;
636
+ price: string;
637
+ filledQuantity: string;
638
+ error?: string | undefined;
639
+ filledPrice?: string | undefined;
640
+ }[] | undefined;
641
+ })[];
642
+ }>;
643
+ };
644
+ instruments: {
645
+ list: (query: HttpTypes.InstrumentListParams, headers?: ClientHeaders) => Promise<{
646
+ instruments: {
647
+ id: string;
648
+ base: string;
649
+ quote: string;
650
+ connector: "hyperliquid" | "binanceusdm" | "bybit" | "okx";
651
+ type: "spot" | "perp" | "hip3";
652
+ leverage: number;
653
+ precision: {
654
+ quantity: {
655
+ decimals: number;
656
+ step: number;
657
+ contractSize: number;
658
+ };
659
+ price: {
660
+ decimals: number;
661
+ tick?: number | null | undefined;
662
+ sigFigs?: number | null | undefined;
663
+ };
664
+ notional?: {
665
+ min?: number | null | undefined;
666
+ max?: number | null | undefined;
667
+ } | undefined;
668
+ };
669
+ }[];
670
+ }>;
671
+ };
672
+ prices: {
673
+ list: (query: HttpTypes.PricesQueryParams, headers?: ClientHeaders) => Promise<{
674
+ mid: Record<string, string>;
675
+ mark: Record<string, string>;
676
+ }>;
677
+ };
678
+ funding: {
679
+ list: (query: HttpTypes.FundingQueryParams, headers?: ClientHeaders) => Promise<{
680
+ funding: Record<string, {
681
+ r: string;
682
+ nft: number;
683
+ }>;
684
+ }>;
685
+ };
686
+ }
687
+
688
+ export { Info };