@pear-protocol/core-sdk 0.0.24 → 0.1.0

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,57 @@
1
+ import { HttpTypes } from '@pear-protocol/types';
2
+ import { HttpClient } from '../http.js';
3
+ import { ClientHeaders } from '../types.js';
4
+
5
+ declare class Admin {
6
+ private client;
7
+ constructor(client: HttpClient);
8
+ clientIds: {
9
+ list: (query?: HttpTypes.ListClientIdsParamsInput, headers?: ClientHeaders) => Promise<{
10
+ id: string;
11
+ code: string;
12
+ label: string;
13
+ isActive: boolean;
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ description?: string | undefined;
17
+ }[]>;
18
+ create: (body: HttpTypes.CreateClientIdPayloadInput, headers?: ClientHeaders) => Promise<{
19
+ id: string;
20
+ code: string;
21
+ label: string;
22
+ isActive: boolean;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ description?: string | undefined;
26
+ }>;
27
+ update: (id: string, body: HttpTypes.UpdateClientIdPayloadInput, headers?: ClientHeaders) => Promise<{
28
+ id: string;
29
+ code: string;
30
+ label: string;
31
+ isActive: boolean;
32
+ createdAt: string;
33
+ updatedAt: string;
34
+ description?: string | undefined;
35
+ }>;
36
+ activate: (id: string, headers?: ClientHeaders) => Promise<{
37
+ id: string;
38
+ code: string;
39
+ label: string;
40
+ isActive: boolean;
41
+ createdAt: string;
42
+ updatedAt: string;
43
+ description?: string | undefined;
44
+ }>;
45
+ deactivate: (id: string, headers?: ClientHeaders) => Promise<{
46
+ id: string;
47
+ code: string;
48
+ label: string;
49
+ isActive: boolean;
50
+ createdAt: string;
51
+ updatedAt: string;
52
+ description?: string | undefined;
53
+ }>;
54
+ };
55
+ }
56
+
57
+ export { Admin };
@@ -0,0 +1,43 @@
1
+ class Admin {
2
+ client;
3
+ constructor(client) {
4
+ this.client = client;
5
+ }
6
+ clientIds = {
7
+ list: async (query, headers) => {
8
+ return await this.client.fetch(`/admin/client-ids`, {
9
+ method: "GET",
10
+ headers,
11
+ query
12
+ });
13
+ },
14
+ create: async (body, headers) => {
15
+ return await this.client.fetch(`/admin/client-ids`, {
16
+ method: "POST",
17
+ headers,
18
+ body
19
+ });
20
+ },
21
+ update: async (id, body, headers) => {
22
+ return await this.client.fetch(`/admin/client-ids/${id}`, {
23
+ method: "PATCH",
24
+ headers,
25
+ body
26
+ });
27
+ },
28
+ activate: async (id, headers) => {
29
+ return await this.client.fetch(`/admin/client-ids/${id}/activate`, {
30
+ method: "POST",
31
+ headers
32
+ });
33
+ },
34
+ deactivate: async (id, headers) => {
35
+ return await this.client.fetch(`/admin/client-ids/${id}/deactivate`, {
36
+ method: "POST",
37
+ headers
38
+ });
39
+ }
40
+ };
41
+ }
42
+
43
+ export { Admin };
@@ -12,7 +12,7 @@ declare class Auth {
12
12
  refreshToken: string;
13
13
  user: {
14
14
  id: string;
15
- role: "basic" | "pro";
15
+ role: "basic" | "pro" | "admin";
16
16
  providerId: string | null;
17
17
  loginMethod: "email" | "evm_wallet";
18
18
  };
@@ -26,7 +26,7 @@ declare class Auth {
26
26
  logout(headers?: ClientHeaders): Promise<void>;
27
27
  me(headers?: ClientHeaders): Promise<{
28
28
  id: string;
29
- role: "basic" | "pro";
29
+ role: "basic" | "pro" | "admin";
30
30
  providerId: string | null;
31
31
  loginMethod: "email" | "evm_wallet";
32
32
  }>;
@@ -405,6 +405,57 @@ declare class Core {
405
405
  data: Record<string, string>;
406
406
  }>;
407
407
  };
408
+ markets: {
409
+ list: (query: HttpTypes.MarketsQueryParamsInput, headers?: ClientHeaders) => Promise<{
410
+ markets: {
411
+ connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
412
+ instrumentId: string;
413
+ displaySymbol: string;
414
+ base: string;
415
+ quote: string;
416
+ price: string;
417
+ volume24h: string;
418
+ change24h: string;
419
+ openInterest: string;
420
+ fundingRate: string;
421
+ tradeability: {
422
+ status: "tradable" | "reduce_only" | "not_tradable";
423
+ reason: string | null;
424
+ };
425
+ updatedAt: number;
426
+ }[];
427
+ totals: {
428
+ markets: number;
429
+ volume24h: string;
430
+ openInterest: string;
431
+ };
432
+ }>;
433
+ baskets: (query: HttpTypes.MarketBasketsQueryParamsInput, headers?: ClientHeaders) => Promise<{
434
+ limit: number;
435
+ offset: number;
436
+ count: number;
437
+ markets: {
438
+ connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
439
+ basketKey: string;
440
+ displaySymbol: string;
441
+ longInstrumentIds: string[];
442
+ shortInstrumentIds: string[];
443
+ price: string;
444
+ priceChange24h: string;
445
+ weightRatio: string;
446
+ weightRatioChange24h: string;
447
+ netFunding: string;
448
+ volume24h: string;
449
+ openInterest: string;
450
+ tradeability: {
451
+ status: "tradable" | "reduce_only" | "not_tradable";
452
+ reason: string | null;
453
+ };
454
+ updatedAt: number;
455
+ hasMaterializedStats: boolean;
456
+ }[];
457
+ }>;
458
+ };
408
459
  positions: {
409
460
  list: (query: HttpTypes.PositionListParamsInput, headers?: ClientHeaders) => Promise<{
410
461
  positions: {
@@ -430,6 +481,177 @@ declare class Core {
430
481
  }[];
431
482
  }>;
432
483
  };
484
+ portfolio: {
485
+ overview: (query?: HttpTypes.PortfolioQueryInput, headers?: ClientHeaders) => Promise<{
486
+ intervals: {
487
+ oneDay: {
488
+ periodStart: string;
489
+ periodEnd: string;
490
+ volume: number;
491
+ openInterest: number;
492
+ winningTradesCount: number;
493
+ winningTradesUsd: number;
494
+ losingTradesCount: number;
495
+ losingTradesUsd: number;
496
+ }[];
497
+ oneWeek: {
498
+ periodStart: string;
499
+ periodEnd: string;
500
+ volume: number;
501
+ openInterest: number;
502
+ winningTradesCount: number;
503
+ winningTradesUsd: number;
504
+ losingTradesCount: number;
505
+ losingTradesUsd: number;
506
+ }[];
507
+ oneMonth: {
508
+ periodStart: string;
509
+ periodEnd: string;
510
+ volume: number;
511
+ openInterest: number;
512
+ winningTradesCount: number;
513
+ winningTradesUsd: number;
514
+ losingTradesCount: number;
515
+ losingTradesUsd: number;
516
+ }[];
517
+ oneYear: {
518
+ periodStart: string;
519
+ periodEnd: string;
520
+ volume: number;
521
+ openInterest: number;
522
+ winningTradesCount: number;
523
+ winningTradesUsd: number;
524
+ losingTradesCount: number;
525
+ losingTradesUsd: number;
526
+ }[];
527
+ all: {
528
+ periodStart: string;
529
+ periodEnd: string;
530
+ volume: number;
531
+ openInterest: number;
532
+ winningTradesCount: number;
533
+ winningTradesUsd: number;
534
+ losingTradesCount: number;
535
+ losingTradesUsd: number;
536
+ }[];
537
+ } | null;
538
+ overall: {
539
+ totalWinningTradesCount: number;
540
+ totalLosingTradesCount: number;
541
+ totalWinningUsd: number;
542
+ totalLosingUsd: number;
543
+ currentOpenInterest: number;
544
+ currentTotalVolume: number;
545
+ unrealizedPnl: number;
546
+ realizedPnl: number;
547
+ totalFees: number;
548
+ totalTrades: number;
549
+ };
550
+ }>;
551
+ analytics: (query?: HttpTypes.PortfolioAnalyticsQueryInput, headers?: ClientHeaders) => Promise<{
552
+ config: {
553
+ rollingWindowDays: number;
554
+ startDate: string;
555
+ endDate: string;
556
+ };
557
+ portfolio: {
558
+ realizedOnly: {
559
+ pnlAbsolute: number;
560
+ pnlPercent: number | null;
561
+ hitRate: number | null;
562
+ profitFactor: number | null;
563
+ avgWinSize: number | null;
564
+ avgLossSize: number | null;
565
+ avgReturnPerWin: number | null;
566
+ avgReturnPerLoss: number | null;
567
+ maxDrawdown: number | null;
568
+ sharpeRatio: number | null;
569
+ sortinoRatio: number | null;
570
+ };
571
+ realizedPlusUnrealized: {
572
+ pnlAbsolute: number;
573
+ pnlPercent: number | null;
574
+ hitRate: number | null;
575
+ profitFactor: number | null;
576
+ avgWinSize: number | null;
577
+ avgLossSize: number | null;
578
+ avgReturnPerWin: number | null;
579
+ avgReturnPerLoss: number | null;
580
+ maxDrawdown: number | null;
581
+ sharpeRatio: number | null;
582
+ sortinoRatio: number | null;
583
+ };
584
+ realizedHitRate: number | null;
585
+ profitFactor: number | null;
586
+ avgWinSize: number | null;
587
+ avgLossSize: number | null;
588
+ breakevenHitRate: number | null;
589
+ cushion: number | null;
590
+ };
591
+ assets: {
592
+ asset: string;
593
+ realizedOnly: {
594
+ pnlAbsolute: number;
595
+ pnlPercent: number | null;
596
+ hitRate: number | null;
597
+ profitFactor: number | null;
598
+ avgWinSize: number | null;
599
+ avgLossSize: number | null;
600
+ avgReturnPerWin: number | null;
601
+ avgReturnPerLoss: number | null;
602
+ maxDrawdown: number | null;
603
+ sharpeRatio: number | null;
604
+ sortinoRatio: number | null;
605
+ };
606
+ realizedPlusUnrealized: {
607
+ pnlAbsolute: number;
608
+ pnlPercent: number | null;
609
+ hitRate: number | null;
610
+ profitFactor: number | null;
611
+ avgWinSize: number | null;
612
+ avgLossSize: number | null;
613
+ avgReturnPerWin: number | null;
614
+ avgReturnPerLoss: number | null;
615
+ maxDrawdown: number | null;
616
+ sharpeRatio: number | null;
617
+ sortinoRatio: number | null;
618
+ };
619
+ unrealizedReturnPerDay: number | null;
620
+ }[];
621
+ pairs: {
622
+ key: string;
623
+ longAssets: string[];
624
+ shortAssets: string[];
625
+ trades: number;
626
+ wins: number;
627
+ losses: number;
628
+ hitRate: number | null;
629
+ avgWinSize: number | null;
630
+ avgLossSize: number | null;
631
+ expectancy: number | null;
632
+ totalPnl: number;
633
+ bookPercent: number | null;
634
+ }[];
635
+ series?: {
636
+ date: string;
637
+ trades: number;
638
+ wins: number;
639
+ losses: number;
640
+ dayPnl: number;
641
+ hitRate: number | null;
642
+ winLossRatio: number | null;
643
+ rollingHitRate: number | null;
644
+ rollingWinLossRatio: number | null;
645
+ dailyReturn: number | null;
646
+ cumulativeReturn: number;
647
+ equity: number;
648
+ drawdown: number;
649
+ rollingSharpe: number | null;
650
+ rollingSortino: number | null;
651
+ rollingVolatility: number | null;
652
+ }[] | undefined;
653
+ }>;
654
+ };
433
655
  prices: {
434
656
  list: (query: HttpTypes.PricesQueryParams, headers?: ClientHeaders) => Promise<{
435
657
  mid: Record<string, string>;
@@ -2149,7 +2371,7 @@ declare class Core {
2149
2371
  profile: {
2150
2372
  id: string;
2151
2373
  displayName: string;
2152
- role: "basic" | "pro";
2374
+ role: "basic" | "pro" | "admin";
2153
2375
  address: string | null;
2154
2376
  email: string | null;
2155
2377
  emailVerified: boolean;
@@ -2210,6 +2432,170 @@ declare class Core {
2210
2432
  }[];
2211
2433
  }>;
2212
2434
  };
2435
+ tca: {
2436
+ execution: (executionId: string, headers?: ClientHeaders) => Promise<{
2437
+ fillMetrics: {
2438
+ id: string;
2439
+ fillId: string;
2440
+ tradeAccountId: string;
2441
+ connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
2442
+ symbol: string;
2443
+ status: "FINAL";
2444
+ createdAt: string;
2445
+ updatedAt: string;
2446
+ benchmarkId?: string | undefined;
2447
+ executionId?: string | undefined;
2448
+ positionId?: string | undefined;
2449
+ cloid?: string | undefined;
2450
+ exchangeFillId?: string | undefined;
2451
+ slippageBps?: string | undefined;
2452
+ slippageQuote?: string | undefined;
2453
+ slippageUsd?: string | undefined;
2454
+ implementationShortfallBps?: string | undefined;
2455
+ spreadCostQuote?: string | undefined;
2456
+ spreadCostUsd?: string | undefined;
2457
+ tradeFee?: string | undefined;
2458
+ pearFee?: string | undefined;
2459
+ totalCostUsd?: string | undefined;
2460
+ gatewayLatencyMs?: number | undefined;
2461
+ timeToFillMs?: number | undefined;
2462
+ quoteAsset?: string | undefined;
2463
+ notionalQuote?: string | undefined;
2464
+ notionalUsd?: string | undefined;
2465
+ submittedAt?: string | undefined;
2466
+ acknowledgedAt?: string | undefined;
2467
+ exchangeExecutedAt?: string | undefined;
2468
+ timingGranularity?: "BATCH" | "LEG" | undefined;
2469
+ benchmark?: {
2470
+ id: string;
2471
+ executionId: string;
2472
+ legIndex: number;
2473
+ connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
2474
+ symbol: string;
2475
+ side: "BUY" | "SELL";
2476
+ source: string;
2477
+ timestamp: string;
2478
+ createdAt: string;
2479
+ orderId?: string | undefined;
2480
+ cloid?: string | undefined;
2481
+ decisionPrice?: string | undefined;
2482
+ arrivalMid?: string | undefined;
2483
+ arrivalBid?: string | undefined;
2484
+ arrivalAsk?: string | undefined;
2485
+ markPrice?: string | undefined;
2486
+ indexPrice?: string | undefined;
2487
+ quoteAsset?: string | undefined;
2488
+ usdConversionPrice?: string | undefined;
2489
+ } | undefined;
2490
+ }[];
2491
+ summary?: {
2492
+ id: string;
2493
+ executionId: string;
2494
+ tradeAccountId: string;
2495
+ connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
2496
+ fillCount: number;
2497
+ status: "FINAL";
2498
+ createdAt: string;
2499
+ updatedAt: string;
2500
+ notionalQuote?: string | undefined;
2501
+ notionalUsd?: string | undefined;
2502
+ weightedSlippageBps?: string | undefined;
2503
+ totalSlippageUsd?: string | undefined;
2504
+ totalTradeFee?: string | undefined;
2505
+ totalPearFee?: string | undefined;
2506
+ totalCostUsd?: string | undefined;
2507
+ } | undefined;
2508
+ }>;
2509
+ position: (positionId: string, query?: HttpTypes.TcaPositionQueryParamsInput, headers?: ClientHeaders) => Promise<{
2510
+ limit: number;
2511
+ fillMetrics: {
2512
+ id: string;
2513
+ fillId: string;
2514
+ tradeAccountId: string;
2515
+ connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
2516
+ symbol: string;
2517
+ status: "FINAL";
2518
+ createdAt: string;
2519
+ updatedAt: string;
2520
+ benchmarkId?: string | undefined;
2521
+ executionId?: string | undefined;
2522
+ positionId?: string | undefined;
2523
+ cloid?: string | undefined;
2524
+ exchangeFillId?: string | undefined;
2525
+ slippageBps?: string | undefined;
2526
+ slippageQuote?: string | undefined;
2527
+ slippageUsd?: string | undefined;
2528
+ implementationShortfallBps?: string | undefined;
2529
+ spreadCostQuote?: string | undefined;
2530
+ spreadCostUsd?: string | undefined;
2531
+ tradeFee?: string | undefined;
2532
+ pearFee?: string | undefined;
2533
+ totalCostUsd?: string | undefined;
2534
+ gatewayLatencyMs?: number | undefined;
2535
+ timeToFillMs?: number | undefined;
2536
+ quoteAsset?: string | undefined;
2537
+ notionalQuote?: string | undefined;
2538
+ notionalUsd?: string | undefined;
2539
+ submittedAt?: string | undefined;
2540
+ acknowledgedAt?: string | undefined;
2541
+ exchangeExecutedAt?: string | undefined;
2542
+ timingGranularity?: "BATCH" | "LEG" | undefined;
2543
+ benchmark?: {
2544
+ id: string;
2545
+ executionId: string;
2546
+ legIndex: number;
2547
+ connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
2548
+ symbol: string;
2549
+ side: "BUY" | "SELL";
2550
+ source: string;
2551
+ timestamp: string;
2552
+ createdAt: string;
2553
+ orderId?: string | undefined;
2554
+ cloid?: string | undefined;
2555
+ decisionPrice?: string | undefined;
2556
+ arrivalMid?: string | undefined;
2557
+ arrivalBid?: string | undefined;
2558
+ arrivalAsk?: string | undefined;
2559
+ markPrice?: string | undefined;
2560
+ indexPrice?: string | undefined;
2561
+ quoteAsset?: string | undefined;
2562
+ usdConversionPrice?: string | undefined;
2563
+ } | undefined;
2564
+ }[];
2565
+ nextCursor?: string | undefined;
2566
+ }>;
2567
+ summary: (query?: HttpTypes.TcaSummaryQueryParamsInput, headers?: ClientHeaders) => Promise<{
2568
+ limit: number;
2569
+ summaries: {
2570
+ id: string;
2571
+ executionId: string;
2572
+ tradeAccountId: string;
2573
+ connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
2574
+ fillCount: number;
2575
+ status: "FINAL";
2576
+ createdAt: string;
2577
+ updatedAt: string;
2578
+ notionalQuote?: string | undefined;
2579
+ notionalUsd?: string | undefined;
2580
+ weightedSlippageBps?: string | undefined;
2581
+ totalSlippageUsd?: string | undefined;
2582
+ totalTradeFee?: string | undefined;
2583
+ totalPearFee?: string | undefined;
2584
+ totalCostUsd?: string | undefined;
2585
+ }[];
2586
+ totals: {
2587
+ executionCount: number;
2588
+ fillCount: number;
2589
+ notionalQuote?: string | undefined;
2590
+ notionalUsd?: string | undefined;
2591
+ totalSlippageUsd?: string | undefined;
2592
+ totalTradeFee?: string | undefined;
2593
+ totalPearFee?: string | undefined;
2594
+ totalCostUsd?: string | undefined;
2595
+ };
2596
+ nextCursor?: string | undefined;
2597
+ }>;
2598
+ };
2213
2599
  }
2214
2600
 
2215
2601
  export { Core };
@@ -99,6 +99,22 @@ class Core {
99
99
  });
100
100
  }
101
101
  };
