@pear-protocol/core-sdk 2.11.0 → 2.13.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.
@@ -2379,7 +2379,7 @@ declare class Core {
2379
2379
  get: (query?: HttpTypes.QuoteFeeParamsInput, headers?: ClientHeaders) => Promise<{
2380
2380
  baseBps: string;
2381
2381
  discounts: {
2382
- scope: "user" | "connector" | "all" | "client_id";
2382
+ scope: "connector" | "all" | "user" | "client_id";
2383
2383
  rate: string;
2384
2384
  }[];
2385
2385
  finalBps: string;
@@ -5362,6 +5362,7 @@ declare class Core {
5362
5362
  decimals: number;
5363
5363
  step: number;
5364
5364
  contractSize: number;
5365
+ min?: number | null | undefined;
5365
5366
  };
5366
5367
  price: {
5367
5368
  decimals: number;
@@ -6399,6 +6400,11 @@ declare class Core {
6399
6400
  endAt: string;
6400
6401
  createdAt: string;
6401
6402
  updatedAt: string;
6403
+ executedSliceCount: number;
6404
+ filledUsd: string;
6405
+ filledQuantities: Record<string, string>;
6406
+ progress: number;
6407
+ legProgress: Record<string, number>;
6402
6408
  strategy: "TWAP";
6403
6409
  intent: "OPEN";
6404
6410
  sliceIntervalSec: number;
@@ -6418,30 +6424,6 @@ declare class Core {
6418
6424
  lastSliceAt?: string | undefined;
6419
6425
  cancelledAt?: string | undefined;
6420
6426
  cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | "POSITION_NETTED" | "POSITION_LIQUIDATED" | "POSITION_REVERSED" | undefined;
6421
- fills?: {
6422
- id: string;
6423
- status: "PROVISIONAL" | "CONFIRMED" | "RECONCILED";
6424
- tradeAccountId: string;
6425
- symbol: string;
6426
- positionId: string;
6427
- connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
6428
- side: "BUY" | "SELL";
6429
- reduceOnly: boolean;
6430
- isExternal: boolean;
6431
- synthetic: boolean;
6432
- quantity: string;
6433
- price: string;
6434
- usd: string;
6435
- timestamp: string;
6436
- cloid?: string | undefined;
6437
- exchangeFillId?: string | undefined;
6438
- tradeFee?: string | undefined;
6439
- pearFee?: string | undefined;
6440
- original?: {
6441
- exchangeFillId: string;
6442
- quantity: string;
6443
- } | undefined;
6444
- }[] | undefined;
6445
6427
  } | {
6446
6428
  id: string;
6447
6429
  connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
@@ -6452,6 +6434,11 @@ declare class Core {
6452
6434
  endAt: string;
6453
6435
  createdAt: string;
6454
6436
  updatedAt: string;
6437
+ executedSliceCount: number;
6438
+ filledUsd: string;
6439
+ filledQuantities: Record<string, string>;
6440
+ progress: number;
6441
+ legProgress: Record<string, number>;
6455
6442
  strategy: "TWAP";
6456
6443
  intent: "CLOSE";
6457
6444
  sliceIntervalSec: number;
@@ -6465,30 +6452,6 @@ declare class Core {
6465
6452
  lastSliceAt?: string | undefined;
6466
6453
  cancelledAt?: string | undefined;
6467
6454
  cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | "POSITION_NETTED" | "POSITION_LIQUIDATED" | "POSITION_REVERSED" | undefined;
6468
- fills?: {
6469
- id: string;
6470
- status: "PROVISIONAL" | "CONFIRMED" | "RECONCILED";
6471
- tradeAccountId: string;
6472
- symbol: string;
6473
- positionId: string;
6474
- connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
6475
- side: "BUY" | "SELL";
6476
- reduceOnly: boolean;
6477
- isExternal: boolean;
6478
- synthetic: boolean;
6479
- quantity: string;
6480
- price: string;
6481
- usd: string;
6482
- timestamp: string;
6483
- cloid?: string | undefined;
6484
- exchangeFillId?: string | undefined;
6485
- tradeFee?: string | undefined;
6486
- pearFee?: string | undefined;
6487
- original?: {
6488
- exchangeFillId: string;
6489
- quantity: string;
6490
- } | undefined;
6491
- }[] | undefined;
6492
6455
  })[];
6493
6456
  nextCursor?: string | undefined;
6494
6457
  }>;
@@ -6503,6 +6466,11 @@ declare class Core {
6503
6466
  endAt: string;
6504
6467
  createdAt: string;
6505
6468
  updatedAt: string;
6469
+ executedSliceCount: number;
6470
+ filledUsd: string;
6471
+ filledQuantities: Record<string, string>;
6472
+ progress: number;
6473
+ legProgress: Record<string, number>;
6506
6474
  strategy: "TWAP";
6507
6475
  intent: "OPEN";
6508
6476
  sliceIntervalSec: number;
@@ -6522,30 +6490,72 @@ declare class Core {
6522
6490
  lastSliceAt?: string | undefined;
6523
6491
  cancelledAt?: string | undefined;
6524
6492
  cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | "POSITION_NETTED" | "POSITION_LIQUIDATED" | "POSITION_REVERSED" | undefined;
6525
- fills?: {
6526
- id: string;
6527
- status: "PROVISIONAL" | "CONFIRMED" | "RECONCILED";
6528
- tradeAccountId: string;
6493
+ } | {
6494
+ id: string;
6495
+ connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
6496
+ status: "ACTIVE" | "CANCELLED" | "COMPLETED" | "FAILED";
6497
+ positionKey: string;
6498
+ executionType: "MARKET";
6499
+ startAt: string;
6500
+ endAt: string;
6501
+ createdAt: string;
6502
+ updatedAt: string;
6503
+ executedSliceCount: number;
6504
+ filledUsd: string;
6505
+ filledQuantities: Record<string, string>;
6506
+ progress: number;
6507
+ legProgress: Record<string, number>;
6508
+ strategy: "TWAP";
6509
+ intent: "CLOSE";
6510
+ sliceIntervalSec: number;
6511
+ sliceCount: number;
6512
+ randomization: {
6513
+ timingJitterBps: number;
6514
+ sizeJitterBps: number;
6515
+ };
6516
+ positionId: string;
6517
+ initialExposure: Record<string, `-${string}` | `+${string}`>;
6518
+ lastSliceAt?: string | undefined;
6519
+ cancelledAt?: string | undefined;
6520
+ cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | "POSITION_NETTED" | "POSITION_LIQUIDATED" | "POSITION_REVERSED" | undefined;
6521
+ };
6522
+ }>;
6523
+ get: (scheduleId: string, query: HttpTypes.ScheduleDetailParamsInput, headers?: ClientHeaders) => Promise<{
6524
+ limit: number;
6525
+ schedule: {
6526
+ id: string;
6527
+ connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
6528
+ status: "ACTIVE" | "CANCELLED" | "COMPLETED" | "FAILED";
6529
+ positionKey: string;
6530
+ executionType: "MARKET";
6531
+ startAt: string;
6532
+ endAt: string;
6533
+ createdAt: string;
6534
+ updatedAt: string;
6535
+ executedSliceCount: number;
6536
+ filledUsd: string;
6537
+ filledQuantities: Record<string, string>;
6538
+ progress: number;
6539
+ legProgress: Record<string, number>;
6540
+ strategy: "TWAP";
6541
+ intent: "OPEN";
6542
+ sliceIntervalSec: number;
6543
+ sliceCount: number;
6544
+ randomization: {
6545
+ timingJitterBps: number;
6546
+ sizeJitterBps: number;
6547
+ };
6548
+ legs: {
6529
6549
  symbol: string;
6530
- positionId: string;
6531
- connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
6532
6550
  side: "BUY" | "SELL";
6533
- reduceOnly: boolean;
6534
- isExternal: boolean;
6535
- synthetic: boolean;
6536
- quantity: string;
6537
- price: string;
6538
- usd: string;
6539
- timestamp: string;
6540
- cloid?: string | undefined;
6541
- exchangeFillId?: string | undefined;
6542
- tradeFee?: string | undefined;
6543
- pearFee?: string | undefined;
6544
- original?: {
6545
- exchangeFillId: string;
6546
- quantity: string;
6547
- } | undefined;
6548
- }[] | undefined;
6551
+ weight: number;
6552
+ id?: string | undefined;
6553
+ }[];
6554
+ targetNotional: string;
6555
+ remainingNotional: string;
6556
+ lastSliceAt?: string | undefined;
6557
+ cancelledAt?: string | undefined;
6558
+ cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | "POSITION_NETTED" | "POSITION_LIQUIDATED" | "POSITION_REVERSED" | undefined;
6549
6559
  } | {
6550
6560
  id: string;
6551
6561
  connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
@@ -6556,6 +6566,11 @@ declare class Core {
6556
6566
  endAt: string;
6557
6567
  createdAt: string;
6558
6568
  updatedAt: string;
6569
+ executedSliceCount: number;
6570
+ filledUsd: string;
6571
+ filledQuantities: Record<string, string>;
6572
+ progress: number;
6573
+ legProgress: Record<string, number>;
6559
6574
  strategy: "TWAP";
6560
6575
  intent: "CLOSE";
6561
6576
  sliceIntervalSec: number;
@@ -6569,6 +6584,14 @@ declare class Core {
6569
6584
  lastSliceAt?: string | undefined;
6570
6585
  cancelledAt?: string | undefined;
6571
6586
  cancelledReason?: "USER" | "POSITION_CLOSED" | "SYSTEM" | "POSITION_NETTED" | "POSITION_LIQUIDATED" | "POSITION_REVERSED" | undefined;
6587
+ };
6588
+ slices: ({
6589
+ index: number;
6590
+ scheduledAt: string;
6591
+ status: "EXECUTED";
6592
+ usd: string;
6593
+ quantities: Record<string, string>;
6594
+ lastFilledAt: string;
6572
6595
  fills?: {
6573
6596
  id: string;
6574
6597
  status: "PROVISIONAL" | "CONFIRMED" | "RECONCILED";
@@ -6593,7 +6616,16 @@ declare class Core {
6593
6616
  quantity: string;
6594
6617
  } | undefined;
6595
6618
  }[] | undefined;
6596
- };
6619
+ } | {
6620
+ index: number;
6621
+ scheduledAt: string;
6622
+ status: "PENDING";
6623
+ } | {
6624
+ index: number;
6625
+ scheduledAt: string;
6626
+ status: "MISSED";
6627
+ })[];
6628
+ nextCursor?: string | undefined;
6597
6629
  }>;
6598
6630
  cancel: (scheduleId: string, headers?: ClientHeaders) => Promise<{
6599
6631
  id: string;
@@ -520,6 +520,13 @@ class Core {
520
520
  body: this.withClientId(body)
521
521
  });
522
522
  }, "create"),
523
+ get: /* @__PURE__ */ __name(async (scheduleId, query, headers) => {
524
+ return await this.client.fetch(`/schedules/${scheduleId}`, {
525
+ method: "GET",
526
+ headers,
527
+ query
528
+ });
529
+ }, "get"),
523
530
  cancel: /* @__PURE__ */ __name(async (scheduleId, headers) => {
524
531
  return await this.client.fetch(`/schedules/${scheduleId}/cancel`, {
525
532
  method: "PATCH",
package/dist/utils.d.ts CHANGED
@@ -9,7 +9,8 @@ declare class FetchError extends Error {
9
9
  status: number | undefined;
10
10
  statusText: string | undefined;
11
11
  errorCode: string | undefined;
12
- constructor(message: string, statusText?: string, status?: number, errorCode?: string);
12
+ details: unknown;
13
+ constructor(message: string, statusText?: string, status?: number, errorCode?: string, details?: unknown);
13
14
  }
14
15
  declare function gzipJson(value: unknown): Promise<Blob>;
15
16
 
package/dist/utils.js CHANGED
@@ -35,7 +35,7 @@ async function normalizeResponseData(resp, reqHeaders) {
35
35
  }
36
36
  if (resp.status >= 300) {
37
37
  const jsonError = await resp.json().catch(() => ({}));
38
- throw new FetchError(jsonError.message ?? resp.statusText, resp.statusText, resp.status, jsonError.errorCode);
38
+ throw new FetchError(jsonError.message ?? resp.statusText, resp.statusText, resp.status, jsonError.errorCode, jsonError.details);
39
39
  }
40
40
  if (resp.status === 204 || resp.status === 205) {
41
41
  return null;
@@ -59,11 +59,14 @@ class FetchError extends Error {
59
59
  statusText;
60
60
  // Machine-readable contract code from the server's error envelope (e.g. SYNC_CREATE_FILLS_TOO_RECENT).
61
61
  errorCode;
62
- constructor(message, statusText, status, errorCode) {
62
+ // Structured context from the server's error envelope; shape varies by failure, so narrow before use.
63
+ details;
64
+ constructor(message, statusText, status, errorCode, details) {
63
65
  super(message);
64
66
  this.statusText = statusText;
65
67
  this.status = status;
66
68
  this.errorCode = errorCode;
69
+ this.details = details;
67
70
  }
68
71
  }
69
72
  async function gzipJson(value) {
@@ -144,6 +144,7 @@ declare class Vaults {
144
144
  depositAmount: string;
145
145
  shares: string;
146
146
  currentValue: string;
147
+ unrealizedPnl: number;
147
148
  }[];
148
149
  tradedVolume?: number | undefined;
149
150
  userStats?: {
@@ -299,15 +300,6 @@ declare class Vaults {
299
300
  };
300
301
  }>;
301
302
  agent: {
302
- /** GET /vaults/:vaultAddress/balances — fetch agent balances for a vault. */
303
- balances: (vaultAddress: string, headers?: ClientHeaders) => Promise<{
304
- agentAddress: string;
305
- spot: Record<string, string>;
306
- perp: {
307
- accountValue: string;
308
- withdrawable: string;
309
- };
310
- }>;
311
303
  /** POST /vaults/:vaultAddress/agent/approve — approve an agent action for a vault. */
312
304
  approve: (vaultAddress: string, body: HttpTypes.AgentApproveInput, headers?: ClientHeaders) => Promise<{
313
305
  result: {
@@ -121,13 +121,6 @@ class Vaults {
121
121
  });
122
122
  }, "withdrawToEvm");
123
123
  agent = {
124
- /** GET /vaults/:vaultAddress/balances — fetch agent balances for a vault. */
125
- balances: /* @__PURE__ */ __name(async (vaultAddress, headers) => {
126
- return await this.client.fetch(`/vaults/${vaultAddress}/balances`, {
127
- method: "GET",
128
- headers
129
- });
130
- }, "balances"),
131
124
  /** POST /vaults/:vaultAddress/agent/approve — approve an agent action for a vault. */
132
125
  approve: /* @__PURE__ */ __name(async (vaultAddress, body, headers) => {
133
126
  return await this.client.fetch(`/vaults/${vaultAddress}/agent/approve`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/core-sdk",
3
- "version": "2.11.0",
3
+ "version": "2.13.0",
4
4
  "description": "Pear Protocol Core SDK",
5
5
  "private": false,
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "typecheck": "tsc --noEmit"
27
27
  },
28
28
  "dependencies": {
29
- "@pear-protocol/types": "^2.18.0",
30
- "@pear-protocol/utils": "^1.3.0",
29
+ "@pear-protocol/types": "^2.20.0",
30
+ "@pear-protocol/utils": "^1.4.0",
31
31
  "qs": "^6.14.0"
32
32
  },
33
33
  "devDependencies": {