Skip to content

Commit

Permalink
Revert "comment 0 balance filtering"
Browse files Browse the repository at this point in the history
This reverts commit 96249ef.
  • Loading branch information
Robiquet committed Mar 25, 2024
1 parent 299e178 commit 6e2d23c
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 102 deletions.
2 changes: 1 addition & 1 deletion components/portfolio/Breakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const PortfolioBreakdown = (props: PortfolioBreakdownProps) => {
title="Liquidity"
value={poolZtgTotal?.mul(ZTG) ?? new Decimal(0)}
usdZtgPrice={props.usdZtgPrice}
changePercentage={props.subsidy.changePercentage}
changePercentage={0}
/>
)}
</div>
Expand Down
195 changes: 98 additions & 97 deletions components/portfolio/MarketPositions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,103 +170,104 @@ export const MarketPositions = ({
);
};

// if (positions.some(displayBalance)) {
return (
<div className={`${className}`}>
<MarketPositionHeader
marketId={market.marketId}
question={market.question ?? undefined}
baseAsset={market.baseAsset}
/>
<Table
showHighlight={false}
columns={isLiquidityMarket ? COLUMNS_LIQUIDITY : COLUMNS}
data={positions
// .filter((pos) => displayBalance(pos))
.map<TableData>(
({
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: (
<div className="text-right">
{IOPoolShareAssetId.is(assetId) ? (
<PoolShareButtons
poolId={assetId.PoolShare}
market={market}
/>
) : marketStage?.type === "Trading" &&
IOMarketOutcomeAssetId.is(assetId) ? (
<AssetTradingButtons assetId={assetId} />
) : marketStage?.type === "Resolved" ? (
<RedeemButton market={market} assetId={assetId} />
) : IOMarketOutcomeAssetId.is(assetId) &&
marketStage?.type === "Reported" ? (
<DisputeButton market={market} assetId={assetId} />
) : IOMarketOutcomeAssetId.is(assetId) &&
(marketStage?.type === "OpenReportingPeriod" ||
(marketStage?.type === "OracleReportingPeriod" &&
isOracle)) ? (
<ReportButton market={market} assetId={assetId} />
) : (
""
)}
</div>
),
};
},
)}
/>
</div>
);
if (positions.some(displayBalance)) {
return (
<div className={`${className}`}>
<MarketPositionHeader
marketId={market.marketId}
question={market.question ?? undefined}
baseAsset={market.baseAsset}
/>
<Table
showHighlight={false}
columns={isLiquidityMarket ? COLUMNS_LIQUIDITY : COLUMNS}
data={positions
.filter((pos) => displayBalance(pos))
.map<TableData>(
({
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: (
<div className="text-right">
{IOPoolShareAssetId.is(assetId) ? (
<PoolShareButtons
poolId={assetId.PoolShare}
market={market}
/>
) : marketStage?.type === "Trading" &&
IOMarketOutcomeAssetId.is(assetId) ? (
<AssetTradingButtons assetId={assetId} />
) : marketStage?.type === "Resolved" ? (
<RedeemButton market={market} assetId={assetId} />
) : IOMarketOutcomeAssetId.is(assetId) &&
marketStage?.type === "Reported" ? (
<DisputeButton market={market} assetId={assetId} />
) : IOMarketOutcomeAssetId.is(assetId) &&
(marketStage?.type === "OpenReportingPeriod" ||
(marketStage?.type === "OracleReportingPeriod" &&
isOracle)) ? (
<ReportButton market={market} assetId={assetId} />
) : (
""
)}
</div>
),
};
},
)}
/>
</div>
);
}

return <></>;
};
Expand Down
10 changes: 6 additions & 4 deletions pages/portfolio/[address].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,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" &&
Expand All @@ -161,7 +161,9 @@ const Portfolio: NextPageWithLayout = () => {
className="mb-8"
market={market}
usdZtgPrice={ztgPrice}
positions={marketPositions}
positions={marketPositions.filter((position) =>
position.userBalance.gt(0),
)}
/>
);
},
Expand Down

0 comments on commit 6e2d23c

Please sign in to comment.