Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
xieqian committed Jan 20, 2024
1 parent 72b9551 commit 45e415b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion redux/selectors/getCollateralAmount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { shrinkToken, PERCENT_DIGITS } from "../../store";
import { RootState } from "../store";
import { hasAssets } from "../utils";
import { toDecimal } from "../../utils/uiNumber";
import { lpTokenPrefix, DEFAULT_POSITION } from "../../utils/config";

export const getCollateralAmount = (tokenId: string) =>
createSelector(
Expand All @@ -12,7 +13,8 @@ export const getCollateralAmount = (tokenId: string) =>
(assets, account) => {
if (!hasAssets(assets)) return "0";
const { metadata, config } = assets.data[tokenId];
const collateral = account.portfolio.positions[tokenId]?.collateral?.[tokenId];
const position = tokenId.indexOf(lpTokenPrefix) > -1 ? tokenId : DEFAULT_POSITION;
const collateral = account.portfolio.positions[position]?.collateral?.[tokenId];
if (!collateral) return "0";
return toDecimal(
shrinkToken(
Expand Down

0 comments on commit 45e415b

Please sign in to comment.