102
+ markets = {
103
+ list: async (query, headers) => {
104
+ return await this.client.fetch(`/markets`, {
105
+ method: "GET",
106
+ headers,
107
+ query
108
+ });
109
+ },
110
+ baskets: async (query, headers) => {
111
+ return await this.client.fetch(`/markets/baskets`, {
112
+ method: "GET",
113
+ headers,
114
+ query
115
+ });
116
+ }
117
+ };
102
118
  positions = {
103
119
  list: async (query, headers) => {
104
120
  return await this.client.fetch(`/positions`, {
@@ -114,6 +130,22 @@ class Core {
114
130
  });
115
131
  }
116
132
  };
133
+ portfolio = {
134
+ overview: async (query, headers) => {
135
+ return await this.client.fetch(`/portfolio`, {
136
+ method: "GET",
137
+ headers,
138
+ query
139
+ });
140
+ },
141
+ analytics: async (query, headers) => {
142
+ return await this.client.fetch(`/portfolio/analytics`, {
143
+ method: "GET",
144
+ headers,
145
+ query
146
+ });
147
+ }
148
+ };
117
149
  prices = {
118
150
  list: async (query, headers) => {
119
151
  return await this.client.fetch(`/prices`, {
@@ -345,6 +377,28 @@ class Core {
345
377
  });
346
378
  }
347
379
  };
380
+ tca = {
381
+ execution: async (executionId, headers) => {
382
+ return await this.client.fetch(`/tca/executions/${executionId}`, {
383
+ method: "GET",
384
+ headers
385
+ });
386
+ },
387
+ position: async (positionId, query, headers) => {
388
+ return await this.client.fetch(`/tca/positions/${positionId}`, {
389
+ method: "GET",
390
+ headers,
391
+ query
392
+ });
393
+ },
394
+ summary: async (query, headers) => {
395
+ return await this.client.fetch(`/tca/summary`, {
396
+ method: "GET",
397
+ headers,
398
+ query
399
+ });
400
+ }
401
+ };
348
402
  }
349
403
 
350
404
  export { Core };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Admin } from './admin/index.js';
