@pear-protocol/core-sdk 1.14.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 +2 -142
- 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
|
@@ -187,7 +187,7 @@ declare class Core {
|
|
|
187
187
|
get: (query?: HttpTypes.QuoteFeeParamsInput, headers?: ClientHeaders) => Promise<{
|
|
188
188
|
baseBps: string;
|
|
189
189
|
discounts: {
|
|
190
|
-
scope: "
|
|
190
|
+
scope: "user" | "connector" | "all" | "client_id";
|
|
191
191
|
rate: string;
|
|
192
192
|
}[];
|
|
193
193
|
finalBps: string;
|
|
@@ -3486,147 +3486,7 @@ declare class Core {
|
|
|
3486
3486
|
}[] | undefined;
|
|
3487
3487
|
};
|
|
3488
3488
|
}>;
|
|
3489
|
-
closeAll: (body: HttpTypes.CreateTradeCloseAll, headers?: ClientHeaders) => Promise<
|
|
3490
|
-
executions: ({
|
|
3491
|
-
id: string;
|
|
3492
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3493
|
-
status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "IDLE" | "FAILED";
|
|
3494
|
-
createdAt: string;
|
|
3495
|
-
updatedAt: string;
|
|
3496
|
-
intent: "OPEN";
|
|
3497
|
-
orderType: "MARKET";
|
|
3498
|
-
legs: [{
|
|
3499
|
-
symbol: string;
|
|
3500
|
-
side: "BUY" | "SELL";
|
|
3501
|
-
mode: "QUANTITY" | "USD";
|
|
3502
|
-
amount: string;
|
|
3503
|
-
reduceOnly: boolean;
|
|
3504
|
-
}, ...{
|
|
3505
|
-
symbol: string;
|
|
3506
|
-
side: "BUY" | "SELL";
|
|
3507
|
-
mode: "QUANTITY" | "USD";
|
|
3508
|
-
amount: string;
|
|
3509
|
-
reduceOnly: boolean;
|
|
3510
|
-
}[]];
|
|
3511
|
-
error?: string | undefined;
|
|
3512
|
-
orders?: {
|
|
3513
|
-
id: string;
|
|
3514
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3515
|
-
status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
|
|
3516
|
-
createdAt: string;
|
|
3517
|
-
updatedAt: string;
|
|
3518
|
-
type: "MARKET";
|
|
3519
|
-
symbol: string;
|
|
3520
|
-
side: "BUY" | "SELL";
|
|
3521
|
-
reduceOnly: boolean;
|
|
3522
|
-
quantity: string;
|
|
3523
|
-
price: string;
|
|
3524
|
-
filledQuantity: string;
|
|
3525
|
-
error?: string | undefined;
|
|
3526
|
-
filledPrice?: string | undefined;
|
|
3527
|
-
}[] | undefined;
|
|
3528
|
-
} | {
|
|
3529
|
-
id: string;
|
|
3530
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3531
|
-
status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "IDLE" | "FAILED";
|
|
3532
|
-
createdAt: string;
|
|
3533
|
-
updatedAt: string;
|
|
3534
|
-
intent: "ADJUST";
|
|
3535
|
-
orderType: "MARKET";
|
|
3536
|
-
position: {
|
|
3537
|
-
id: string;
|
|
3538
|
-
exposure: Record<string, `-${string}` | `+${string}`>;
|
|
3539
|
-
};
|
|
3540
|
-
legs: [{
|
|
3541
|
-
symbol: string;
|
|
3542
|
-
side: "BUY" | "SELL";
|
|
3543
|
-
mode: "QUANTITY" | "USD";
|
|
3544
|
-
amount: string;
|
|
3545
|
-
reduceOnly: boolean;
|
|
3546
|
-
}, ...{
|
|
3547
|
-
symbol: string;
|
|
3548
|
-
side: "BUY" | "SELL";
|
|
3549
|
-
mode: "QUANTITY" | "USD";
|
|
3550
|
-
amount: string;
|
|
3551
|
-
reduceOnly: boolean;
|
|
3552
|
-
}[]];
|
|
3553
|
-
error?: string | undefined;
|
|
3554
|
-
orders?: {
|
|
3555
|
-
id: string;
|
|
3556
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3557
|
-
status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
|
|
3558
|
-
createdAt: string;
|
|
3559
|
-
updatedAt: string;
|
|
3560
|
-
type: "MARKET";
|
|
3561
|
-
symbol: string;
|
|
3562
|
-
side: "BUY" | "SELL";
|
|
3563
|
-
reduceOnly: boolean;
|
|
3564
|
-
quantity: string;
|
|
3565
|
-
price: string;
|
|
3566
|
-
filledQuantity: string;
|
|
3567
|
-
error?: string | undefined;
|
|
3568
|
-
filledPrice?: string | undefined;
|
|
3569
|
-
}[] | undefined;
|
|
3570
|
-
} | {
|
|
3571
|
-
id: string;
|
|
3572
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3573
|
-
status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "IDLE" | "FAILED";
|
|
3574
|
-
createdAt: string;
|
|
3575
|
-
updatedAt: string;
|
|
3576
|
-
intent: "CLOSE";
|
|
3577
|
-
orderType: "MARKET";
|
|
3578
|
-
position: {
|
|
3579
|
-
id: string;
|
|
3580
|
-
exposure: Record<string, `-${string}` | `+${string}`>;
|
|
3581
|
-
};
|
|
3582
|
-
error?: string | undefined;
|
|
3583
|
-
orders?: {
|
|
3584
|
-
id: string;
|
|
3585
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3586
|
-
status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
|
|
3587
|
-
createdAt: string;
|
|
3588
|
-
updatedAt: string;
|
|
3589
|
-
type: "MARKET";
|
|
3590
|
-
symbol: string;
|
|
3591
|
-
side: "BUY" | "SELL";
|
|
3592
|
-
reduceOnly: boolean;
|
|
3593
|
-
quantity: string;
|
|
3594
|
-
price: string;
|
|
3595
|
-
filledQuantity: string;
|
|
3596
|
-
error?: string | undefined;
|
|
3597
|
-
filledPrice?: string | undefined;
|
|
3598
|
-
}[] | undefined;
|
|
3599
|
-
} | {
|
|
3600
|
-
id: string;
|
|
3601
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3602
|
-
status: "CANCELLED" | "ACTIVE" | "COMPLETED" | "IDLE" | "FAILED";
|
|
3603
|
-
createdAt: string;
|
|
3604
|
-
updatedAt: string;
|
|
3605
|
-
intent: "REVERSE";
|
|
3606
|
-
orderType: "MARKET";
|
|
3607
|
-
position: {
|
|
3608
|
-
id: string;
|
|
3609
|
-
exposure: Record<string, `-${string}` | `+${string}`>;
|
|
3610
|
-
};
|
|
3611
|
-
error?: string | undefined;
|
|
3612
|
-
orders?: {
|
|
3613
|
-
id: string;
|
|
3614
|
-
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
3615
|
-
status: "CANCELLED" | "PENDING" | "PARTIAL" | "FILLED" | "REJECTED";
|
|
3616
|
-
createdAt: string;
|
|
3617
|
-
updatedAt: string;
|
|
3618
|
-
type: "MARKET";
|
|
3619
|
-
symbol: string;
|
|
3620
|
-
side: "BUY" | "SELL";
|
|
3621
|
-
reduceOnly: boolean;
|
|
3622
|
-
quantity: string;
|
|
3623
|
-
price: string;
|
|
3624
|
-
filledQuantity: string;
|
|
3625
|
-
error?: string | undefined;
|
|
3626
|
-
filledPrice?: string | undefined;
|
|
3627
|
-
}[] | undefined;
|
|
3628
|
-
})[];
|
|
3629
|
-
}>;
|
|
3489
|
+
closeAll: (body: HttpTypes.CreateTradeCloseAll, headers?: ClientHeaders) => Promise<Record<string, never>>;
|
|
3630
3490
|
setLeverage: (body: HttpTypes.SetLeverage, headers?: ClientHeaders) => Promise<Record<string, never>>;
|
|
3631
3491
|
};
|
|
3632
3492
|
triggers: {
|
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
|
}
|