From 3e3a2a1a9d624339a30fc2c6b5784723c8785cbc Mon Sep 17 00:00:00 2001 From: chambaz Date: Tue, 26 Nov 2024 17:33:11 -0500 Subject: [PATCH] fix: default to checking isLending against usdValues --- packages/marginfi-v2-ui-state/src/lib/mrgnlend.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/marginfi-v2-ui-state/src/lib/mrgnlend.ts b/packages/marginfi-v2-ui-state/src/lib/mrgnlend.ts index 55b72194b9..d7275d77f3 100644 --- a/packages/marginfi-v2-ui-state/src/lib/mrgnlend.ts +++ b/packages/marginfi-v2-ui-state/src/lib/mrgnlend.ts @@ -398,7 +398,12 @@ export function makeLendingPosition( const amounts = balance.computeQuantity(bank); const usdValues = balance.computeUsdValue(bank, oraclePrice, MarginRequirementType.Equity); const weightedUSDValues = balance.getUsdValueWithPriceBias(bank, oraclePrice, MarginRequirementType.Maintenance); - const isLending = balance.assetShares.gt(balance.liabilityShares); + + // default to checking against usdValues to account for active positions with zero asset / liab shares + // if token has been sunset and oracle set to 0 check against shares instead + const isLending = oraclePrice.priceRealtime.price.isZero() + ? balance.assetShares.gt(balance.liabilityShares) + : usdValues.liabilities.isZero(); const amount = isLending ? nativeToUi(amounts.assets.integerValue(BigNumber.ROUND_DOWN).toNumber(), bankInfo.mintDecimals)