From 8a3c64c98f4235a660355923d2d9d3857e47531b Mon Sep 17 00:00:00 2001 From: "troyb.eth" Date: Fri, 10 Feb 2023 05:39:37 -0700 Subject: [PATCH 1/6] fix: use skew adjusted price for uPnL (#1993) upnl uses skew adjusted price --- state/futures/selectors.ts | 2 +- utils/futures.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/state/futures/selectors.ts b/state/futures/selectors.ts index 647e74e9c8..7891202ffa 100644 --- a/state/futures/selectors.ts +++ b/state/futures/selectors.ts @@ -217,7 +217,7 @@ export const selectCrossMarginPositions = createSelector( ); export const selectIsolatedMarginPositions = createSelector( - selectPrices, + selectMarkPrices, selectIsolatedAccountData, (prices, account) => { return account?.positions?.map((p) => updatePositionUpnl(p, prices)) ?? []; diff --git a/utils/futures.ts b/utils/futures.ts index 220b5a6650..51569f9208 100644 --- a/utils/futures.ts +++ b/utils/futures.ts @@ -15,7 +15,7 @@ import { FuturesVolumes, PositionSide, } from 'sdk/types/futures'; -import { Prices, PricesMap } from 'sdk/types/prices'; +import { PricesMap } from 'sdk/types/prices'; import { CrossMarginBalanceInfo, CrossMarginSettings, @@ -26,6 +26,7 @@ import { TransactionEstimation, futuresPositionKeys, FundingRate, + MarkPrices, } from 'state/futures/types'; import { deserializeWeiObject } from 'state/helpers'; @@ -243,13 +244,13 @@ const getPositionChangeState = (existingSize: Wei, newSize: Wei) => { export const updatePositionUpnl = ( positionDetails: FuturesPosition, - prices: Prices + prices: MarkPrices ): FuturesPosition => { const deserializedPositionDetails = deserializeWeiObject( positionDetails, futuresPositionKeys ) as FuturesPosition; - const offChainPrice = prices[deserializedPositionDetails.asset]?.offChain; + const offChainPrice = prices[MarketKeyByAsset[deserializedPositionDetails.asset]]; const position = deserializedPositionDetails.position; const pnl = From ff11a4625f859c51381102c52683a6b621f6b9aa Mon Sep 17 00:00:00 2001 From: Adam Clarke Date: Fri, 10 Feb 2023 17:18:47 +0000 Subject: [PATCH 2/6] fix: extend market drop down height (#2001) --- sections/futures/Trade/MarketsDropdown.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/sections/futures/Trade/MarketsDropdown.tsx b/sections/futures/Trade/MarketsDropdown.tsx index 78511d44b2..b849cf8e29 100644 --- a/sections/futures/Trade/MarketsDropdown.tsx +++ b/sections/futures/Trade/MarketsDropdown.tsx @@ -157,6 +157,7 @@ const MarketsDropdown: React.FC = ({ mobile }) => { return (