MigrationDisabledTooltip.tsx
1 import { ExclamationIcon } from '@heroicons/react/outline'; 2 import { Trans } from '@lingui/macro'; 3 import { Typography } from '@mui/material'; 4 import { ReactNode } from 'react'; 5 import { MigrationDisabled } from 'src/store/v3MigrationSelectors'; 6 7 import { Link } from '../primitives/Link'; 8 import { TextWithTooltip } from '../TextWithTooltip'; 9 10 interface MigrationDisabledTooltipProps { 11 dashboardLink?: string; 12 marketName?: string; 13 warningType: MigrationDisabled; 14 isolatedV3?: boolean; 15 } 16 17 export const MigrationDisabledTooltip = ({ 18 dashboardLink, 19 marketName, 20 warningType, 21 isolatedV3, 22 }: MigrationDisabledTooltipProps) => { 23 const warningText: Record<MigrationDisabled, ReactNode> = { 24 [MigrationDisabled.EModeBorrowDisabled]: ( 25 <Trans> 26 Asset cannot be migrated to {marketName} V3 Market due to E-mode restrictions. You can 27 disable or manage E-mode categories in your{' '} 28 <Link href={dashboardLink || ''} target="_blank" underline="always"> 29 V3 Dashboard 30 </Link> 31 </Trans> 32 ), 33 [MigrationDisabled.AssetNotFlashloanable]: ( 34 <Trans>Flashloan is disabled for this asset, hence this position cannot be migrated.</Trans> 35 ), 36 [MigrationDisabled.InsufficientLiquidity]: ( 37 <Trans> 38 Asset cannot be migrated due to insufficient liquidity or borrow cap limitation in{' '} 39 {marketName} v3 market. 40 </Trans> 41 ), 42 [MigrationDisabled.NotEnoughtSupplies]: ( 43 <Trans> 44 Asset cannot be migrated due to supply cap restriction in {marketName} v3 market. 45 </Trans> 46 ), 47 [MigrationDisabled.ReserveFrozen]: ( 48 <Trans> 49 Asset is frozen in {marketName} v3 market, hence this position cannot be migrated. 50 </Trans> 51 ), 52 [MigrationDisabled.IsolationModeBorrowDisabled]: isolatedV3 ? ( 53 <Trans> 54 Asset cannot be migrated because you have isolated collateral in {marketName} v3 Market 55 which limits borrowable assets. You can manage your collateral in{' '} 56 <Link href={dashboardLink || ''} target="_blank" underline="always"> 57 {marketName} V3 Dashboard 58 </Link>{' '} 59 </Trans> 60 ) : ( 61 <Trans> 62 Asset cannot be migrated to {marketName} v3 Market since collateral asset will enable 63 isolation mode. 64 </Trans> 65 ), 66 [MigrationDisabled.V3AssetMissing]: ( 67 <Trans> 68 Underlying asset does not exist in {marketName} v3 Market, hence this position cannot be 69 migrated. 70 </Trans> 71 ), 72 }; 73 74 return ( 75 <TextWithTooltip iconSize={16} color="error.main" icon={<ExclamationIcon />}> 76 <Typography variant="caption" color="text.secondary"> 77 {warningText[warningType]} 78 </Typography> 79 </TextWithTooltip> 80 ); 81 };