From 96249ef530a95fe13265dfb144c2cd26c0af040e Mon Sep 17 00:00:00 2001 From: Tom Robiquet Date: Tue, 30 Jan 2024 13:23:26 +0200 Subject: [PATCH] comment 0 balance filtering --- components/portfolio/MarketPositions.tsx | 193 +++++++++++------------ pages/portfolio/[address].tsx | 10 +- 2 files changed, 100 insertions(+), 103 deletions(-) diff --git a/components/portfolio/MarketPositions.tsx b/components/portfolio/MarketPositions.tsx index a62dd09cc..df543f970 100644 --- a/components/portfolio/MarketPositions.tsx +++ b/components/portfolio/MarketPositions.tsx @@ -170,103 +170,102 @@ export const MarketPositions = ({ ); }; - if (positions.some(displayBalance)) { - return ( -
- - displayBalance(pos)) - .map( - ({ - assetId, - price, - userBalance, - outcome, - changePercentage, - market, - avgCost, - rpnl, - upnl, - }) => { - const baseAssetUsdPrice = lookUpAssetPrice( - market.baseAsset, - foreignAssetPrices, - usdZtgPrice, - ); - return { - outcome: outcome, - userBalance: userBalance.div(ZTG).toNumber(), - price: { - value: price.toNumber(), - usdValue: price.mul(baseAssetUsdPrice ?? 0).toNumber(), - }, - cost: { - value: avgCost, - usdValue: new Decimal(avgCost) - .mul(baseAssetUsdPrice ?? 0) - .toNumber(), - }, - upnl: { - value: upnl, - usdValue: new Decimal(upnl) - .mul(baseAssetUsdPrice ?? 0) - .toNumber(), - }, - rpnl: { - value: rpnl, - usdValue: new Decimal(rpnl) - .mul(baseAssetUsdPrice ?? 0) - .toNumber(), - }, - value: { - value: userBalance.mul(price).div(ZTG).toNumber(), - usdValue: userBalance - .mul(price) - .mul(baseAssetUsdPrice ?? 0) - .div(ZTG) - .toNumber(), - }, - change: isNaN(changePercentage) - ? 0 - : changePercentage.toFixed(1), - actions: ( -
- {IOPoolShareAssetId.is(assetId) ? ( - - ) : marketStage?.type === "Trading" && - IOMarketOutcomeAssetId.is(assetId) ? ( - - ) : marketStage?.type === "Resolved" ? ( - - ) : IOMarketOutcomeAssetId.is(assetId) && - marketStage?.type === "Reported" ? ( - - ) : IOMarketOutcomeAssetId.is(assetId) && - (marketStage?.type === "OpenReportingPeriod" || - (marketStage?.type === "OracleReportingPeriod" && - isOracle)) ? ( - - ) : ( - "" - )} -
- ), - }; - }, - )} - /> - - ); - } + // if (positions.some(displayBalance)) { + return ( +
+ +
displayBalance(pos)) + .map( + ({ + assetId, + price, + userBalance, + outcome, + changePercentage, + market, + avgCost, + rpnl, + upnl, + }) => { + const baseAssetUsdPrice = lookUpAssetPrice( + market.baseAsset, + foreignAssetPrices, + usdZtgPrice, + ); + return { + outcome: outcome, + userBalance: userBalance.div(ZTG).toNumber(), + price: { + value: price.toNumber(), + usdValue: price.mul(baseAssetUsdPrice ?? 0).toNumber(), + }, + cost: { + value: avgCost, + usdValue: new Decimal(avgCost) + .mul(baseAssetUsdPrice ?? 0) + .toNumber(), + }, + upnl: { + value: upnl, + usdValue: new Decimal(upnl) + .mul(baseAssetUsdPrice ?? 0) + .toNumber(), + }, + rpnl: { + value: rpnl, + usdValue: new Decimal(rpnl) + .mul(baseAssetUsdPrice ?? 0) + .toNumber(), + }, + value: { + value: userBalance.mul(price).div(ZTG).toNumber(), + usdValue: userBalance + .mul(price) + .mul(baseAssetUsdPrice ?? 0) + .div(ZTG) + .toNumber(), + }, + change: isNaN(changePercentage) + ? 0 + : changePercentage.toFixed(1), + actions: ( +
+ {IOPoolShareAssetId.is(assetId) ? ( + + ) : marketStage?.type === "Trading" && + IOMarketOutcomeAssetId.is(assetId) ? ( + + ) : marketStage?.type === "Resolved" ? ( + + ) : IOMarketOutcomeAssetId.is(assetId) && + marketStage?.type === "Reported" ? ( + + ) : IOMarketOutcomeAssetId.is(assetId) && + (marketStage?.type === "OpenReportingPeriod" || + (marketStage?.type === "OracleReportingPeriod" && + isOracle)) ? ( + + ) : ( + "" + )} +
+ ), + }; + }, + )} + /> + + ); return <>; }; diff --git a/pages/portfolio/[address].tsx b/pages/portfolio/[address].tsx index c4b519f08..96e5d9c8f 100644 --- a/pages/portfolio/[address].tsx +++ b/pages/portfolio/[address].tsx @@ -137,9 +137,9 @@ const Portfolio: NextPageWithLayout = () => { (marketPositions) => { const market = marketPositions[0].market; - marketPositions = marketPositions.filter((position) => - position.userBalance.gt(0), - ); + // marketPositions = marketPositions.filter((position) => + // position.userBalance.gt(0), + // ); if ( market.status === "Resolved" && @@ -160,9 +160,7 @@ const Portfolio: NextPageWithLayout = () => { className="mb-8" market={market} usdZtgPrice={ztgPrice} - positions={marketPositions.filter((position) => - position.userBalance.gt(0), - )} + positions={marketPositions} /> ); },