Skip to content

Commit

Permalink
fix: default to checking isLending against usdValues
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Nov 27, 2024
1 parent 0728cac commit 3e3a2a1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/marginfi-v2-ui-state/src/lib/mrgnlend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3e3a2a1

Please sign in to comment.