@pear-protocol/core-sdk 2.17.0 → 2.18.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.
@@ -2988,18 +2988,6 @@ declare class Core {
2988
2988
  }[];
2989
2989
  nextCursor?: string | undefined;
2990
2990
  }>;
2991
- /** Read account-owned provisional receipts awaiting fee collection. */
2992
- provisionals: (headers?: ClientHeaders) => Promise<{
2993
- fills: {
2994
- id: string;
2995
- tradeAccountId: string;
2996
- connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
2997
- symbol: string;
2998
- status: "PROVISIONAL";
2999
- executionId?: string | undefined;
3000
- cloid?: string | undefined;
3001
- }[];
3002
- }>;
3003
2991
  };
3004
2992
  funding: {
3005
2993
  list: (query: HttpTypes.FundingQueryParams, headers?: ClientHeaders) => Promise<{
@@ -5681,6 +5669,7 @@ declare class Core {
5681
5669
  notional?: {
5682
5670
  min?: number | null | undefined;
5683
5671
  max?: number | null | undefined;
5672
+ minBuffer?: number | undefined;
5684
5673
  } | undefined;
5685
5674
  };
5686
5675
  tradeability: {
@@ -5770,7 +5759,7 @@ declare class Core {
5770
5759
  list: (query?: HttpTypes.NotificationListParamsInput, headers?: ClientHeaders) => Promise<{
5771
5760
  notifications: {
5772
5761
  id: string;
5773
- category: "TAKE_PROFIT_HIT" | "STOP_LOSS_HIT" | "TRIGGER_ORDER_HIT" | "TAKE_PROFIT_FAILED" | "STOP_LOSS_FAILED" | "TRIGGER_ORDER_FAILED" | "ATTACHED_TRIGGER_DISCARDED" | "AUTO_REBALANCE_EXECUTED" | "AUTO_REBALANCE_FAILED" | "AUTO_REBALANCE_PAUSED" | "TRIGGER_TWAP_STARTED" | "TRIGGER_TWAP_SKIPPED" | "TRIGGER_TWAP_FAILED" | "TRIGGER_TWAP_POSITION_CHANGED" | "TRIGGER_CANCELLED_MIS_SCALED" | "COPY_PLACED" | "COPY_FAILED" | "COPY_SUBSCRIPTION_STOPPED" | "COPY_LEVERAGE_NOT_APPLIED" | "POSITION_LIQUIDATION" | "TRIGGER_CANCELLED_POSITION_RESIZED" | "TAKE_PROFIT_PARTIAL" | "STOP_LOSS_PARTIAL" | "TRIGGER_ORDER_PARTIAL" | "TRIGGER_CANCELLED_BY_OPERATOR" | "LADDER_CANCELLED_BY_OPERATOR" | "AUTO_REBALANCE_STOPPED_BY_OPERATOR";
5762
+ category: "TAKE_PROFIT_HIT" | "STOP_LOSS_HIT" | "TRIGGER_ORDER_HIT" | "TAKE_PROFIT_FAILED" | "STOP_LOSS_FAILED" | "TRIGGER_ORDER_FAILED" | "ATTACHED_TRIGGER_DISCARDED" | "AUTO_REBALANCE_EXECUTED" | "AUTO_REBALANCE_FAILED" | "AUTO_REBALANCE_PAUSED" | "TRIGGER_TWAP_STARTED" | "TRIGGER_TWAP_SKIPPED" | "TRIGGER_TWAP_FAILED" | "TRIGGER_TWAP_POSITION_CHANGED" | "TRIGGER_CANCELLED_MIS_SCALED" | "COPY_PLACED" | "COPY_FAILED" | "COPY_SUBSCRIPTION_STOPPED" | "COPY_LEVERAGE_NOT_APPLIED" | "COPY_MARGIN_NOT_APPLIED" | "POSITION_LIQUIDATION" | "TRIGGER_CANCELLED_POSITION_RESIZED" | "TAKE_PROFIT_PARTIAL" | "STOP_LOSS_PARTIAL" | "TRIGGER_ORDER_PARTIAL" | "TRIGGER_CANCELLED_BY_OPERATOR" | "LADDER_CANCELLED_BY_OPERATOR" | "AUTO_REBALANCE_STOPPED_BY_OPERATOR";
5774
5763
  parameters: {
5775
5764
  type: "position_liquidation";
5776
5765
  positionId: string;
@@ -5982,6 +5971,10 @@ declare class Core {
5982
5971
  type: "copy_leverage_not_applied";
5983
5972
  subscriptionId: string;
5984
5973
  activityId: string;
5974
+ } | {
5975
+ type: "copy_margin_not_applied";
5976
+ subscriptionId: string;
5977
+ activityId: string;
5985
5978
  } | {
5986
5979
  type: "trigger_cancelled_position_resized";
5987
5980
  triggerId: string;
@@ -6066,18 +6059,6 @@ declare class Core {
6066
6059
  }[];
6067
6060
  nextCursor?: string | undefined;
6068
6061
  }>;
6069
- openLite: (headers?: ClientHeaders) => Promise<{
6070
- positions: {
6071
- id: string;
6072
- positionKey: string;
6073
- createdAt: string;
6074
- exposure: Record<string, `-${string}` | `+${string}`>;
6075
- status: "OPEN";
6076
- origin: "PARTIAL" | "PEAR" | "EXTERNAL";
6077
- connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
6078
- copySubscriptionId?: string | undefined;
6079
- }[];
6080
- }>;
6081
6062
  /**
6082
6063
  * Closed-position history, newest close first, composed server-side.
6083
6064
  *
@@ -7095,25 +7076,11 @@ declare class Core {
7095
7076
  }>;
7096
7077
  };
7097
7078
  sync: {
7098
- fills: {
7099
- since: (body: HttpTypes.SyncFillsSinceRequest, headers?: ClientHeaders) => Promise<{
7100
- sinceMs: number;
7101
- neverSynced: boolean;
7102
- executionsUpdatedAtEpochMs: number;
7103
- firstSyncStartedAt?: number | undefined;
7104
- confirmedExchangeFillIds?: string[] | undefined;
7105
- hasPendingSynthetics?: boolean | undefined;
7106
- }>;
7107
- create: (body: HttpTypes.CreateApplicablesRequest, headers?: ClientHeaders) => Promise<Record<string, never>>;
7108
- createBulk: (body: HttpTypes.CreateApplicablesRequest, headers?: ClientHeaders) => Promise<Record<string, never>>;
7109
- };
7110
- funding: {
7111
- since: (body: HttpTypes.SyncFundingSinceRequest, headers?: ClientHeaders) => Promise<{
7112
- sinceMs: number;
7113
- }>;
7114
- create: (body: HttpTypes.CreateFundingPaymentsRequest, headers?: ClientHeaders) => Promise<Record<string, never>>;
7115
- createBulk: (body: HttpTypes.CreateFundingPaymentsRequest, headers?: ClientHeaders) => Promise<Record<string, never>>;
7116
- };
7079
+ /** Ask the server to sync the active account now; neverSynced says whether its first import is still pending. */
7080
+ refresh: (headers?: ClientHeaders) => Promise<{
7081
+ neverSynced: boolean;
7082
+ credentialsRejection?: "venue-account-missing" | "credentials-invalid" | undefined;
7083
+ }>;
7117
7084
  };
7118
7085
  /** Basket commands; executed-fill history lives under the plural `trades` namespace. */
7119
7086
  trade: {
@@ -11282,7 +11249,7 @@ declare class Core {
11282
11249
  } | {
11283
11250
  leaderPositionId: string;
11284
11251
  outcome: "SKIPPED";
11285
- reason: "ASSET_CONFLICT" | "SUBSCRIPTION_NOT_ACTIVE" | "POSITION_EXCLUDED" | "INCLUDED_IN_JOIN" | "VENUE_MISMATCH" | "BELOW_VENUE_MINIMUM" | "PAIR_ALREADY_ENTERED" | "ENTRY_EXPIRED" | "FOLLOWER_LEG_ABSENT" | "LEADER_LEG_REOPENED" | "NO_FOLLOWER_DELTA" | "LEADER_EQUITY_UNREADABLE" | "FOLLOWER_EQUITY_UNREADABLE" | "PRICE_UNAVAILABLE" | "LEVERAGE_NOT_APPLIED" | "FOLLOWER_TWAP_NOT_ACTIVE" | "FOLLOWER_TWAP_ALREADY_ACTIVE" | "TRUE_UP_STALE";
11252
+ reason: "ASSET_CONFLICT" | "SUBSCRIPTION_NOT_ACTIVE" | "POSITION_EXCLUDED" | "INCLUDED_IN_JOIN" | "VENUE_MISMATCH" | "BELOW_VENUE_MINIMUM" | "PAIR_ALREADY_ENTERED" | "ENTRY_EXPIRED" | "FOLLOWER_LEG_ABSENT" | "LEADER_LEG_REOPENED" | "NO_FOLLOWER_DELTA" | "LEADER_EQUITY_UNREADABLE" | "FOLLOWER_EQUITY_UNREADABLE" | "PRICE_UNAVAILABLE" | "LEVERAGE_NOT_APPLIED" | "MARGIN_NOT_APPLIED" | "FOLLOWER_TWAP_NOT_ACTIVE" | "FOLLOWER_TWAP_ALREADY_ACTIVE" | "TRUE_UP_STALE";
11286
11253
  } | {
11287
11254
  leaderPositionId: string;
11288
11255
  outcome: "FAILED";
@@ -11426,7 +11393,7 @@ declare class Core {
11426
11393
  activities: (id: string, query?: HttpTypes.CopyActivityListParamsInput, headers?: ClientHeaders) => Promise<{
11427
11394
  activities: {
11428
11395
  id: string;
11429
- leaderAction: "TWAP" | "OPEN" | "CLOSE" | "ADJUST" | "REVERSE" | "TWAP_END" | "LEVERAGE_CHANGED";
11396
+ leaderAction: "TWAP" | "OPEN" | "CLOSE" | "ADJUST" | "REVERSE" | "TWAP_END" | "LEVERAGE_CHANGED" | "MARGIN_ADJUSTED";
11430
11397
  state: "RECORDED" | "DISPATCHED" | "SETTLED";
11431
11398
  followerLegs: {
11432
11399
  symbol: string;
@@ -11450,7 +11417,7 @@ declare class Core {
11450
11417
  configId: string;
11451
11418
  } | undefined;
11452
11419
  outcome?: "FAILED" | "COPIED" | "PARTIAL" | "SKIPPED" | undefined;
11453
- skipReason?: "ASSET_CONFLICT" | "SUBSCRIPTION_NOT_ACTIVE" | "POSITION_EXCLUDED" | "INCLUDED_IN_JOIN" | "VENUE_MISMATCH" | "BELOW_VENUE_MINIMUM" | "PAIR_ALREADY_ENTERED" | "ENTRY_EXPIRED" | "FOLLOWER_LEG_ABSENT" | "LEADER_LEG_REOPENED" | "NO_FOLLOWER_DELTA" | "LEADER_EQUITY_UNREADABLE" | "FOLLOWER_EQUITY_UNREADABLE" | "PRICE_UNAVAILABLE" | "LEVERAGE_NOT_APPLIED" | "FOLLOWER_TWAP_NOT_ACTIVE" | "FOLLOWER_TWAP_ALREADY_ACTIVE" | "TRUE_UP_STALE" | undefined;
11420
+ skipReason?: "ASSET_CONFLICT" | "SUBSCRIPTION_NOT_ACTIVE" | "POSITION_EXCLUDED" | "INCLUDED_IN_JOIN" | "VENUE_MISMATCH" | "BELOW_VENUE_MINIMUM" | "PAIR_ALREADY_ENTERED" | "ENTRY_EXPIRED" | "FOLLOWER_LEG_ABSENT" | "LEADER_LEG_REOPENED" | "NO_FOLLOWER_DELTA" | "LEADER_EQUITY_UNREADABLE" | "FOLLOWER_EQUITY_UNREADABLE" | "PRICE_UNAVAILABLE" | "LEVERAGE_NOT_APPLIED" | "MARGIN_NOT_APPLIED" | "FOLLOWER_TWAP_NOT_ACTIVE" | "FOLLOWER_TWAP_ALREADY_ACTIVE" | "TRUE_UP_STALE" | undefined;
11454
11421
  failureReason?: string | undefined;
11455
11422
  leaderEquityFraction?: string | undefined;
11456
11423
  twap?: {
@@ -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 {
@@ -219,14 +217,7 @@ class Core {
219
217
  headers,
220
218
  query
221
219
  });
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")
220
+ }, "list")
230
221
  };
231
222
  funding = {
232
223
  list: /* @__PURE__ */ __name(async (query, headers) => {
@@ -350,12 +341,6 @@ class Core {
350
341
  query
351
342
  });
352
343
  }, "list"),
353
- openLite: /* @__PURE__ */ __name(async (headers) => {
354
- return await this.client.fetch(`/positions/lite`, {
355
- method: "GET",
356
- headers
357
- });
358
- }, "openLite"),
359
344
  /**
360
345
  * Closed-position history, newest close first, composed server-side.
361
346
  *
@@ -568,65 +553,13 @@ class Core {
568
553
  }, "cancelAll")
569
554
  };
570
555
  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
- }
556
+ /** Ask the server to sync the active account now; neverSynced says whether its first import is still pending. */
557
+ refresh: /* @__PURE__ */ __name(async (headers) => {
558
+ return await this.client.fetch(`/sync/refresh`, {
559
+ method: "POST",
560
+ headers
561
+ });
562
+ }, "refresh")
630
563
  };
631
564
  /** Basket commands; executed-fill history lives under the plural `trades` namespace. */
632
565
  trade = {
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.18.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.27.0",
30
+ "@pear-protocol/utils": "^1.7.0",
31
31
  "qs": "^6.14.0"
32
32
  },
33
33
  "devDependencies": {