@pear-protocol/hyperliquid-sdk 0.1.14 → 0.1.15

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/index.d.ts CHANGED
@@ -228,6 +228,7 @@ interface TwapMonitoringDto {
228
228
  interface TradeHistoryAssetDataDto {
229
229
  coin: string;
230
230
  entryWeight: number;
231
+ closeWeight: number;
231
232
  entryPrice: number;
232
233
  limitPrice: number;
233
234
  leverage: number;
package/dist/index.js CHANGED
@@ -1566,17 +1566,33 @@ const useTradeHistories = () => {
1566
1566
  const enrichedTradeHistories = useMemo(() => {
1567
1567
  if (!tradeHistories)
1568
1568
  return null;
1569
- return tradeHistories.map((history) => ({
1570
- ...history,
1571
- closedLongAssets: history.closedLongAssets.map((asset) => ({
1572
- ...asset,
1573
- metadata: getAssetByName(asset.coin),
1574
- })),
1575
- closedShortAssets: history.closedShortAssets.map((asset) => ({
1576
- ...asset,
1577
- metadata: getAssetByName(asset.coin),
1578
- })),
1579
- }));
1569
+ return tradeHistories.map((history) => {
1570
+ const totalClosePositionSize = history.closedLongAssets.reduce((acc, asset) => acc + asset.limitPrice * asset.size, 0) +
1571
+ history.closedShortAssets.reduce((acc, asset) => acc + asset.limitPrice * asset.size, 0);
1572
+ return {
1573
+ ...history,
1574
+ closedLongAssets: history.closedLongAssets.map((asset) => {
1575
+ const closeNotional = asset.limitPrice * asset.size;
1576
+ return {
1577
+ ...asset,
1578
+ closeWeight: totalClosePositionSize > 0
1579
+ ? closeNotional / totalClosePositionSize
1580
+ : 0,
1581
+ metadata: getAssetByName(asset.coin),
1582
+ };
1583
+ }),
1584
+ closedShortAssets: history.closedShortAssets.map((asset) => {
1585
+ const closeNotional = asset.limitPrice * asset.size;
1586
+ return {
1587
+ ...asset,
1588
+ closeWeight: totalClosePositionSize > 0
1589
+ ? closeNotional / totalClosePositionSize
1590
+ : 0,
1591
+ metadata: getAssetByName(asset.coin),
1592
+ };
1593
+ }),
1594
+ };
1595
+ });
1580
1596
  }, [tradeHistories, getAssetByName]);
1581
1597
  const isLoading = useMemo(() => {
1582
1598
  return tradeHistories === null && context.isConnected;
package/dist/types.d.ts CHANGED
@@ -200,6 +200,7 @@ export interface TwapMonitoringDto {
200
200
  export interface TradeHistoryAssetDataDto {
201
201
  coin: string;
202
202
  entryWeight: number;
203
+ closeWeight: number;
203
204
  entryPrice: number;
204
205
  limitPrice: number;
205
206
  leverage: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/hyperliquid-sdk",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "React SDK for Pear Protocol Hyperliquid API integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",