Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling refs/heads/staging into test-staging #2217

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 96 additions & 97 deletions components/portfolio/MarketPositions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,103 +170,102 @@ export const MarketPositions = ({
);
};

if (positions.some(displayBalance)) {
return (
<div className={`${className}`}>
<MarketPositionHeader
marketId={market.marketId}
question={market.question ?? undefined}
/>
<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}
/>
<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: 4 additions & 6 deletions pages/portfolio/[address].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand All @@ -160,9 +160,7 @@ const Portfolio: NextPageWithLayout = () => {
className="mb-8"
market={market}
usdZtgPrice={ztgPrice}
positions={marketPositions.filter((position) =>
position.userBalance.gt(0),
)}
positions={marketPositions}
/>
);
},
Expand Down
Loading