diff --git a/src/components/transactions/Emode/EmodeModalContent.tsx b/src/components/transactions/Emode/EmodeModalContent.tsx index ac86c11c4b..816997b8dc 100644 --- a/src/components/transactions/Emode/EmodeModalContent.tsx +++ b/src/components/transactions/Emode/EmodeModalContent.tsx @@ -28,6 +28,7 @@ import { Link } from 'src/components/primitives/Link'; import { Row } from 'src/components/primitives/Row'; import { TokenIcon } from 'src/components/primitives/TokenIcon'; import { Warning } from 'src/components/primitives/Warning'; +import { EmodeCategory } from 'src/helpers/types'; import { ExtendedFormattedUser, useAppDataContext, @@ -36,7 +37,6 @@ import { useCurrentTimestamp } from 'src/hooks/useCurrentTimestamp'; import { useModalContext } from 'src/hooks/useModal'; import { useProtocolDataContext } from 'src/hooks/useProtocolDataContext'; import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; -import { NewEModeCategory } from 'src/store/poolSelectors'; import { getNetworkConfig } from 'src/utils/marketsAndNetworksConfig'; import { TxErrorView } from '../FlowCommons/Error'; @@ -52,12 +52,12 @@ export enum ErrorType { CLOSE_POSITIONS_BEFORE_SWITCHING, } -export type EModeCategoryDisplay = NewEModeCategory & { +export type EModeCategoryDisplay = EmodeCategory & { available: boolean; // indicates if the user can enter this category }; // An E-Mode category is available if the user has no borrow positions outside of the category -function isEModeCategoryAvailable(user: ExtendedFormattedUser, eMode: NewEModeCategory): boolean { +function isEModeCategoryAvailable(user: ExtendedFormattedUser, eMode: EmodeCategory): boolean { const borrowableReserves = eMode.assets .filter((asset) => asset.borrowable) .map((asset) => asset.underlyingAsset); diff --git a/src/components/transactions/Emode/EmodeSelect.tsx b/src/components/transactions/Emode/EmodeSelect.tsx deleted file mode 100644 index cab71e9a03..0000000000 --- a/src/components/transactions/Emode/EmodeSelect.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import { Trans } from '@lingui/macro'; -import { FormLabel, Typography } from '@mui/material'; -import FormControl from '@mui/material/FormControl'; -import MenuItem from '@mui/material/MenuItem'; -import Select from '@mui/material/Select'; -import * as React from 'react'; -import { EmodeCategory } from 'src/helpers/types'; - -import { getEmodeMessage } from './EmodeNaming'; - -export type EmodeSelectProps = { - emodeCategories: Record; - selectedEmode: number | undefined; - setSelectedEmode: React.Dispatch>; - userEmode: number; -}; - -export const EmodeSelect = ({ - emodeCategories, - selectedEmode, - setSelectedEmode, - userEmode, -}: EmodeSelectProps) => { - return ( - - - Asset category - - - - - ); -}; diff --git a/src/helpers/types.ts b/src/helpers/types.ts index b4be6d910f..616c3f5825 100644 --- a/src/helpers/types.ts +++ b/src/helpers/types.ts @@ -15,12 +15,16 @@ export type Reward = { export type EmodeCategory = { id: number; - ltv: number; - liquidationThreshold: number; - liquidationBonus: number; - priceSource: string; label: string; - assets: string[]; + ltv: string; + liquidationThreshold: string; + liquidationBonus: string; + assets: Array<{ + underlyingAsset: string; + symbol: string; + collateral: boolean; + borrowable: boolean; + }>; }; export enum CollateralType { diff --git a/src/hooks/app-data-provider/useAppDataProvider.tsx b/src/hooks/app-data-provider/useAppDataProvider.tsx index d5dd448d27..9729770973 100644 --- a/src/hooks/app-data-provider/useAppDataProvider.tsx +++ b/src/hooks/app-data-provider/useAppDataProvider.tsx @@ -7,11 +7,12 @@ import { } from '@aave/math-utils'; import { formatUnits } from 'ethers/lib/utils'; import React, { useContext } from 'react'; +import { EmodeCategory } from 'src/helpers/types'; import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; import { useRootStore } from 'src/store/root'; import { GHO_MINTING_MARKETS } from 'src/utils/ghoUtilities'; -import { formatEmodes, NewEModeCategory } from '../../store/poolSelectors'; +import { formatEmodes } from '../../store/poolSelectors'; import { ExtendedFormattedUser as _ExtendedFormattedUser, useExtendedUserSummaryAndIncentives, @@ -53,7 +54,7 @@ export type ExtendedFormattedUser = _ExtendedFormattedUser; export interface AppDataContextType { loading: boolean; reserves: ComputedReserveData[]; - eModes: Record; + eModes: Record; user?: ExtendedFormattedUser; marketReferencePriceInUsd: string; marketReferenceCurrencyDecimals: number; diff --git a/src/store/poolSelectors.ts b/src/store/poolSelectors.ts index 99bb5ecf2e..01a5779b30 100644 --- a/src/store/poolSelectors.ts +++ b/src/store/poolSelectors.ts @@ -1,23 +1,9 @@ +import { EmodeCategory } from 'src/helpers/types'; import { FormattedReservesAndIncentives } from 'src/hooks/pool/usePoolFormattedReserves'; import { CustomMarket, marketsData, NetworkConfig } from 'src/utils/marketsAndNetworksConfig'; import { PoolReserve } from './poolSlice'; -// TODO: refactor existing utils type EmodeCategory -export type NewEModeCategory = { - id: number; - label: string; - ltv: string; - liquidationThreshold: string; - liquidationBonus: string; - assets: Array<{ - underlyingAsset: string; - symbol: string; - collateral: boolean; - borrowable: boolean; - }>; -}; - export const selectCurrentChainIdMarkets = ( chainId: number, currentNetworkConfig: NetworkConfig @@ -65,7 +51,7 @@ export const reserveSortFn = ( }; export const formatEmodes = (reserves: FormattedReservesAndIncentives[]) => { - const eModes: Record = {}; + const eModes: Record = {}; reserves.forEach((r) => { r.eModes.forEach((e) => {