@pear-protocol/core-sdk 1.14.0 → 1.16.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/auth/index.d.ts +26 -2
- package/dist/auth/index.js +30 -0
- package/dist/core/index.d.ts +179 -2
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +5 -2
- package/package.json +6 -4
package/dist/auth/index.d.ts
CHANGED
|
@@ -8,6 +8,25 @@ declare class Auth {
|
|
|
8
8
|
constructor(client: HttpClient);
|
|
9
9
|
linkEmail(body: HttpTypes.LinkEmailRequest, headers?: ClientHeaders): Promise<void>;
|
|
10
10
|
linkWallet(body: HttpTypes.LinkWalletRequest, headers?: ClientHeaders): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Begin linking an X account. Send the browser to the returned `authorizeUrl`;
|
|
13
|
+
* X redirects back to the backend callback, which finishes the link.
|
|
14
|
+
*/
|
|
15
|
+
startXLink(headers?: ClientHeaders): Promise<{
|
|
16
|
+
authorizeUrl: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Begin signing in with X. Send the browser to the returned `authorizeUrl`; X redirects
|
|
20
|
+
* back to the backend callback, which signs in the Pear account that has this X account
|
|
21
|
+
* connected. It never creates one - connect X from a signed-in session first.
|
|
22
|
+
*/
|
|
23
|
+
startXLogin(headers?: ClientHeaders): Promise<{
|
|
24
|
+
authorizeUrl: string;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Unlink the authenticated user's X account. Removes the public handle immediately.
|
|
28
|
+
*/
|
|
29
|
+
disconnectX(headers?: ClientHeaders): Promise<void>;
|
|
11
30
|
login(body: HttpTypes.LoginRequest, headers?: ClientHeaders): Promise<{
|
|
12
31
|
accessToken: string;
|
|
13
32
|
refreshToken: string;
|
|
@@ -15,7 +34,7 @@ declare class Auth {
|
|
|
15
34
|
id: string;
|
|
16
35
|
role: "basic" | "pro";
|
|
17
36
|
providerId: string | null;
|
|
18
|
-
loginMethod: "email" | "evm_wallet" | "oauth";
|
|
37
|
+
loginMethod: "email" | "evm_wallet" | "oauth" | "x";
|
|
19
38
|
};
|
|
20
39
|
}>;
|
|
21
40
|
requestNonce(body: HttpTypes.RequestNonceRequest, headers?: ClientHeaders): Promise<{
|
|
@@ -29,7 +48,12 @@ declare class Auth {
|
|
|
29
48
|
id: string;
|
|
30
49
|
role: "basic" | "pro";
|
|
31
50
|
providerId: string | null;
|
|
32
|
-
loginMethod: "email" | "evm_wallet" | "oauth";
|
|
51
|
+
loginMethod: "email" | "evm_wallet" | "oauth" | "x";
|
|
52
|
+
identities: {
|
|
53
|
+
provider: "email" | "evm_wallet" | "oauth" | "x";
|
|
54
|
+
externalId: string;
|
|
55
|
+
connectedAt: string;
|
|
56
|
+
}[];
|
|
33
57
|
}>;
|
|
34
58
|
apiKeyMe(headers?: ClientHeaders): Promise<{
|
|
35
59
|
id: string;
|
package/dist/auth/index.js
CHANGED
|
@@ -17,6 +17,36 @@ class Auth {
|
|
|
17
17
|
body
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Begin linking an X account. Send the browser to the returned `authorizeUrl`;
|
|
22
|
+
* X redirects back to the backend callback, which finishes the link.
|
|
23
|
+
*/
|
|
24
|
+
async startXLink(headers) {
|
|
25
|
+
return await this.client.fetch(`/auth/link/x/start`, {
|
|
26
|
+
method: "POST",
|
|
27
|
+
headers
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Begin signing in with X. Send the browser to the returned `authorizeUrl`; X redirects
|
|
32
|
+
* back to the backend callback, which signs in the Pear account that has this X account
|
|
33
|
+
* connected. It never creates one - connect X from a signed-in session first.
|
|
34
|
+
*/
|
|
35
|
+
async startXLogin(headers) {
|
|
36
|
+
return await this.client.fetch(`/auth/login/x/start`, {
|
|
37
|
+
method: "POST",
|
|
38
|
+
headers
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Unlink the authenticated user's X account. Removes the public handle immediately.
|
|
43
|
+
*/
|
|
44
|
+
async disconnectX(headers) {
|
|
45
|
+
return await this.client.fetch(`/auth/link/x`, {
|
|
46
|
+
method: "DELETE",
|
|
47
|
+
headers
|
|
48
|
+
});
|
|
49
|
+
}
|
|
20
50
|
async login(body, headers) {
|
|
21
51
|
return await this.client.fetch(`/auth/login`, {
|
|
22
52
|
method: "POST",
|
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;
|
|
@@ -702,6 +702,7 @@ declare class Core {
|
|
|
702
702
|
quantity: string;
|
|
703
703
|
} | undefined;
|
|
704
704
|
}[] | undefined;
|
|
705
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
705
706
|
} | {
|
|
706
707
|
id: string;
|
|
707
708
|
tradeAccountId: string;
|
|
@@ -836,6 +837,7 @@ declare class Core {
|
|
|
836
837
|
quantity: string;
|
|
837
838
|
} | undefined;
|
|
838
839
|
}[] | undefined;
|
|
840
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
839
841
|
trailing?: {
|
|
840
842
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
841
843
|
deltaValue: number;
|
|
@@ -1003,6 +1005,7 @@ declare class Core {
|
|
|
1003
1005
|
quantity: string;
|
|
1004
1006
|
} | undefined;
|
|
1005
1007
|
}[] | undefined;
|
|
1008
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
1006
1009
|
trailing?: {
|
|
1007
1010
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
1008
1011
|
deltaValue: number;
|
|
@@ -1014,6 +1017,54 @@ declare class Core {
|
|
|
1014
1017
|
})[];
|
|
1015
1018
|
createdAt: string;
|
|
1016
1019
|
updatedAt: string;
|
|
1020
|
+
attachTriggers?: ({
|
|
1021
|
+
intent: "CLOSE";
|
|
1022
|
+
type: "MARKET";
|
|
1023
|
+
bracketType: "STOP_LOSS" | "TAKE_PROFIT";
|
|
1024
|
+
condition: {
|
|
1025
|
+
type: "notional";
|
|
1026
|
+
data: {
|
|
1027
|
+
priceSource: "mark" | "mid";
|
|
1028
|
+
threshold: number;
|
|
1029
|
+
};
|
|
1030
|
+
} | {
|
|
1031
|
+
type: "upnl";
|
|
1032
|
+
data: {
|
|
1033
|
+
priceSource: "mark" | "mid";
|
|
1034
|
+
threshold: number;
|
|
1035
|
+
};
|
|
1036
|
+
} | {
|
|
1037
|
+
type: "upnl_bps";
|
|
1038
|
+
data: {
|
|
1039
|
+
priceSource: "mark" | "mid";
|
|
1040
|
+
threshold: number;
|
|
1041
|
+
};
|
|
1042
|
+
};
|
|
1043
|
+
} | {
|
|
1044
|
+
intent: "CLOSE";
|
|
1045
|
+
type: "MARKET";
|
|
1046
|
+
condition: {
|
|
1047
|
+
type: "notional_trailing";
|
|
1048
|
+
data: {
|
|
1049
|
+
priceSource: "mark" | "mid";
|
|
1050
|
+
};
|
|
1051
|
+
} | {
|
|
1052
|
+
type: "upnl_trailing";
|
|
1053
|
+
data: {
|
|
1054
|
+
priceSource: "mark" | "mid";
|
|
1055
|
+
};
|
|
1056
|
+
} | {
|
|
1057
|
+
type: "upnl_bps_trailing";
|
|
1058
|
+
data: {
|
|
1059
|
+
priceSource: "mark" | "mid";
|
|
1060
|
+
};
|
|
1061
|
+
};
|
|
1062
|
+
trailing: {
|
|
1063
|
+
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
1064
|
+
deltaValue: number;
|
|
1065
|
+
activationValue?: number | undefined;
|
|
1066
|
+
};
|
|
1067
|
+
})[] | undefined;
|
|
1017
1068
|
}[];
|
|
1018
1069
|
nextCursor?: string | undefined;
|
|
1019
1070
|
}>;
|
|
@@ -1140,6 +1191,7 @@ declare class Core {
|
|
|
1140
1191
|
quantity: string;
|
|
1141
1192
|
} | undefined;
|
|
1142
1193
|
}[] | undefined;
|
|
1194
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
1143
1195
|
} | {
|
|
1144
1196
|
id: string;
|
|
1145
1197
|
tradeAccountId: string;
|
|
@@ -1274,6 +1326,7 @@ declare class Core {
|
|
|
1274
1326
|
quantity: string;
|
|
1275
1327
|
} | undefined;
|
|
1276
1328
|
}[] | undefined;
|
|
1329
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
1277
1330
|
trailing?: {
|
|
1278
1331
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
1279
1332
|
deltaValue: number;
|
|
@@ -1441,6 +1494,7 @@ declare class Core {
|
|
|
1441
1494
|
quantity: string;
|
|
1442
1495
|
} | undefined;
|
|
1443
1496
|
}[] | undefined;
|
|
1497
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
1444
1498
|
trailing?: {
|
|
1445
1499
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
1446
1500
|
deltaValue: number;
|
|
@@ -1452,6 +1506,54 @@ declare class Core {
|
|
|
1452
1506
|
})[];
|
|
1453
1507
|
createdAt: string;
|
|
1454
1508
|
updatedAt: string;
|
|
1509
|
+
attachTriggers?: ({
|
|
1510
|
+
intent: "CLOSE";
|
|
1511
|
+
type: "MARKET";
|
|
1512
|
+
bracketType: "STOP_LOSS" | "TAKE_PROFIT";
|
|
1513
|
+
condition: {
|
|
1514
|
+
type: "notional";
|
|
1515
|
+
data: {
|
|
1516
|
+
priceSource: "mark" | "mid";
|
|
1517
|
+
threshold: number;
|
|
1518
|
+
};
|
|
1519
|
+
} | {
|
|
1520
|
+
type: "upnl";
|
|
1521
|
+
data: {
|
|
1522
|
+
priceSource: "mark" | "mid";
|
|
1523
|
+
threshold: number;
|
|
1524
|
+
};
|
|
1525
|
+
} | {
|
|
1526
|
+
type: "upnl_bps";
|
|
1527
|
+
data: {
|
|
1528
|
+
priceSource: "mark" | "mid";
|
|
1529
|
+
threshold: number;
|
|
1530
|
+
};
|
|
1531
|
+
};
|
|
1532
|
+
} | {
|
|
1533
|
+
intent: "CLOSE";
|
|
1534
|
+
type: "MARKET";
|
|
1535
|
+
condition: {
|
|
1536
|
+
type: "notional_trailing";
|
|
1537
|
+
data: {
|
|
1538
|
+
priceSource: "mark" | "mid";
|
|
1539
|
+
};
|
|
1540
|
+
} | {
|
|
1541
|
+
type: "upnl_trailing";
|
|
1542
|
+
data: {
|
|
1543
|
+
priceSource: "mark" | "mid";
|
|
1544
|
+
};
|
|
1545
|
+
} | {
|
|
1546
|
+
type: "upnl_bps_trailing";
|
|
1547
|
+
data: {
|
|
1548
|
+
priceSource: "mark" | "mid";
|
|
1549
|
+
};
|
|
1550
|
+
};
|
|
1551
|
+
trailing: {
|
|
1552
|
+
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
1553
|
+
deltaValue: number;
|
|
1554
|
+
activationValue?: number | undefined;
|
|
1555
|
+
};
|
|
1556
|
+
})[] | undefined;
|
|
1455
1557
|
};
|
|
1456
1558
|
}>;
|
|
1457
1559
|
get: (ladderId: string, headers?: ClientHeaders) => Promise<{
|
|
@@ -1577,6 +1679,7 @@ declare class Core {
|
|
|
1577
1679
|
quantity: string;
|
|
1578
1680
|
} | undefined;
|
|
1579
1681
|
}[] | undefined;
|
|
1682
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
1580
1683
|
} | {
|
|
1581
1684
|
id: string;
|
|
1582
1685
|
tradeAccountId: string;
|
|
@@ -1711,6 +1814,7 @@ declare class Core {
|
|
|
1711
1814
|
quantity: string;
|
|
1712
1815
|
} | undefined;
|
|
1713
1816
|
}[] | undefined;
|
|
1817
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
1714
1818
|
trailing?: {
|
|
1715
1819
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
1716
1820
|
deltaValue: number;
|
|
@@ -1878,6 +1982,7 @@ declare class Core {
|
|
|
1878
1982
|
quantity: string;
|
|
1879
1983
|
} | undefined;
|
|
1880
1984
|
}[] | undefined;
|
|
1985
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
1881
1986
|
trailing?: {
|
|
1882
1987
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
1883
1988
|
deltaValue: number;
|
|
@@ -1889,6 +1994,54 @@ declare class Core {
|
|
|
1889
1994
|
})[];
|
|
1890
1995
|
createdAt: string;
|
|
1891
1996
|
updatedAt: string;
|
|
1997
|
+
attachTriggers?: ({
|
|
1998
|
+
intent: "CLOSE";
|
|
1999
|
+
type: "MARKET";
|
|
2000
|
+
bracketType: "STOP_LOSS" | "TAKE_PROFIT";
|
|
2001
|
+
condition: {
|
|
2002
|
+
type: "notional";
|
|
2003
|
+
data: {
|
|
2004
|
+
priceSource: "mark" | "mid";
|
|
2005
|
+
threshold: number;
|
|
2006
|
+
};
|
|
2007
|
+
} | {
|
|
2008
|
+
type: "upnl";
|
|
2009
|
+
data: {
|
|
2010
|
+
priceSource: "mark" | "mid";
|
|
2011
|
+
threshold: number;
|
|
2012
|
+
};
|
|
2013
|
+
} | {
|
|
2014
|
+
type: "upnl_bps";
|
|
2015
|
+
data: {
|
|
2016
|
+
priceSource: "mark" | "mid";
|
|
2017
|
+
threshold: number;
|
|
2018
|
+
};
|
|
2019
|
+
};
|
|
2020
|
+
} | {
|
|
2021
|
+
intent: "CLOSE";
|
|
2022
|
+
type: "MARKET";
|
|
2023
|
+
condition: {
|
|
2024
|
+
type: "notional_trailing";
|
|
2025
|
+
data: {
|
|
2026
|
+
priceSource: "mark" | "mid";
|
|
2027
|
+
};
|
|
2028
|
+
} | {
|
|
2029
|
+
type: "upnl_trailing";
|
|
2030
|
+
data: {
|
|
2031
|
+
priceSource: "mark" | "mid";
|
|
2032
|
+
};
|
|
2033
|
+
} | {
|
|
2034
|
+
type: "upnl_bps_trailing";
|
|
2035
|
+
data: {
|
|
2036
|
+
priceSource: "mark" | "mid";
|
|
2037
|
+
};
|
|
2038
|
+
};
|
|
2039
|
+
trailing: {
|
|
2040
|
+
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
2041
|
+
deltaValue: number;
|
|
2042
|
+
activationValue?: number | undefined;
|
|
2043
|
+
};
|
|
2044
|
+
})[] | undefined;
|
|
1892
2045
|
};
|
|
1893
2046
|
}>;
|
|
1894
2047
|
cancel: (ladderId: string, headers?: ClientHeaders) => Promise<{
|
|
@@ -2008,7 +2161,7 @@ declare class Core {
|
|
|
2008
2161
|
list: (query?: HttpTypes.NotificationListParamsInput, headers?: ClientHeaders) => Promise<{
|
|
2009
2162
|
notifications: {
|
|
2010
2163
|
id: string;
|
|
2011
|
-
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";
|
|
2164
|
+
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_CANCELLED_MIS_SCALED";
|
|
2012
2165
|
parameters: {
|
|
2013
2166
|
legs: {
|
|
2014
2167
|
id: string;
|
|
@@ -2019,6 +2172,7 @@ declare class Core {
|
|
|
2019
2172
|
triggerId: string;
|
|
2020
2173
|
positionId: string;
|
|
2021
2174
|
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
2175
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | undefined;
|
|
2022
2176
|
metric?: "price" | "ratio" | "weighted_ratio" | "funding_rate" | "prediction_market" | "btc_dominance" | "notional" | "upnl" | "upnl_bps" | "ratio_trailing" | "price_trailing" | "weighted_ratio_trailing" | "notional_trailing" | "upnl_trailing" | "upnl_bps_trailing" | undefined;
|
|
2023
2177
|
level?: number | undefined;
|
|
2024
2178
|
reason?: string | undefined;
|
|
@@ -2032,6 +2186,7 @@ declare class Core {
|
|
|
2032
2186
|
triggerId: string;
|
|
2033
2187
|
positionId: string;
|
|
2034
2188
|
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
2189
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | undefined;
|
|
2035
2190
|
metric?: "price" | "ratio" | "weighted_ratio" | "funding_rate" | "prediction_market" | "btc_dominance" | "notional" | "upnl" | "upnl_bps" | "ratio_trailing" | "price_trailing" | "weighted_ratio_trailing" | "notional_trailing" | "upnl_trailing" | "upnl_bps_trailing" | undefined;
|
|
2036
2191
|
level?: number | undefined;
|
|
2037
2192
|
reason?: string | undefined;
|
|
@@ -2122,6 +2277,12 @@ declare class Core {
|
|
|
2122
2277
|
connector: "hyperliquid" | "binance" | "bybit" | "okx" | "lighter";
|
|
2123
2278
|
weightSource: "INITIAL_WEIGHT" | "LIVE_BETA";
|
|
2124
2279
|
type: "auto_rebalance_paused";
|
|
2280
|
+
} | {
|
|
2281
|
+
type: "trigger_cancelled_mis_scaled";
|
|
2282
|
+
triggerId: string;
|
|
2283
|
+
positionKey: string;
|
|
2284
|
+
storedBps: number;
|
|
2285
|
+
readingMarginPct: number;
|
|
2125
2286
|
};
|
|
2126
2287
|
isRead: boolean;
|
|
2127
2288
|
createdAt: string;
|
|
@@ -3743,6 +3904,7 @@ declare class Core {
|
|
|
3743
3904
|
quantity: string;
|
|
3744
3905
|
} | undefined;
|
|
3745
3906
|
}[] | undefined;
|
|
3907
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
3746
3908
|
} | {
|
|
3747
3909
|
id: string;
|
|
3748
3910
|
tradeAccountId: string;
|
|
@@ -3877,6 +4039,7 @@ declare class Core {
|
|
|
3877
4039
|
quantity: string;
|
|
3878
4040
|
} | undefined;
|
|
3879
4041
|
}[] | undefined;
|
|
4042
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
3880
4043
|
trailing?: {
|
|
3881
4044
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
3882
4045
|
deltaValue: number;
|
|
@@ -4044,6 +4207,7 @@ declare class Core {
|
|
|
4044
4207
|
quantity: string;
|
|
4045
4208
|
} | undefined;
|
|
4046
4209
|
}[] | undefined;
|
|
4210
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
4047
4211
|
trailing?: {
|
|
4048
4212
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
4049
4213
|
deltaValue: number;
|
|
@@ -4167,6 +4331,7 @@ declare class Core {
|
|
|
4167
4331
|
quantity: string;
|
|
4168
4332
|
} | undefined;
|
|
4169
4333
|
}[] | undefined;
|
|
4334
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
4170
4335
|
} | {
|
|
4171
4336
|
id: string;
|
|
4172
4337
|
tradeAccountId: string;
|
|
@@ -4301,6 +4466,7 @@ declare class Core {
|
|
|
4301
4466
|
quantity: string;
|
|
4302
4467
|
} | undefined;
|
|
4303
4468
|
}[] | undefined;
|
|
4469
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
4304
4470
|
trailing?: {
|
|
4305
4471
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
4306
4472
|
deltaValue: number;
|
|
@@ -4468,6 +4634,7 @@ declare class Core {
|
|
|
4468
4634
|
quantity: string;
|
|
4469
4635
|
} | undefined;
|
|
4470
4636
|
}[] | undefined;
|
|
4637
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
4471
4638
|
trailing?: {
|
|
4472
4639
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
4473
4640
|
deltaValue: number;
|
|
@@ -4590,6 +4757,7 @@ declare class Core {
|
|
|
4590
4757
|
quantity: string;
|
|
4591
4758
|
} | undefined;
|
|
4592
4759
|
}[] | undefined;
|
|
4760
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
4593
4761
|
} | {
|
|
4594
4762
|
id: string;
|
|
4595
4763
|
tradeAccountId: string;
|
|
@@ -4724,6 +4892,7 @@ declare class Core {
|
|
|
4724
4892
|
quantity: string;
|
|
4725
4893
|
} | undefined;
|
|
4726
4894
|
}[] | undefined;
|
|
4895
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
4727
4896
|
trailing?: {
|
|
4728
4897
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
4729
4898
|
deltaValue: number;
|
|
@@ -4891,6 +5060,7 @@ declare class Core {
|
|
|
4891
5060
|
quantity: string;
|
|
4892
5061
|
} | undefined;
|
|
4893
5062
|
}[] | undefined;
|
|
5063
|
+
semanticBracketType?: "STOP_LOSS" | "TAKE_PROFIT" | "NONE" | undefined;
|
|
4894
5064
|
trailing?: {
|
|
4895
5065
|
mode: "RELATIVE_BPS" | "ABSOLUTE_POINTS";
|
|
4896
5066
|
deltaValue: number;
|
|
@@ -4917,6 +5087,9 @@ declare class Core {
|
|
|
4917
5087
|
address: string | null;
|
|
4918
5088
|
email: string | null;
|
|
4919
5089
|
emailVerified: boolean;
|
|
5090
|
+
xHandle: string | null;
|
|
5091
|
+
xName: string | null;
|
|
5092
|
+
xAvatarUrl: string | null;
|
|
4920
5093
|
};
|
|
4921
5094
|
preferences: {
|
|
4922
5095
|
slippageToleranceBps: number;
|
|
@@ -4994,6 +5167,10 @@ declare class Core {
|
|
|
4994
5167
|
pearFee: string;
|
|
4995
5168
|
tradeFee: string;
|
|
4996
5169
|
totalTrades: number;
|
|
5170
|
+
xHandle?: string | undefined;
|
|
5171
|
+
xName?: string | undefined;
|
|
5172
|
+
xAvatarUrl?: string | undefined;
|
|
5173
|
+
xUserId?: string | undefined;
|
|
4997
5174
|
}[];
|
|
4998
5175
|
}>;
|
|
4999
5176
|
};
|
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.16.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.23.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
|
}
|