diff --git a/components/PositionsTable.tsx b/components/PositionsTable.tsx index 9c040916..dc371781 100644 --- a/components/PositionsTable.tsx +++ b/components/PositionsTable.tsx @@ -35,10 +35,21 @@ const PositionsTable = () => { [mangoGroup] ) const perpAccounts = mangoAccount - ? groupConfig.perpMarkets.map( - (m) => mangoAccount.perpAccounts[m.marketIndex] - ) + ? groupConfig.perpMarkets.map((m) => { + return { + perpAccount: mangoAccount.perpAccounts[m.marketIndex], + marketIndex: m.marketIndex, + } + }) : [] + const filteredPerpAccounts = perpAccounts.filter( + ({ perpAccount }) => + !( + perpAccount.quotePosition.eq(ZERO_I80F48) && + perpAccount.basePosition.eq(new BN(0)) + ) + ) + console.log('perp acc length', filteredPerpAccounts.length) const handleSettlePnl = async ( perpMarket: PerpMarket, @@ -81,7 +92,7 @@ const PositionsTable = () => {
- {marketConfig.name} - | -
- |
- - {perpMarket.baseLotsToNumber(perpAcc.basePosition)} - | -- {nativeI80F48ToUi( - perpAcc.quotePosition, - marketConfig.quoteDecimals - ).toFixed()} - | -- $ - {nativeI80F48ToUi( - perpAcc.getPnl(perpMarketInfo, price), - marketConfig.quoteDecimals - ).toFixed()} - | -- {perpAcc - .getHealth( - perpMarketInfo, - price, - perpMarketInfo.maintAssetWeight, - perpMarketInfo.maintLiabWeight, - marketCache.longFunding, - marketCache.shortFunding - ) - .toFixed(3)} - | -
-
- | + {perpMarket.baseLotsToNumber( + perpAccount.basePosition + )} + | ++ {nativeI80F48ToUi( + perpAccount.quotePosition, + marketConfig.quoteDecimals + ).toFixed()} + | ++ $ + {nativeI80F48ToUi( + perpAccount.getPnl(perpMarketInfo, price), + marketConfig.quoteDecimals + ).toFixed()} + | ++ {perpAccount + .getHealth( + perpMarketInfo, + price, + perpMarketInfo.maintAssetWeight, + perpMarketInfo.maintLiabWeight, + marketCache.longFunding, + marketCache.shortFunding + ) + .toFixed(3)} + | +
+
+
+
+ |
+
+ )
+ }
+ )}