@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 +1 -0
- package/dist/index.js +27 -11
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
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
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
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