diff --git a/src/components/transactions/Bridge/BridgeModalContent.tsx b/src/components/transactions/Bridge/BridgeModalContent.tsx index 15ab323e75..a3656c2cb3 100644 --- a/src/components/transactions/Bridge/BridgeModalContent.tsx +++ b/src/components/transactions/Bridge/BridgeModalContent.tsx @@ -1,5 +1,4 @@ import { ChainId } from '@aave/contract-helpers'; -import { AaveV3Monad } from '@aave-dao/aave-address-book'; import { ExternalLinkIcon, SwitchVerticalIcon } from '@heroicons/react/outline'; import { Trans } from '@lingui/macro'; import { @@ -57,18 +56,6 @@ import { useTimeToDestination } from './useGetFinalityTime'; const defaultNetwork = supportedNetworksWithBridge[0]; function getUseBridgeTokensParams(chainId: number): UseBridgeTokensParams { - const tokenOracle = getConfigFor(chainId).tokenOracle; - - if (chainId === 143) { - // no market config available yet for Monad, so values are set here - return { - chainId, - ghoTokenAddress: '0xfc421aD3C883Bf9E7C4f42dE845C4e4405799e73', - tokenOracle, - walletBalanceProviderAddress: AaveV3Monad.WALLET_BALANCE_PROVIDER, - }; - } - const market = Object.values(marketsData).filter( (md) => md.chainId === chainId && md.v3 === true && md.addresses.GHO_TOKEN_ADDRESS )[0]; @@ -79,7 +66,7 @@ function getUseBridgeTokensParams(chainId: number): UseBridgeTokensParams { return { chainId, ghoTokenAddress: market.addresses.GHO_TOKEN_ADDRESS, - tokenOracle, + tokenOracle: getConfigFor(chainId).tokenOracle, walletBalanceProviderAddress: market.addresses.WALLET_BALANCE_PROVIDER, }; } diff --git a/src/components/transactions/CollateralChange/CollateralChangeModalContent.tsx b/src/components/transactions/CollateralChange/CollateralChangeModalContent.tsx index f39bdc35b7..73c56f385f 100644 --- a/src/components/transactions/CollateralChange/CollateralChangeModalContent.tsx +++ b/src/components/transactions/CollateralChange/CollateralChangeModalContent.tsx @@ -10,6 +10,7 @@ import { import { useAssetCaps } from 'src/hooks/useAssetCaps'; import { useModalContext } from 'src/hooks/useModal'; import { useZeroLTVBlockingWithdraw } from 'src/hooks/useZeroLTVBlockingWithdraw'; +import { hasNonZeroEffectiveLtv } from 'src/utils/hfUtils'; import { GasEstimationError } from '../FlowCommons/GasEstimationError'; import { ModalWrapperProps } from '../FlowCommons/ModalWrapper'; @@ -49,9 +50,12 @@ export const CollateralChangeModalContent = ({ // Check if asset has non-zero LTV (base or in user's active e-mode) const userEMode = poolReserve.eModes?.find((e) => e.id === user?.userEmodeCategoryId); - const hasNonZeroLtv = - poolReserve.baseLTVasCollateral !== '0' || - (user?.isInEmode && userEMode?.collateralEnabled && !userEMode?.ltvzeroEnabled); + const hasNonZeroLtv = hasNonZeroEffectiveLtv({ + baseLTVasCollateral: poolReserve.baseLTVasCollateral, + isInEmode: !!user?.isInEmode, + emodeEntry: userEMode, + isEModeIsolated: !!eModes[user.userEmodeCategoryId]?.isolated, + }); // Find e-mode categories where this asset can be used as collateral with non-zero LTV const collateralEmodeCategories = diff --git a/src/components/transactions/Emode/EmodeModalContent.tsx b/src/components/transactions/Emode/EmodeModalContent.tsx index eeca1c6660..9133e59a8f 100644 --- a/src/components/transactions/Emode/EmodeModalContent.tsx +++ b/src/components/transactions/Emode/EmodeModalContent.tsx @@ -18,6 +18,7 @@ import { FormattedNumber } from 'src/components/primitives/FormattedNumber'; import { Link } from 'src/components/primitives/Link'; import { Row } from 'src/components/primitives/Row'; import { Warning } from 'src/components/primitives/Warning'; +import { TextWithTooltip } from 'src/components/TextWithTooltip'; import { EmodeCategory } from 'src/helpers/types'; import { ComputedReserveData, @@ -28,6 +29,7 @@ import { useCurrentTimestamp } from 'src/hooks/useCurrentTimestamp'; import { useModalContext } from 'src/hooks/useModal'; import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; import { useRootStore } from 'src/store/root'; +import { getEmodeAdjustedReserves } from 'src/utils/hfUtils'; import { getNetworkConfig } from 'src/utils/marketsAndNetworksConfig'; import { replaceUnderscoresWithSpaces } from 'src/utils/utils'; import { useShallow } from 'zustand/shallow'; @@ -96,7 +98,10 @@ function getEModeCategoryBlockReason( ) { zeroLtvCollateral.push(reserve.symbol); } else if (!reserveTargetEmode || !reserveTargetEmode.collateralEnabled) { - if (Number(reserve.baseLTVasCollateral) === 0) { + // v3.7 isolated eMode rule: assets outside the category's collateralBitmap are + // forced to 0 LTV regardless of their base LTV, so entry reverts on-chain + // (InvalidCollateralInEmode) unless this collateral is disabled first. + if (Number(reserve.baseLTVasCollateral) === 0 || eMode.isolated) { zeroLtvCollateral.push(reserve.symbol); } } @@ -172,11 +177,12 @@ export const EmodeModalContent = ({ user }: { user: ExtendedFormattedUser }) => const networkConfig = getNetworkConfig(currentChainId); // calcs + const targetEmodeId = disableEmode ? 0 : selectedEmode.id; const newSummary = formatUserSummary({ currentTimestamp, userReserves: userReserves, - formattedReserves: reserves, - userEmodeCategoryId: disableEmode ? 0 : selectedEmode.id, + formattedReserves: getEmodeAdjustedReserves(reserves, targetEmodeId, eModes), + userEmodeCategoryId: targetEmodeId, marketReferenceCurrencyDecimals, marketReferencePriceInUsd, }); @@ -393,9 +399,29 @@ export const EmodeModalContent = ({ user }: { user: ExtendedFormattedUser }) => - - Asset category - + + + Asset category + + {selectedEmode.isolated && ( + <> + + - + + Isolated} + variant="caption" + textColor="warning.main" + iconColor="warning.main" + > + + Only the listed collateral contributes borrowing power in this category — + other collateral you hold will have 0% LTV while it's active. + + + + )} +