@pear-protocol/core-sdk 1.13.0 → 1.15.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.
- package/dist/core/index.d.ts +13 -142
- package/dist/core/index.js +8 -0
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +5 -2
- package/package.json +6 -4
package/dist/core/index.d.ts
CHANGED
|
@@ -2618,7 +2618,18 @@ declare class Core {
|
|
|
2618
2618
|
/** Return referral codes owned by the authenticated user and their referrer. */
|
|
2619
2619
|
status: (headers?: ClientHeaders) => Promise<{
|
|
2620
2620
|
ownedCodes: string[];
|
|
2621
|
-
|
|
2621
|
+
referrerCode?: string | undefined;
|
|
2622
|
+
}>;
|
|
2623
|
+
/** List users permanently bound to the authenticated referrer. */
|
|
2624
|
+
referees: (query?: HttpTypes.ReferralRefereeListParamsInput, headers?: ClientHeaders) => Promise<{
|
|
2625
|
+
limit: number;
|
|
2626
|
+
count: number;
|
|
2627
|
+
referees: {
|
|
2628
|
+
tradeCount: number;
|
|
2629
|
+
address?: `0x${string}` | undefined;
|
|
2630
|
+
referredAt?: number | undefined;
|
|
2631
|
+
}[];
|
|
2632
|
+
nextCursor?: string | undefined;
|
|
2622
2633
|
}>;
|
|
2623
2634
|
};
|
|
2624
2635
|
savedBaskets: {
|
|
@@ -3475,147 +3486,7 @@ declare class Core {
|
|
|
3475
3486
|
}[] | undefined;
|
|
3476
3487
|
};
|
|
3477
3488
|
}>;
|
|
3478
|
-
closeAll: (body: HttpTypes.CreateTradeCloseAll, headers?: ClientHeaders) => Promise<
|
|
3479
|
-
executions: ({
|
|
3480
|
-
id: string;
|
|
3481
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3482
|
-
status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "IDLE" | "FAILED";
|
|
3483
|
-
createdAt: string;
|
|
3484
|
-
updatedAt: string;
|
|
3485
|
-
intent: "OPEN";
|
|
3486
|
-
orderType: "MARKET";
|
|
3487
|
-
legs: [{
|
|
3488
|
-
symbol: string;
|
|
3489
|
-
side: "BUY" | "SELL";
|
|
3490
|
-
mode: "QUANTITY" | "USD";
|
|
3491
|
-
amount: string;
|
|
3492
|
-
reduceOnly: boolean;
|
|
3493
|
-
}, ...{
|
|
3494
|
-
symbol: string;
|
|
3495
|
-
side: "BUY" | "SELL";
|
|
3496
|
-
mode: "QUANTITY" | "USD";
|
|
3497
|
-
amount: string;
|
|
3498
|
-
reduceOnly: boolean;
|
|
3499
|
-
}[]];
|
|
3500
|
-
error?: string | undefined;
|
|
3501
|
-
orders?: {
|
|
3502
|
-
id: string;
|
|
3503
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3504
|
-
status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
|
|
3505
|
-
createdAt: string;
|
|
3506
|
-
updatedAt: string;
|
|
3507
|
-
type: "MARKET";
|
|
3508
|
-
symbol: string;
|
|
3509
|
-
side: "BUY" | "SELL";
|
|
3510
|
-
reduceOnly: boolean;
|
|
3511
|
-
quantity: string;
|
|
3512
|
-
price: string;
|
|
3513
|
-
filledQuantity: string;
|
|
3514
|
-
error?: string | undefined;
|
|
3515
|
-
filledPrice?: string | undefined;
|
|
3516
|
-
}[] | undefined;
|
|
3517
|
-
} | {
|
|
3518
|
-
id: string;
|
|
3519
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3520
|
-
status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "IDLE" | "FAILED";
|
|
3521
|
-
createdAt: string;
|
|
3522
|
-
updatedAt: string;
|
|
3523
|
-
intent: "ADJUST";
|
|
3524
|
-
orderType: "MARKET";
|
|
3525
|
-
position: {
|
|
3526
|
-
id: string;
|
|
3527
|
-
exposure: Record<string, `-${string}` | `+${string}`>;
|
|
3528
|
-
};
|
|
3529
|
-
legs: [{
|
|
3530
|
-
symbol: string;
|
|
3531
|
-
side: "BUY" | "SELL";
|
|
3532
|
-
mode: "QUANTITY" | "USD";
|
|
3533
|
-
amount: string;
|
|
3534
|
-
reduceOnly: boolean;
|
|
3535
|
-
}, ...{
|
|
3536
|
-
symbol: string;
|
|
3537
|
-
side: "BUY" | "SELL";
|
|
3538
|
-
mode: "QUANTITY" | "USD";
|
|
3539
|
-
amount: string;
|
|
3540
|
-
reduceOnly: boolean;
|
|
3541
|
-
}[]];
|
|
3542
|
-
error?: string | undefined;
|
|
3543
|
-
orders?: {
|
|
3544
|
-
id: string;
|
|
3545
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3546
|
-
status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
|
|
3547
|
-
createdAt: string;
|
|
3548
|
-
updatedAt: string;
|
|
3549
|
-
type: "MARKET";
|
|
3550
|
-
symbol: string;
|
|
3551
|
-
side: "BUY" | "SELL";
|
|
3552
|
-
reduceOnly: boolean;
|
|
3553
|
-
quantity: string;
|
|
3554
|
-
price: string;
|
|
3555
|
-
filledQuantity: string;
|
|
3556
|
-
error?: string | undefined;
|
|
3557
|
-
filledPrice?: string | undefined;
|
|
3558
|
-
}[] | undefined;
|
|
3559
|
-
} | {
|
|
3560
|
-
id: string;
|
|
3561
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3562
|
-
status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "IDLE" | "FAILED";
|
|
3563
|
-
createdAt: string;
|
|
3564
|
-
updatedAt: string;
|
|
3565
|
-
intent: "CLOSE";
|
|
3566
|
-
orderType: "MARKET";
|
|
3567
|
-
position: {
|
|
3568
|
-
id: string;
|
|
3569
|
-
exposure: Record<string, `-${string}` | `+${string}`>;
|
|
3570
|
-
};
|
|
3571
|
-
error?: string | undefined;
|
|
3572
|
-
orders?: {
|
|
3573
|
-
id: string;
|
|
3574
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3575
|
-
status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
|
|
3576
|
-
createdAt: string;
|
|
3577
|
-
updatedAt: string;
|
|
3578
|
-
type: "MARKET";
|
|
3579
|
-
symbol: string;
|
|
3580
|
-
side: "BUY" | "SELL";
|
|
3581
|
-
reduceOnly: boolean;
|
|
3582
|
-
quantity: string;
|
|
3583
|
-
price: string;
|
|
3584
|
-
filledQuantity: string;
|
|
3585
|
-
error?: string | undefined;
|
|
3586
|
-
filledPrice?: string | undefined;
|
|
3587
|
-
}[] | undefined;
|
|
3588
|
-
} | {
|
|
3589
|
-
id: string;
|
|
3590
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3591
|
-
status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "IDLE" | "FAILED";
|
|
3592
|
-
createdAt: string;
|
|
3593
|
-
updatedAt: string;
|
|
3594
|
-
intent: "REVERSE";
|
|
3595
|
-
orderType: "MARKET";
|
|
3596
|
-
position: {
|
|
3597
|
-
id: string;
|
|
3598
|
-
exposure: Record<string, `-${string}` | `+${string}`>;
|
|
3599
|
-
};
|
|
3600
|
-
error?: string | undefined;
|
|
3601
|
-
orders?: {
|
|
3602
|
-
id: string;
|
|
3603
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3604
|
-
status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
|
|
3605
|
-
createdAt: string;
|
|
3606
|
-
updatedAt: string;
|
|
3607
|
-
type: "MARKET";
|
|
3608
|
-
symbol: string;
|
|
3609
|
-
side: "BUY" | "SELL";
|
|
3610
|
-
reduceOnly: boolean;
|
|
3611
|
-
quantity: string;
|
|
3612
|
-
price: string;
|
|
3613
|
-
filledQuantity: string;
|
|
3614
|
-
error?: string | undefined;
|
|
3615
|
-
filledPrice?: string | undefined;
|
|
3616
|
-
}[] | undefined;
|
|
3617
|
-
})[];
|
|
3618
|
-
}>;
|
|
3489
|
+
closeAll: (body: HttpTypes.CreateTradeCloseAll, headers?: ClientHeaders) => Promise<Record<string, never>>;
|
|
3619
3490
|
setLeverage: (body: HttpTypes.SetLeverage, headers?: ClientHeaders) => Promise<Record<string, never>>;
|
|
3620
3491
|
};
|
|
3621
3492
|
triggers: {
|
package/dist/core/index.js
CHANGED
|
@@ -375,6 +375,14 @@ class Core {
|
|
|
375
375
|
method: "GET",
|
|
376
376
|
headers
|
|
377
377
|
});
|
|
378
|
+
},
|
|
379
|
+
/** List users permanently bound to the authenticated referrer. */
|
|
380
|
+
referees: async (query, headers) => {
|
|
381
|
+
return await this.client.fetch(`/referrals/referees`, {
|
|
382
|
+
method: "GET",
|
|
383
|
+
headers,
|
|
384
|
+
query
|
|
385
|
+
});
|
|
378
386
|
}
|
|
379
387
|
};
|
|
380
388
|
savedBaskets = {
|
package/dist/utils.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ declare function normalizeResponseData(resp: Response, reqHeaders: Headers): Pro
|
|
|
8
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
13
|
}
|
|
13
14
|
declare function gzipJson(value: unknown): Promise<Blob>;
|
|
14
15
|
|
package/dist/utils.js
CHANGED
|
@@ -27,7 +27,7 @@ async function normalizeResponseData(resp, reqHeaders) {
|
|
|
27
27
|
}
|
|
28
28
|
if (resp.status >= 300) {
|
|
29
29
|
const jsonError = await resp.json().catch(() => ({}));
|
|
30
|
-
throw new FetchError(jsonError.message ?? resp.statusText, resp.statusText, resp.status);
|
|
30
|
+
throw new FetchError(jsonError.message ?? resp.statusText, resp.statusText, resp.status, jsonError.errorCode);
|
|
31
31
|
}
|
|
32
32
|
if (resp.status === 204 || resp.status === 205) {
|
|
33
33
|
return null;
|
|
@@ -45,10 +45,13 @@ async function normalizeResponseData(resp, reqHeaders) {
|
|
|
45
45
|
class FetchError extends Error {
|
|
46
46
|
status;
|
|
47
47
|
statusText;
|
|
48
|
-
|
|
48
|
+
// Machine-readable contract code from the server's error envelope (e.g. SYNC_CREATE_FILLS_TOO_RECENT).
|
|
49
|
+
errorCode;
|
|
50
|
+
constructor(message, statusText, status, errorCode) {
|
|
49
51
|
super(message);
|
|
50
52
|
this.statusText = statusText;
|
|
51
53
|
this.status = status;
|
|
54
|
+
this.errorCode = errorCode;
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
async function gzipJson(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pear-protocol/core-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "Pear Protocol Core SDK",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -22,17 +22,19 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsup",
|
|
24
24
|
"clean": "rm -rf dist .turbo",
|
|
25
|
+
"test": "vitest run",
|
|
25
26
|
"typecheck": "tsc --noEmit"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@pear-protocol/types": "^1.
|
|
29
|
-
"@pear-protocol/utils": "^0.5.
|
|
29
|
+
"@pear-protocol/types": "^1.20.0",
|
|
30
|
+
"@pear-protocol/utils": "^0.5.1",
|
|
30
31
|
"qs": "^6.14.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@backend/typescript-config": "workspace:*",
|
|
34
35
|
"@types/qs": "^6.14.0",
|
|
35
36
|
"tsup": "8.5.1",
|
|
36
|
-
"typescript": "5.9.3"
|
|
37
|
+
"typescript": "5.9.3",
|
|
38
|
+
"vitest": "4.1.2"
|
|
37
39
|
}
|
|
38
40
|
}
|