diff --git a/src/domain/synthetics/markets/types.ts b/src/domain/synthetics/markets/types.ts index e0d0477938..d643786a53 100644 --- a/src/domain/synthetics/markets/types.ts +++ b/src/domain/synthetics/markets/types.ts @@ -102,6 +102,11 @@ export type MarketInfo = Market & borrowingFactorPerSecondForLongs: bigint; borrowingFactorPerSecondForShorts: bigint; + pnlLongMax?: bigint; + pnlShortMax?: bigint; + pnlLongMin?: bigint; + pnlShortMin?: bigint; + fundingFactorPerSecond: bigint; longsPayShorts: boolean; diff --git a/src/domain/synthetics/markets/useMarketsInfoRequest/index.ts b/src/domain/synthetics/markets/useMarketsInfoRequest/index.ts index bc5c579c43..09bb55c5d9 100644 --- a/src/domain/synthetics/markets/useMarketsInfoRequest/index.ts +++ b/src/domain/synthetics/markets/useMarketsInfoRequest/index.ts @@ -47,6 +47,10 @@ type MarketValues = Pick< | "virtualPoolAmountForLongToken" | "virtualPoolAmountForShortToken" | "virtualInventoryForPositions" + | "pnlLongMax" + | "pnlShortMax" + | "pnlLongMin" + | "pnlShortMin" >; /** @@ -393,6 +397,11 @@ function useMarketsValuesRequest({ borrowingFactorPerSecondForLongs: readerValues.marketInfo.returnValues.borrowingFactorPerSecondForLongs, borrowingFactorPerSecondForShorts: readerValues.marketInfo.returnValues.borrowingFactorPerSecondForShorts, + pnlLongMax: poolValueInfoMax.longPnl, + pnlShortMax: poolValueInfoMax.shortPnl, + pnlLongMin: poolValueInfoMin.longPnl, + pnlShortMin: poolValueInfoMin.shortPnl, + fundingFactorPerSecond: nextFunding.fundingFactorPerSecond, longsPayShorts: nextFunding.longsPayShorts, diff --git a/src/domain/synthetics/markets/utils.ts b/src/domain/synthetics/markets/utils.ts index 45b974565b..e2b061f450 100644 --- a/src/domain/synthetics/markets/utils.ts +++ b/src/domain/synthetics/markets/utils.ts @@ -266,6 +266,17 @@ export function getPriceForPnl(prices: TokenPrices, isLong: boolean, maximize: b } export function getMarketPnl(marketInfo: MarketInfo, isLong: boolean, maximize: boolean) { + let res: bigint | undefined = undefined; + if (maximize) { + res = isLong ? marketInfo.pnlLongMax : marketInfo.pnlShortMax; + } else { + res = isLong ? marketInfo.pnlLongMin : marketInfo.pnlShortMin; + } + + if (res !== undefined) { + return res; + } + const openInterestUsd = getOpenInterestUsd(marketInfo, isLong); const openInterestInTokens = getOpenInterestInTokens(marketInfo, isLong);