@pear-protocol/core-sdk 2.3.0 → 2.5.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.
@@ -22,6 +22,15 @@ class Core {
22
22
  ...body
23
23
  };
24
24
  }
25
+ traders = {
26
+ /** Read the latest 20 open positions and active automation records per section without account authentication. */
27
+ public: /* @__PURE__ */ __name(async (tradeAccountId, headers) => {
28
+ return await this.client.fetch(`/traders/${encodeURIComponent(tradeAccountId)}`, {
29
+ method: "GET",
30
+ headers
31
+ });
32
+ }, "public")
33
+ };
25
34
  accounts = {
26
35
  list: /* @__PURE__ */ __name(async (query, headers) => {
27
36
  return await this.client.fetch(`/trade-accounts`, {
@@ -44,6 +53,22 @@ class Core {
44
53
  body
45
54
  });
46
55
  }, "update"),
56
+ /** Set public viewing consent independently of account settings. */
57
+ updateSharing: /* @__PURE__ */ __name(async (id, body, headers) => {
58
+ return await this.client.fetch(`/trade-accounts/${encodeURIComponent(id)}/sharing`, {
59
+ method: "PATCH",
60
+ headers,
61
+ body
62
+ });
63
+ }, "updateSharing"),
64
+ /** Set copying consent independently of account settings. */
65
+ updateCopying: /* @__PURE__ */ __name(async (id, body, headers) => {
66
+ return await this.client.fetch(`/trade-accounts/${encodeURIComponent(id)}/copying`, {
67
+ method: "PATCH",
68
+ headers,
69
+ body
70
+ });
71
+ }, "updateCopying"),
47
72
  delete: /* @__PURE__ */ __name(async (id, headers) => {
48
73
  return await this.client.fetch(`/trade-accounts/${id}`, {
49
74
  method: "DELETE",
@@ -516,46 +541,6 @@ class Core {
516
541
  body
517
542
  });
518
543
  }, "since"),
519
- reconcile: /* @__PURE__ */ __name(async (body, headers) => {
520
- return await this.client.fetch(`/sync/fills/reconcile`, {
521
- method: "POST",
522
- headers,
523
- body
524
- });
525
- }, "reconcile"),
526
- reconcileBulk: /* @__PURE__ */ __name(async (body, headers) => {
527
- const file = await gzipJson(body);
528
- const formData = new FormData();
529
- formData.append("file", file, "payload.json.gz");
530
- return await this.client.fetch(`/sync/fills/reconcile/bulk`, {
531
- method: "POST",
532
- headers: {
533
- ...headers,
534
- "content-type": null
535
- },
536
- body: formData
537
- });
538
- }, "reconcileBulk"),
539
- confirm: /* @__PURE__ */ __name(async (body, headers) => {
540
- return await this.client.fetch(`/sync/fills/confirm`, {
541
- method: "POST",
542
- headers,
543
- body
544
- });
545
- }, "confirm"),
546
- confirmBulk: /* @__PURE__ */ __name(async (body, headers) => {
547
- const file = await gzipJson(body);
548
- const formData = new FormData();
549
- formData.append("file", file, "payload.json.gz");
550
- return await this.client.fetch(`/sync/fills/confirm/bulk`, {
551
- method: "POST",
552
- headers: {
553
- ...headers,
554
- "content-type": null
555
- },
556
- body: formData
557
- });
558
- }, "confirmBulk"),
559
544
  create: /* @__PURE__ */ __name(async (body, headers) => {
560
545
  return await this.client.fetch(`/sync/fills/create`, {
561
546
  method: "POST",
@@ -748,6 +733,30 @@ class Core {
748
733
  */
749
734
  buildLighterMiscRoutes(basePath) {
750
735
  return {
736
+ /** Creates a Lighter subaccount with the main account's API credentials. */
737
+ createSubAccount: /* @__PURE__ */ __name(async (body, headers) => {
738
+ return await this.client.fetch(`${basePath}/sub-account/create`, {
739
+ method: "POST",
740
+ headers,
741
+ body
742
+ });
743
+ }, "createSubAccount"),
744
+ /** Moves perpetual collateral between Lighter accounts owned by the same main account. */
745
+ transferSubAccount: /* @__PURE__ */ __name(async (body, headers) => {
746
+ return await this.client.fetch(`${basePath}/sub-account/transfer`, {
747
+ method: "POST",
748
+ headers,
749
+ body
750
+ });
751
+ }, "transferSubAccount"),
752
+ /** Sets a Lighter subaccount's display name and description; Core answers 204 on success. */
753
+ setSubAccountMetadata: /* @__PURE__ */ __name(async (body, headers) => {
754
+ await this.client.fetch(`${basePath}/sub-account/set-metadata`, {
755
+ method: "POST",
756
+ headers,
757
+ body
758
+ });
759
+ }, "setSubAccountMetadata"),
751
760
  createApiKey: /* @__PURE__ */ __name(async (body, headers) => {
752
761
  return await this.client.fetch(`${basePath}/create-api-key`, {
753
762
  method: "POST",
@@ -809,6 +818,71 @@ class Core {
809
818
  }, "changeAccountTier")
810
819
  };
811
820
  }
821
+ /**
822
+ * Copy trading, served by the copy service rather than core.
823
+ *
824
+ * Same gateway and same session, a different upstream behind `/copy` — so nothing here needs its
825
+ * own client, but a failure means the copy service is down rather than core.
826
+ */
827
+ copy = {
828
+ health: /* @__PURE__ */ __name(async (headers) => {
829
+ return await this.client.fetch(`/copy/health`, {
830
+ method: "GET",
831
+ headers
832
+ });
833
+ }, "health"),
834
+ /** Read NONE or ACTIVE for one account owned by the authenticated user. */
835
+ state: /* @__PURE__ */ __name(async (headers) => {
836
+ return await this.client.fetch(`/copy/state`, {
837
+ method: "GET",
838
+ headers
839
+ });
840
+ }, "state"),
841
+ /** Read all active followers of an owned leader account. */
842
+ followers: /* @__PURE__ */ __name(async (headers) => {
843
+ return await this.client.fetch(`/copy/followers`, {
844
+ method: "GET",
845
+ headers
846
+ });
847
+ }, "followers"),
848
+ /** Read owner-only copy totals; optional dates filter fills, not follower counts. */
849
+ stats: /* @__PURE__ */ __name(async (query, headers) => {
850
+ return await this.client.fetch(`/copy/stats`, {
851
+ method: "GET",
852
+ headers,
853
+ query
854
+ });
855
+ }, "stats"),
856
+ /** Read subscription history; use copy.state for the current relationship of one account. */
857
+ listSubscriptions: /* @__PURE__ */ __name(async (headers) => {
858
+ return await this.client.fetch(`/copy/subscriptions`, {
859
+ method: "GET",
860
+ headers
861
+ });
862
+ }, "listSubscriptions"),
863
+ /** Start copying into the account selected by x-trade-account-id, syncing existing positions by default. */
864
+ subscribe: /* @__PURE__ */ __name(async (body, headers) => {
865
+ return await this.client.fetch(`/copy/subscriptions`, {
866
+ method: "POST",
867
+ headers,
868
+ body
869
+ });
870
+ }, "subscribe"),
871
+ /** Stop copying while retaining existing positions under follower control. */
872
+ unsubscribe: /* @__PURE__ */ __name(async (id, headers) => {
873
+ return await this.client.fetch(`/copy/subscriptions/${id}/end`, {
874
+ method: "POST",
875
+ headers
876
+ });
877
+ }, "unsubscribe"),
878
+ activities: /* @__PURE__ */ __name(async (id, query, headers) => {
879
+ return await this.client.fetch(`/copy/subscriptions/${id}/activities`, {
880
+ method: "GET",
881
+ headers,
882
+ query
883
+ });
884
+ }, "activities")
885
+ };
812
886
  statistics = {
813
887
  volume: /* @__PURE__ */ __name(async (query, headers) => {
814
888
  return await this.client.fetch(`/statistics/volume`, {
package/dist/index.js CHANGED
@@ -175,7 +175,7 @@ class PearSDK {
175
175
  return next();
176
176
  }
177
177
  const tradeAccountId = getTradeAccountId?.();
178
- if (tradeAccountId) {
178
+ if (tradeAccountId && !request.headers.has("x-trade-account-id")) {
179
179
  request.headers.set("x-trade-account-id", tradeAccountId);
180
180
  }
181
181
  return next();
package/dist/types.d.ts CHANGED
@@ -57,7 +57,7 @@ type SDKConfig = {
57
57
  key?: () => string | null;
58
58
  };
59
59
  /**
60
- * Trade account ID getter (used in both modes)
60
+ * Default trade account ID getter; explicit x-trade-account-id request headers take precedence.
61
61
  *
62
62
  * Example: () => localStorage.getState().activeTradeAccountId
63
63
  */
@@ -176,7 +176,7 @@ declare class Vaults {
176
176
  activity: {
177
177
  id: string;
178
178
  type: "vault.create" | "vault.set_trader" | "vault.update_metadata" | "bridge.withdraw_to_evm";
179
- status: "failed" | "pending" | "succeeded";
179
+ status: "pending" | "failed" | "succeeded";
180
180
  createdAt: string;
181
181
  updatedAt: string;
182
182
  vaultAddress?: string | undefined;
@@ -189,7 +189,7 @@ declare class Vaults {
189
189
  activity: {
190
190
  id: string;
191
191
  type: "vault.create" | "vault.set_trader" | "vault.update_metadata" | "bridge.withdraw_to_evm";
192
- status: "failed" | "pending" | "succeeded";
192
+ status: "pending" | "failed" | "succeeded";
193
193
  createdAt: string;
194
194
  updatedAt: string;
195
195
  vaultAddress?: string | undefined;
@@ -221,21 +221,28 @@ declare class Vaults {
221
221
  metadata: {
222
222
  /** PATCH /vaults/:vaultAddress — update mutable metadata fields on a vault. */
223
223
  update: (vaultAddress: string, body: HttpTypes.UpdateVaultMetadataInput, headers?: ClientHeaders) => Promise<{
224
- vault: {
225
- id: string;
226
- vaultAddress: HttpTypes.EthereumAddress;
227
- ownerAddress: HttpTypes.EthereumAddress;
228
- traderAddress: HttpTypes.EthereumAddress | null;
229
- agentAddress: HttpTypes.EthereumAddress;
230
- status: "active" | "inactive" | "pending_activation";
231
- isApproved: boolean;
232
- name: string | null;
233
- about: string | null;
234
- imageUrl: string | null;
235
- transactionHash: string | null;
236
- maxWithdrawalPeriodDays: number;
237
- createdAt: string;
238
- updatedAt: string;
224
+ result: {
225
+ success: true;
226
+ vault: {
227
+ id: string;
228
+ vaultAddress: HttpTypes.EthereumAddress;
229
+ ownerAddress: HttpTypes.EthereumAddress;
230
+ traderAddress: HttpTypes.EthereumAddress | null;
231
+ agentAddress: HttpTypes.EthereumAddress;
232
+ status: "active" | "inactive" | "pending_activation";
233
+ isApproved: boolean;
234
+ name: string | null;
235
+ about: string | null;
236
+ imageUrl: string | null;
237
+ transactionHash: string | null;
238
+ maxWithdrawalPeriodDays: number;
239
+ createdAt: string;
240
+ updatedAt: string;
241
+ };
242
+ } | {
243
+ success: false;
244
+ status: "in_progress";
245
+ activityId: string;
239
246
  };
240
247
  }>;
241
248
  };
@@ -394,10 +401,10 @@ declare class Vaults {
394
401
  positions: {
395
402
  status: "CLOSED";
396
403
  connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
404
+ positionId: string;
397
405
  closedAt: string;
398
406
  grossPnl: `-${string}` | `+${string}`;
399
407
  netPnl: `-${string}` | `+${string}`;
400
- positionId: string;
401
408
  openedAt: string;
402
409
  hasProvisionalFills: boolean;
403
410
  legs: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/core-sdk",
3
- "version": "2.3.0",
3
+ "version": "2.5.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.10.0",
30
- "@pear-protocol/utils": "^1.2.0",
29
+ "@pear-protocol/types": "^2.12.0",
30
+ "@pear-protocol/utils": "^1.3.0",
31
31
  "qs": "^6.14.0"
32
32
  },
33
33
  "devDependencies": {