@pear-protocol/core-sdk 2.17.0 → 2.19.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.
@@ -1,5 +1,3 @@
1
- import { gzipJson } from '../utils';
2
-
3
1
  var __defProp = Object.defineProperty;
4
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
3
  class Core {
@@ -202,7 +200,19 @@ class Core {
202
200
  method: "GET",
203
201
  headers
204
202
  });
205
- }, "get")
203
+ }, "get"),
204
+ cancel: /* @__PURE__ */ __name(async (id, headers) => {
205
+ return await this.client.fetch(`/executions/${id}/cancel`, {
206
+ method: "POST",
207
+ headers
208
+ });
209
+ }, "cancel"),
210
+ complete: /* @__PURE__ */ __name(async (id, headers) => {
211
+ return await this.client.fetch(`/executions/${id}/complete`, {
212
+ method: "POST",
213
+ headers
214
+ });
215
+ }, "complete")
206
216
  };
207
217
  fills = {
208
218
  /** Read one position's assigned quantities and fees at the original receipt price. */
@@ -219,14 +229,7 @@ class Core {
219
229
  headers,
220
230
  query
221
231
  });
222
- }, "list"),
223
- /** Read account-owned provisional receipts awaiting fee collection. */
224
- provisionals: /* @__PURE__ */ __name(async (headers) => {
225
- return await this.client.fetch(`/fills/provisionals-lite`, {
226
- method: "GET",
227
- headers
228
- });
229
- }, "provisionals")
232
+ }, "list")
230
233
  };
231
234
  funding = {
232
235
  list: /* @__PURE__ */ __name(async (query, headers) => {
@@ -350,12 +353,6 @@ class Core {
350
353
  query
351
354
  });
352
355
  }, "list"),
353
- openLite: /* @__PURE__ */ __name(async (headers) => {
354
- return await this.client.fetch(`/positions/lite`, {
355
- method: "GET",
356
- headers
357
- });
358
- }, "openLite"),
359
356
  /**
360
357
  * Closed-position history, newest close first, composed server-side.
361
358
  *
@@ -568,65 +565,13 @@ class Core {
568
565
  }, "cancelAll")
569
566
  };
570
567
  sync = {
571
- fills: {
572
- since: /* @__PURE__ */ __name(async (body, headers) => {
573
- return await this.client.fetch(`/sync/fills/since`, {
574
- method: "POST",
575
- headers,
576
- body
577
- });
578
- }, "since"),
579
- create: /* @__PURE__ */ __name(async (body, headers) => {
580
- return await this.client.fetch(`/sync/fills/create`, {
581
- method: "POST",
582
- headers,
583
- body
584
- });
585
- }, "create"),
586
- createBulk: /* @__PURE__ */ __name(async (body, headers) => {
587
- const file = await gzipJson(body);
588
- const formData = new FormData();
589
- formData.append("file", file, "payload.json.gz");
590
- formData.append("executionsUpdatedAtEpochMs", String(body.meta.executionsUpdatedAtEpochMs));
591
- return await this.client.fetch(`/sync/fills/create/bulk`, {
592
- method: "POST",
593
- headers: {
594
- ...headers,
595
- "content-type": null
596
- },
597
- body: formData
598
- });
599
- }, "createBulk")
600
- },
601
- funding: {
602
- since: /* @__PURE__ */ __name(async (body, headers) => {
603
- return await this.client.fetch(`/sync/funding/since`, {
604
- method: "POST",
605
- headers,
606
- body
607
- });
608
- }, "since"),
609
- create: /* @__PURE__ */ __name(async (body, headers) => {
610
- return await this.client.fetch(`/sync/funding/create`, {
611
- method: "POST",
612
- headers,
613
- body
614
- });
615
- }, "create"),
616
- createBulk: /* @__PURE__ */ __name(async (body, headers) => {
617
- const file = await gzipJson(body);
618
- const formData = new FormData();
619
- formData.append("file", file, "payload.json.gz");
620
- return await this.client.fetch(`/sync/funding/create/bulk`, {
621
- method: "POST",
622
- headers: {
623
- ...headers,
624
- "content-type": null
625
- },
626
- body: formData
627
- });
628
- }, "createBulk")
629
- }
568
+ /** Ask the server to sync the active account now; neverSynced says whether its first import is still pending. */
569
+ refresh: /* @__PURE__ */ __name(async (headers) => {
570
+ return await this.client.fetch(`/sync/refresh`, {
571
+ method: "POST",
572
+ headers
573
+ });
574
+ }, "refresh")
630
575
  };
631
576
  /** Basket commands; executed-fill history lives under the plural `trades` namespace. */
