@orderly.network/ui-positions 2.11.0 → 3.0.0-beta.1
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.js +25 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
package/dist/index.js
CHANGED
|
@@ -1639,7 +1639,17 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1639
1639
|
if (!currentPosition) return null;
|
|
1640
1640
|
return new utils.Decimal(currentPosition.notional);
|
|
1641
1641
|
}, [currentPosition]);
|
|
1642
|
-
const unSettledPnl =
|
|
1642
|
+
const unSettledPnl = React2.useMemo(() => {
|
|
1643
|
+
if (!currentPosition || !notional || !fundingRates) return null;
|
|
1644
|
+
const fundingRate = fundingRates[currentPosition.symbol];
|
|
1645
|
+
return notional.sub(new utils.Decimal(currentPosition.cost_position)).sub(
|
|
1646
|
+
new utils.Decimal(currentPosition.position_qty).mul(
|
|
1647
|
+
new utils.Decimal(fundingRate.sum_unitary_funding ?? 0).sub(
|
|
1648
|
+
new utils.Decimal(currentPosition.last_sum_unitary_funding)
|
|
1649
|
+
)
|
|
1650
|
+
)
|
|
1651
|
+
);
|
|
1652
|
+
}, [notional, currentPosition, fundingRates]);
|
|
1643
1653
|
const imr = React2.useMemo(() => {
|
|
1644
1654
|
if (!currentPosition || !symbolsInfo?.[symbol] || !notional) {
|
|
1645
1655
|
return null;
|
|
@@ -1667,12 +1677,12 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1667
1677
|
}
|
|
1668
1678
|
const positionNotional = notional;
|
|
1669
1679
|
const imrValue = imr;
|
|
1670
|
-
const unsettledPnlValue = unSettledPnl ?? 0;
|
|
1680
|
+
const unsettledPnlValue = unSettledPnl ?? new utils.Decimal(0);
|
|
1671
1681
|
return perp.account.maxReduce({
|
|
1672
1682
|
isolatedPositionMargin: isolatedMargin,
|
|
1673
1683
|
positionNotional: positionNotional.toNumber(),
|
|
1674
1684
|
imr: imrValue.toNumber(),
|
|
1675
|
-
positionUnsettledPnL: unsettledPnlValue
|
|
1685
|
+
positionUnsettledPnL: unsettledPnlValue.toNumber()
|
|
1676
1686
|
});
|
|
1677
1687
|
}, [
|
|
1678
1688
|
total_cross_unsettled_pnl,
|
|
@@ -1689,14 +1699,14 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1689
1699
|
const currentSymbolInfo = symbolsInfo[symbol];
|
|
1690
1700
|
const currentPositionNotional = notional?.toNumber() ?? 0;
|
|
1691
1701
|
const currentPositionIMRFactor = accountInfo.imr_factor[symbol] ?? currentSymbolInfo.imr_factor ?? 0;
|
|
1692
|
-
perp.positions.MMR({
|
|
1702
|
+
const currentPositionMMR = perp.positions.MMR({
|
|
1693
1703
|
baseMMR: currentSymbolInfo.base_mmr ?? 0,
|
|
1694
1704
|
baseIMR: currentSymbolInfo.base_imr ?? 0,
|
|
1695
1705
|
IMRFactor: currentPositionIMRFactor,
|
|
1696
1706
|
positionNotional: currentPositionNotional,
|
|
1697
1707
|
IMR_factor_power: 4 / 5
|
|
1698
1708
|
});
|
|
1699
|
-
positions2?.filter((item) => item.symbol !== symbol).map((item) => {
|
|
1709
|
+
const otherPositions = positions2?.filter((item) => item.symbol !== symbol).map((item) => {
|
|
1700
1710
|
const itemSymbolInfo = symbolsInfo[item.symbol];
|
|
1701
1711
|
const itemIMRFactor = accountInfo.imr_factor[item.symbol] ?? itemSymbolInfo?.imr_factor ?? 0;
|
|
1702
1712
|
const itemNotional = item.notional ?? new utils.Decimal(item.position_qty).mul(item.mark_price).abs().toNumber();
|
|
@@ -1714,19 +1724,18 @@ var usePositionMargin = (symbol, isAdd, isolatedMargin, finalMargin) => {
|
|
|
1714
1724
|
mmr: itemMMR
|
|
1715
1725
|
};
|
|
1716
1726
|
}) ?? [];
|
|
1717
|
-
new utils.Decimal(finalMargin).add(currentPosition.unsettled_pnl ?? 0).toNumber();
|
|
1718
|
-
const
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
positionQty: currentPosition.position_qty
|
|
1723
|
-
|
|
1724
|
-
|
|
1727
|
+
const totalCollateral = new utils.Decimal(finalMargin).add(currentPosition.unsettled_pnl ?? 0).toNumber();
|
|
1728
|
+
const liqPrice = perp.positions.liqPrice({
|
|
1729
|
+
markPrice,
|
|
1730
|
+
symbol,
|
|
1731
|
+
totalCollateral,
|
|
1732
|
+
positionQty: currentPosition.position_qty,
|
|
1733
|
+
positions: otherPositions,
|
|
1734
|
+
MMR: currentPositionMMR,
|
|
1725
1735
|
baseMMR: currentSymbolInfo.base_mmr ?? 0,
|
|
1726
1736
|
baseIMR: currentSymbolInfo.base_imr ?? 0,
|
|
1727
1737
|
IMRFactor: currentPositionIMRFactor,
|
|
1728
|
-
|
|
1729
|
-
leverage: currentPosition.leverage ?? 0
|
|
1738
|
+
costPosition: currentPosition.cost_position ?? 0
|
|
1730
1739
|
});
|
|
1731
1740
|
return liqPrice;
|
|
1732
1741
|
}, [
|
|
@@ -1872,7 +1881,7 @@ var useAdjustMarginScript = (props) => {
|
|
|
1872
1881
|
sliderValue,
|
|
1873
1882
|
maxAmount: maxAmount ?? 0,
|
|
1874
1883
|
currentMargin,
|
|
1875
|
-
liquidationPrice,
|
|
1884
|
+
liquidationPrice: liquidationPrice ?? 0,
|
|
1876
1885
|
effectiveLeverage: effectiveLeverage ?? 0,
|
|
1877
1886
|
isLoading,
|
|
1878
1887
|
isAdd,
|