Skip to content

Commit

Permalink
fix: small bug of state not being ready & handle empty portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
k0beLeenders committed Dec 9, 2024
1 parent 8a312be commit c2d9c18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/marginfi-v2-trading/src/pages/portfolio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function PortfolioPage() {
<div className="w-full max-w-4xl mx-auto px-4 md:px-0">
<PageHeading heading="Portfolio" body={<p>Manage your positions in the arena.</p>} links={[]} />
</div>
{!shortPositions ? (
{portfolioCombined.length === 0 ? (
<p className="text-center mt-4">
You do not have any open positions.
<br className="md:hidden" />{" "}
Expand Down
12 changes: 6 additions & 6 deletions apps/marginfi-v2-trading/src/store/tradeStoreV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -911,16 +911,16 @@ const sortPools = (
const bIndex = timestampOrder.indexOf(b.groupPk.toBase58());
return aIndex - bIndex;
} else if (sortBy.startsWith("price-movement")) {
const aPrice = Math.abs(aTokenData.priceChange24h ?? 0);
const bPrice = Math.abs(bTokenData.priceChange24h ?? 0);
const aPrice = Math.abs(aTokenData?.priceChange24h ?? 0);
const bPrice = Math.abs(bTokenData?.priceChange24h ?? 0);
return sortBy === TradePoolFilterStates.PRICE_MOVEMENT_ASC ? aPrice - bPrice : bPrice - aPrice;
} else if (sortBy.startsWith("market-cap")) {
const aMarketCap = aTokenData.marketcap ?? 0;
const bMarketCap = bTokenData.marketcap ?? 0;
const aMarketCap = aTokenData?.marketcap ?? 0;
const bMarketCap = bTokenData?.marketcap ?? 0;
return sortBy === TradePoolFilterStates.MARKET_CAP_ASC ? aMarketCap - bMarketCap : bMarketCap - aMarketCap;
} else if (sortBy.startsWith("liquidity")) {
const aLiquidity = aBankData.info.state.totalDeposits ?? 0;
const bLiquidity = bBankData.info.state.totalDeposits ?? 0;
const aLiquidity = aBankData?.info.state.totalDeposits ?? 0;
const bLiquidity = bBankData?.info.state.totalDeposits ?? 0;
return sortBy === TradePoolFilterStates.LIQUIDITY_ASC ? aLiquidity - bLiquidity : bLiquidity - aLiquidity;
} else if (sortBy.startsWith("apy")) {
// todo add apy filter
Expand Down

0 comments on commit c2d9c18

Please sign in to comment.