632
577
  trade = {
package/dist/types.d.ts CHANGED
@@ -162,6 +162,6 @@ type FetchArgs = Omit<RequestInit, 'headers' | 'body'> & {
162
162
  };
163
163
  type RequestMiddleware = (request: Request, next: () => Promise<Response>) => Promise<Response>;
164
164
  type ResponseMiddleware = (response: Response, retry: () => Promise<Response>, request: Request) => Promise<Response>;
165
- type ClientIdBody = HttpTypes.RebalanceManual | HttpTypes.CreateSchedule | HttpTypes.CreateTradeOpen | HttpTypes.CreateTradeAdjust | HttpTypes.CreateTradeClose | HttpTypes.CreateTradeCloseAll | HttpTypes.CreateTriggerOpen | HttpTypes.CreateTriggerClose;
165
+ type ClientIdBody = HttpTypes.RebalanceManual | HttpTypes.CreateSchedule | HttpTypes.CreateTradeOpenInput | HttpTypes.CreateTradeAdjust | HttpTypes.CreateTradeClose | HttpTypes.CreateTradeCloseAll | HttpTypes.CreateTriggerOpen | HttpTypes.CreateTriggerClose;
166
166
 
167
167
  export type { AuthErrorContext, AuthMode, ClientHeaders, ClientIdBody, FetchArgs, FetchInput, FetchParams, Logger, RequestMiddleware, ResponseMiddleware, SDKConfig };
package/dist/utils.d.ts CHANGED
@@ -12,6 +12,5 @@ declare class FetchError extends Error {
12
12
  details: unknown;
13
13
  constructor(message: string, statusText?: string, status?: number, errorCode?: string, details?: unknown);
14
14
  }
15
- declare function gzipJson(value: unknown): Promise<Blob>;
16
15
 
17
- export { FetchError, getBaseUrl, gzipJson, normalizeRequest, normalizeResponseData };
16
+ export { FetchError, getBaseUrl, normalizeRequest, normalizeResponseData };
package/dist/utils.js CHANGED
@@ -57,7 +57,7 @@ class FetchError extends Error {
57
57
  }
58
58
  status;
59
59
  statusText;
60
- // Machine-readable contract code from the server's error envelope (e.g. SYNC_CREATE_FILLS_TOO_RECENT).
60
+ // Machine-readable contract code from the server's error envelope (e.g. VALIDATION_ERROR).
61
61
  errorCode;
62
62
  // Structured context from the server's error envelope; shape varies by failure, so narrow before use.
63
63
  details;
@@ -69,12 +69,5 @@ class FetchError extends Error {
69
69
  this.details = details;
70
70
  }
71
71
  }
72
- async function gzipJson(value) {
73
- const stream = new Blob([
74
- JSON.stringify(value)
75
- ]).stream().pipeThrough(new CompressionStream("gzip"));
76
- return await new Response(stream).blob();
77
- }
78
- __name(gzipJson, "gzipJson");
79
72
 
80
- export { FetchError, getBaseUrl, gzipJson, normalizeRequest, normalizeResponseData };
73
+ export { FetchError, getBaseUrl, normalizeRequest, normalizeResponseData };
@@ -321,6 +321,11 @@ declare class Vaults {
321
321
  success: boolean;
322
322
  agentAddress: string;
323
323
  }>;
324
+ /** POST /vaults/:vaultAddress/set-account-mode — switch the vault agent between unified account and portfolio margin. */
325
+ setAccountMode: (vaultAddress: string, body: HttpTypes.SetAccountModeInput, headers?: ClientHeaders) => Promise<{
326
+ agentAddress: string;
327
+ mode: "unifiedAccount" | "portfolioMargin";
328
+ }>;
324
329
  };
325
330
  nav: {
326
331
  /** GET /vaults/:vaultAddress/nav/latest — fetch the most recent NAV snapshot for a vault. */
@@ -136,7 +136,15 @@ class Vaults {
136
136
  headers,
137
137
  body
138
138
  });
139
- }, "setUnifiedAccount")
139
+ }, "setUnifiedAccount"),
140
+ /** POST /vaults/:vaultAddress/set-account-mode — switch the vault agent between unified account and portfolio margin. */
141
+ setAccountMode: /* @__PURE__ */ __name(async (vaultAddress, body, headers) => {
142
+ return await this.client.fetch(`/vaults/${vaultAddress}/set-account-mode`, {
143
+ method: "POST",
144
+ headers,
145
+ body
146
+ });
147
+ }, "setAccountMode")
140
148
  };
141
149
  nav = {
142
150
  /** GET /vaults/:vaultAddress/nav/latest — fetch the most recent NAV snapshot for a vault. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/core-sdk",
3
- "version": "2.17.0",
3
+ "version": "2.19.0",
4
4
  "description": "Pear Protocol Core SDK",
5
5
  "private": false,
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "typecheck": "bunx --package bun@1.4.3 bun --check --threads=2"
27
27
  },
28
28
  "dependencies": {
29
- "@pear-protocol/types": "^2.25.0",
30
- "@pear-protocol/utils": "^1.6.1",
29
+ "@pear-protocol/types": "^2.28.0",
30
+ "@pear-protocol/utils": "^1.8.0",
31
31
  "qs": "^6.14.0"
32
32
  },
33
33
  "devDependencies": {