@pear-protocol/core-sdk 2.4.0 → 2.5.1
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.
- package/dist/core/index.d.ts +3171 -545
- package/dist/core/index.js +122 -40
- package/dist/index.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/vaults/index.d.ts +4 -4
- package/package.json +3 -3
package/dist/core/index.js
CHANGED
|
@@ -22,6 +22,23 @@ class Core {
|
|
|
22
22
|
...body
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
+
traders = {
|
|
26
|
+
/** Read a public trader's paginated closed history without account authentication. */
|
|
27
|
+
closedPositions: /* @__PURE__ */ __name(async (tradeAccountId, query, headers) => {
|
|
28
|
+
return await this.client.fetch(`/traders/${encodeURIComponent(tradeAccountId)}/closed-positions`, {
|
|
29
|
+
method: "GET",
|
|
30
|
+
query,
|
|
31
|
+
headers
|
|
32
|
+
});
|
|
33
|
+
}, "closedPositions"),
|
|
34
|
+
/** Read the latest 20 open positions and active automation records per section without account authentication. */
|
|
35
|
+
public: /* @__PURE__ */ __name(async (tradeAccountId, headers) => {
|
|
36
|
+
return await this.client.fetch(`/traders/${encodeURIComponent(tradeAccountId)}`, {
|
|
37
|
+
method: "GET",
|
|
38
|
+
headers
|
|
39
|
+
});
|
|
40
|
+
}, "public")
|
|
41
|
+
};
|
|
25
42
|
accounts = {
|
|
26
43
|
list: /* @__PURE__ */ __name(async (query, headers) => {
|
|
27
44
|
return await this.client.fetch(`/trade-accounts`, {
|
|
@@ -44,6 +61,22 @@ class Core {
|
|
|
44
61
|
body
|
|
45
62
|
});
|
|
46
63
|
}, "update"),
|
|
64
|
+
/** Set public viewing consent independently of account settings. */
|
|
65
|
+
updateSharing: /* @__PURE__ */ __name(async (id, body, headers) => {
|
|
66
|
+
return await this.client.fetch(`/trade-accounts/${encodeURIComponent(id)}/sharing`, {
|
|
67
|
+
method: "PATCH",
|
|
68
|
+
headers,
|
|
69
|
+
body
|
|
70
|
+
});
|
|
71
|
+
}, "updateSharing"),
|
|
72
|
+
/** Set copying consent independently of account settings. */
|
|
73
|
+
updateCopying: /* @__PURE__ */ __name(async (id, body, headers) => {
|
|
74
|
+
return await this.client.fetch(`/trade-accounts/${encodeURIComponent(id)}/copying`, {
|
|
75
|
+
method: "PATCH",
|
|
76
|
+
headers,
|
|
77
|
+
body
|
|
78
|
+
});
|
|
79
|
+
}, "updateCopying"),
|
|
47
80
|
delete: /* @__PURE__ */ __name(async (id, headers) => {
|
|
48
81
|
return await this.client.fetch(`/trade-accounts/${id}`, {
|
|
49
82
|
method: "DELETE",
|
|
@@ -516,46 +549,6 @@ class Core {
|
|
|
516
549
|
body
|
|
517
550
|
});
|
|
518
551
|
}, "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
552
|
create: /* @__PURE__ */ __name(async (body, headers) => {
|
|
560
553
|
return await this.client.fetch(`/sync/fills/create`, {
|
|
561
554
|
method: "POST",
|
|
@@ -748,6 +741,30 @@ class Core {
|
|
|
748
741
|
*/
|
|
749
742
|
buildLighterMiscRoutes(basePath) {
|
|
750
743
|
return {
|
|
744
|
+
/** Creates a Lighter subaccount with the main account's API credentials. */
|
|
745
|
+
createSubAccount: /* @__PURE__ */ __name(async (body, headers) => {
|
|
746
|
+
return await this.client.fetch(`${basePath}/sub-account/create`, {
|
|
747
|
+
method: "POST",
|
|
748
|
+
headers,
|
|
749
|
+
body
|
|
750
|
+
});
|
|
751
|
+
}, "createSubAccount"),
|
|
752
|
+
/** Moves perpetual collateral between Lighter accounts owned by the same main account. */
|
|
753
|
+
transferSubAccount: /* @__PURE__ */ __name(async (body, headers) => {
|
|
754
|
+
return await this.client.fetch(`${basePath}/sub-account/transfer`, {
|
|
755
|
+
method: "POST",
|
|
756
|
+
headers,
|
|
757
|
+
body
|
|
758
|
+
});
|
|
759
|
+
}, "transferSubAccount"),
|
|
760
|
+
/** Sets a Lighter subaccount's display name and description; Core answers 204 on success. */
|
|
761
|
+
setSubAccountMetadata: /* @__PURE__ */ __name(async (body, headers) => {
|
|
762
|
+
await this.client.fetch(`${basePath}/sub-account/set-metadata`, {
|
|
763
|
+
method: "POST",
|
|
764
|
+
headers,
|
|
765
|
+
body
|
|
766
|
+
});
|
|
767
|
+
}, "setSubAccountMetadata"),
|
|
751
768
|
createApiKey: /* @__PURE__ */ __name(async (body, headers) => {
|
|
752
769
|
return await this.client.fetch(`${basePath}/create-api-key`, {
|
|
753
770
|
method: "POST",
|
|
@@ -809,6 +826,71 @@ class Core {
|
|
|
809
826
|
}, "changeAccountTier")
|
|
810
827
|
};
|
|
811
828
|
}
|
|
829
|
+
/**
|
|
830
|
+
* Copy trading, served by the copy service rather than core.
|
|
831
|
+
*
|
|
832
|
+
* Same gateway and same session, a different upstream behind `/copy` — so nothing here needs its
|
|
833
|
+
* own client, but a failure means the copy service is down rather than core.
|
|
834
|
+
*/
|
|
835
|
+
copy = {
|
|
836
|
+
health: /* @__PURE__ */ __name(async (headers) => {
|
|
837
|
+
return await this.client.fetch(`/copy/health`, {
|
|
838
|
+
method: "GET",
|
|
839
|
+
headers
|
|
840
|
+
});
|
|
841
|
+
}, "health"),
|
|
842
|
+
/** Read NONE or ACTIVE for one account owned by the authenticated user. */
|
|
843
|
+
state: /* @__PURE__ */ __name(async (headers) => {
|
|
844
|
+
return await this.client.fetch(`/copy/state`, {
|
|
845
|
+
method: "GET",
|
|
846
|
+
headers
|
|
847
|
+
});
|
|
848
|
+
}, "state"),
|
|
849
|
+
/** Read all active followers of an owned leader account. */
|
|
850
|
+
followers: /* @__PURE__ */ __name(async (headers) => {
|
|
851
|
+
return await this.client.fetch(`/copy/followers`, {
|
|
852
|
+
method: "GET",
|
|
853
|
+
headers
|
|
854
|
+
});
|
|
855
|
+
}, "followers"),
|
|
856
|
+
/** Read owner-only copy totals; optional dates filter fills, not follower counts. */
|
|
857
|
+
stats: /* @__PURE__ */ __name(async (query, headers) => {
|
|
858
|
+
return await this.client.fetch(`/copy/stats`, {
|
|
859
|
+
method: "GET",
|
|
860
|
+
headers,
|
|
861
|
+
query
|
|
862
|
+
});
|
|
863
|
+
}, "stats"),
|
|
864
|
+
/** Read subscription history; use copy.state for the current relationship of one account. */
|
|
865
|
+
listSubscriptions: /* @__PURE__ */ __name(async (headers) => {
|
|
866
|
+
return await this.client.fetch(`/copy/subscriptions`, {
|
|
867
|
+
method: "GET",
|
|
868
|
+
headers
|
|
869
|
+
});
|
|
870
|
+
}, "listSubscriptions"),
|
|
871
|
+
/** Start copying into the account selected by x-trade-account-id, syncing existing positions by default. */
|
|
872
|
+
subscribe: /* @__PURE__ */ __name(async (body, headers) => {
|
|
873
|
+
return await this.client.fetch(`/copy/subscriptions`, {
|
|
874
|
+
method: "POST",
|
|
875
|
+
headers,
|
|
876
|
+
body
|
|
877
|
+
});
|
|
878
|
+
}, "subscribe"),
|
|
879
|
+
/** Stop copying while retaining existing positions under follower control. */
|
|
880
|
+
unsubscribe: /* @__PURE__ */ __name(async (id, headers) => {
|
|
881
|
+
return await this.client.fetch(`/copy/subscriptions/${id}/end`, {
|
|
882
|
+
method: "POST",
|
|
883
|
+
headers
|
|
884
|
+
});
|
|
885
|
+
}, "unsubscribe"),
|
|
886
|
+
activities: /* @__PURE__ */ __name(async (id, query, headers) => {
|
|
887
|
+
return await this.client.fetch(`/copy/subscriptions/${id}/activities`, {
|
|
888
|
+
method: "GET",
|
|
889
|
+
headers,
|
|
890
|
+
query
|
|
891
|
+
});
|
|
892
|
+
}, "activities")
|
|
893
|
+
};
|
|
812
894
|
statistics = {
|
|
813
895
|
volume: /* @__PURE__ */ __name(async (query, headers) => {
|
|
814
896
|
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
|
-
*
|
|
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
|
*/
|
package/dist/vaults/index.d.ts
CHANGED
|
@@ -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: "
|
|
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: "
|
|
192
|
+
status: "pending" | "failed" | "succeeded";
|
|
193
193
|
createdAt: string;
|
|
194
194
|
updatedAt: string;
|
|
195
195
|
vaultAddress?: string | undefined;
|
|
@@ -401,10 +401,10 @@ declare class Vaults {
|
|
|
401
401
|
positions: {
|
|
402
402
|
status: "CLOSED";
|
|
403
403
|
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter" | "lighter_rhc";
|
|
404
|
+
positionId: string;
|
|
404
405
|
closedAt: string;
|
|
405
406
|
grossPnl: `-${string}` | `+${string}`;
|
|
406
407
|
netPnl: `-${string}` | `+${string}`;
|
|
407
|
-
positionId: string;
|
|
408
408
|
openedAt: string;
|
|
409
409
|
hasProvisionalFills: boolean;
|
|
410
410
|
legs: {
|
|
@@ -416,7 +416,7 @@ declare class Vaults {
|
|
|
416
416
|
entryVwap?: string | undefined;
|
|
417
417
|
exitVwap?: string | undefined;
|
|
418
418
|
}[];
|
|
419
|
-
closedReason?: "
|
|
419
|
+
closedReason?: "NETTED" | "USER" | "LIQUIDATED" | undefined;
|
|
420
420
|
}[];
|
|
421
421
|
nextCursor?: string | undefined;
|
|
422
422
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pear-protocol/core-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
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.
|
|
30
|
-
"@pear-protocol/utils": "^1.
|
|
29
|
+
"@pear-protocol/types": "^2.12.1",
|
|
30
|
+
"@pear-protocol/utils": "^1.3.0",
|
|
31
31
|
"qs": "^6.14.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|