1
2
  import { Auth } from './auth/index.js';
2
3
  import { Core } from './core/index.js';
3
4
  import { SDKConfig } from './types.js';
@@ -6,6 +7,7 @@ export * from '@pear-protocol/utils';
6
7
  import './http.js';
7
8
 
8
9
  declare class PearSDK {
10
+ admin: Admin;
9
11
  auth: Auth;
10
12
  core: Core;
11
13
  constructor(config: SDKConfig);
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { Admin } from './admin';
1
2
  import { Auth } from './auth';
2
3
  import { Core } from './core';
3
4
  import { HttpClient } from './http';
@@ -5,6 +6,7 @@ import { FetchError } from './utils';
5
6
  export * from '@pear-protocol/utils';
6
7
 
7
8
  class PearSDK {
9
+ admin;
8
10
  auth;
9
11
  core;
10
12
  constructor(config) {
@@ -17,6 +19,7 @@ class PearSDK {
17
19
  }
18
20
  };
19
21
  const client = new HttpClient(config.url, authMode, config.logger, config.debug);
22
+ this.admin = new Admin(client);
20
23
  this.auth = new Auth(client);
21
24
  this.core = new Core(client);
22
25
  if (authMode === "session") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/core-sdk",
3
- "version": "0.0.24",
3
+ "version": "0.1.0",
4
4
  "description": "Pear Protocol Core SDK",
5
5
  "private": false,
6
6
  "type": "module",
@@ -25,8 +25,8 @@
25
25
  "typecheck": "tsc --noEmit"
26
26
  },
27
27
  "dependencies": {
28
- "@pear-protocol/types": "^0.0.21",
29
- "@pear-protocol/utils": "^0.0.21",
28
+ "@pear-protocol/types": "^0.1.0",
29
+ "@pear-protocol/utils": "^0.0.22",
30
30
  "qs": "^6.14.0"
31
31
  },
32
32
  "devDependencies": {