Skip to content

Commit

Permalink
feat: etherfi market [skip cypress] (#2172)
Browse files Browse the repository at this point in the history
  • Loading branch information
grothem authored Sep 9, 2024
1 parent 2b64400 commit df8a2c7
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 402 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"dependencies": {
"@aave/contract-helpers": "1.30.2",
"@aave/math-utils": "1.30.2",
"@bgd-labs/aave-address-book": "^3.0.1",
"@bgd-labs/aave-address-book": "^3.2.1",
"@emotion/cache": "11.10.3",
"@emotion/react": "11.10.4",
"@emotion/server": "latest",
Expand Down
1 change: 1 addition & 0 deletions public/icons/markets/etherfi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/markets/lido.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 35 additions & 61 deletions src/components/MarketSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@ import {
import StyledToggleButton from './StyledToggleButton';
import StyledToggleButtonGroup from './StyledToggleButtonGroup';

export const MULTIPLE_MARKET_OPTIONS = [
CustomMarket.proto_mainnet_v3,
CustomMarket.proto_lido_v3,
'fork_proto_lido_v3',
'fork_proto_mainnet_v3',
];

export const getMarketInfoById = (marketId: CustomMarket) => {
const market: MarketDataType = marketsData[marketId as CustomMarket];
const network: BaseNetworkConfig = networkConfigs[market.chainId];
const logo = market.logo || network.networkLogoPath;

return { market, network };
return { market, logo };
};

export const getMarketHelpData = (marketName: string) => {
Expand All @@ -55,16 +49,9 @@ export const getMarketHelpData = (marketName: string) => {
'Kovan',
'Rinkeby',
];

const arrayName = marketName.split(' ');

const testChainName = arrayName.filter((el) => testChains.indexOf(el) > -1);

const marketTitle =
// Note: We keep Eth for Lido market and fetch Lido market data
marketName === 'Ethereum Lido Market'
? 'Ethereum'
: arrayName.filter((el) => !testChainName.includes(el)).join(' ');
const marketTitle = arrayName.filter((el) => !testChainName.includes(el)).join(' ');

return {
name: marketTitle,
Expand Down Expand Up @@ -168,13 +155,13 @@ export const MarketSwitcher = () => {
</SvgIcon>
),
renderValue: (marketId) => {
const { market, network } = getMarketInfoById(marketId as CustomMarket);
const { market, logo } = getMarketInfoById(marketId as CustomMarket);

return (
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<MarketLogo
size={upToLG ? 32 : 28}
logo={network.networkLogoPath}
logo={logo}
testChainName={getMarketHelpData(market.marketTitle).testChainName}
/>
<Box sx={{ mr: 1, display: 'inline-flex', alignItems: 'flex-start' }}>
Expand All @@ -187,8 +174,7 @@ export const MarketSwitcher = () => {
}}
>
{getMarketHelpData(market.marketTitle).name} {market.isFork ? 'Fork' : ''}
{/* {upToLG && ' Market'} */}
{upToLG && ''}
{upToLG && ' Market'}
</Typography>
{market.v3 ? (
<Box
Expand Down Expand Up @@ -331,47 +317,35 @@ export const MarketSwitcher = () => {
</StyledToggleButtonGroup>
</Box>
)}
{availableMarkets
.filter((marketId: CustomMarket) => {
const { market } = getMarketInfoById(marketId);

const excludedDropdownMarkets = ['proto_lido_v3'];

return !excludedDropdownMarkets.includes(marketId) && market;
})
.map((marketId: CustomMarket) => {
const { market, network } = getMarketInfoById(marketId);
const marketNaming = getMarketHelpData(market.marketTitle);
return (
<MenuItem
key={marketId}
data-cy={`marketSelector_${marketId}`}
value={marketId}
sx={{
'.MuiListItemIcon-root': { minWidth: 'unset' },
display:
(market.v3 && selectedMarketVersion === SelectedMarketVersion.V2) ||
(!market.v3 && selectedMarketVersion === SelectedMarketVersion.V3)
? 'none'
: 'flex',
}}
>
<MarketLogo
size={32}
logo={network.networkLogoPath}
testChainName={marketNaming.testChainName}
/>
<ListItemText sx={{ mr: 0 }}>
{marketNaming.name} {market.isFork ? 'Fork' : ''}
</ListItemText>
<ListItemText sx={{ textAlign: 'right' }}>
<Typography color="text.muted" variant="description">
{marketNaming.testChainName}
</Typography>
</ListItemText>
</MenuItem>
);
})}
{availableMarkets.map((marketId: CustomMarket) => {
const { market, logo } = getMarketInfoById(marketId);
const marketNaming = getMarketHelpData(market.marketTitle);
return (
<MenuItem
key={marketId}
data-cy={`marketSelector_${marketId}`}
value={marketId}
sx={{
'.MuiListItemIcon-root': { minWidth: 'unset' },
display:
(market.v3 && selectedMarketVersion === SelectedMarketVersion.V2) ||
(!market.v3 && selectedMarketVersion === SelectedMarketVersion.V3)
? 'none'
: 'flex',
}}
>
<MarketLogo size={32} logo={logo} testChainName={marketNaming.testChainName} />
<ListItemText sx={{ mr: 0 }}>
{marketNaming.name} {market.isFork ? 'Fork' : ''}
</ListItemText>
<ListItemText sx={{ textAlign: 'right' }}>
<Typography color="text.muted" variant="description">
{marketNaming.testChainName}
</Typography>
</ListItemText>
</MenuItem>
);
})}
</TextField>
);
};
111 changes: 50 additions & 61 deletions src/components/StyledToggleButton.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,58 @@
import { styled, ToggleButton, ToggleButtonProps } from '@mui/material';
import React from 'react';

interface CustomToggleButtonProps extends ToggleButtonProps {
unselectedBackgroundColor?: string;
maxWidth?: string;
}

const CustomToggleButton = styled(ToggleButton)<CustomToggleButtonProps>(
({ theme, unselectedBackgroundColor }) => ({
border: '0px',
flex: 1,
backgroundColor: unselectedBackgroundColor || '#383D51',
borderRadius: '4px',

'&.Mui-selected, &.Mui-selected:hover': {
backgroundColor: '#FFFFFF',
borderRadius: '4px !important',
const CustomToggleButton = styled(ToggleButton)<ToggleButtonProps>(({ theme }) => ({
border: '0px',
flex: 1,
backgroundColor: '#383D51',
borderRadius: '4px',

'&.Mui-selected, &.Mui-selected:hover': {
backgroundColor: '#FFFFFF',
borderRadius: '4px !important',
},

'&.Mui-selected, &.Mui-disabled': {
zIndex: 100,
height: '100%',
display: 'flex',
justifyContent: 'center',

'.MuiTypography-subheader1': {
background: theme.palette.gradients.aaveGradient,
backgroundClip: 'text',
textFillColor: 'transparent',
},

'&.Mui-selected, &.Mui-disabled': {
zIndex: 100,
height: '100%',
display: 'flex',
justifyContent: 'center',

'.MuiTypography-subheader1': {
background: theme.palette.gradients.aaveGradient,
backgroundClip: 'text',
textFillColor: 'transparent',
},
'.MuiTypography-secondary14': {
background: theme.palette.gradients.aaveGradient,
backgroundClip: 'text',
textFillColor: 'transparent',
},
'.MuiTypography-secondary14': {
background: theme.palette.gradients.aaveGradient,
backgroundClip: 'text',
textFillColor: 'transparent',
},
})
) as typeof ToggleButton;

const CustomTxModalToggleButton = styled(ToggleButton)<CustomToggleButtonProps>(
({ theme, unselectedBackgroundColor, maxWidth }) => ({
border: '0px',
flex: 1,
color: theme.palette.text.muted,
borderRadius: '4px',
backgroundColor: unselectedBackgroundColor || '#383D51',
maxWidth: maxWidth || '100%',

'&.Mui-selected, &.Mui-selected:hover': {
border: `1px solid ${theme.palette.other.standardInputLine}`,
backgroundColor: '#FFFFFF',
borderRadius: '4px !important',
},

'&.Mui-selected, &.Mui-disabled': {
zIndex: 100,
height: '100%',
display: 'flex',
justifyContent: 'center',
color: theme.palette.background.header,
},
})
) as typeof ToggleButton;

export function StyledTxModalToggleButton(props: CustomToggleButtonProps) {
},
})) as typeof ToggleButton;

const CustomTxModalToggleButton = styled(ToggleButton)<ToggleButtonProps>(({ theme }) => ({
border: '0px',
flex: 1,
color: theme.palette.text.muted,
borderRadius: '4px',

'&.Mui-selected, &.Mui-selected:hover': {
border: `1px solid ${theme.palette.other.standardInputLine}`,
backgroundColor: '#FFFFFF',
borderRadius: '4px !important',
},

'&.Mui-selected, &.Mui-disabled': {
zIndex: 100,
height: '100%',
display: 'flex',
justifyContent: 'center',
color: theme.palette.background.header,
},
})) as typeof ToggleButton;

export function StyledTxModalToggleButton(props: ToggleButtonProps) {
return <CustomTxModalToggleButton {...props} />;
}

Expand Down
3 changes: 0 additions & 3 deletions src/components/TopInfoPanel/TopInfoPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ interface TopInfoPanelProps extends PageTitleProps {
children?: ReactNode;
titleComponent?: ReactNode;
containerProps?: ContainerProps;
multiMarket?: boolean;
}

export const TopInfoPanel = ({
Expand All @@ -16,7 +15,6 @@ export const TopInfoPanel = ({
withMarketSwitcher,
withMigrateButton,
bridge,
multiMarket,
children,
containerProps = {},
}: TopInfoPanelProps) => {
Expand Down Expand Up @@ -49,7 +47,6 @@ export const TopInfoPanel = ({
gap: { xs: 3, xsm: 8 },
flexWrap: 'wrap',
width: '100%',
...(multiMarket && { flexDirection: 'column' }),
}}
>
{children}
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import { AppHeader } from './AppHeader';
import TopBarNotify from './TopBarNotify';

export function MainLayout({ children }: { children: ReactNode }) {
const APP_BANNER_VERSION = '1.0.0';
const APP_BANNER_VERSION = '2.0.0';

return (
<>
<TopBarNotify
learnMoreLink="/markets/?marketName=proto_lido_v3"
learnMoreLink="/markets/?marketName=proto_etherfi_v3"
buttonText="View Market"
notifyText="Aave Governance has deployed a new Lido market on Ethereum V3"
notifyText="Aave Governance has deployed a new EtherFi market on Ethereum V3"
bannerVersion={APP_BANNER_VERSION}
icon={'/icons/tokens/ldo.svg'}
icon={'/icons/markets/etherfi.svg'}
/>
<AppHeader />
<Box component="main" sx={{ display: 'flex', flexDirection: 'column', flex: 1 }}>
Expand Down
2 changes: 1 addition & 1 deletion src/locales/en/messages.js

Large diffs are not rendered by default.

20 changes: 0 additions & 20 deletions src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ msgstr "At a discount"
#: src/components/transactions/Withdraw/WithdrawModalContent.tsx
#: src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsList.tsx
#: src/modules/dashboard/lists/BorrowAssetsList/GhoBorrowAssetsListItem.tsx
#: src/modules/markets/MarketsTopPanel.tsx
msgid "Available"
msgstr "Available"

Expand Down Expand Up @@ -592,10 +591,6 @@ msgstr "Borrowing this amount will reduce your health factor and increase risk o
msgid "Borrowing {symbol}"
msgstr "Borrowing {symbol}"

#: src/modules/markets/MarketsTopPanel.tsx
msgid "Borrows"
msgstr "Borrows"

#: src/components/transactions/GovDelegation/DelegationTypeSelector.tsx
msgid "Both"
msgstr "Both"
Expand Down Expand Up @@ -1103,11 +1098,6 @@ msgstr "Estimated compounding interest, including discount for Staking {0}AAVE i
msgid "Estimated time"
msgstr "Estimated time"

#: src/modules/dashboard/DashboardContentWrapper.tsx
#: src/modules/markets/MarketsTopPanel.tsx
msgid "Ethereum Main"
msgstr "Ethereum Main"

#: src/modules/reserve-overview/Gho/GhoPieChartContainer.tsx
msgid "Exceeds the discount"
msgstr "Exceeds the discount"
Expand Down Expand Up @@ -1414,11 +1404,6 @@ msgstr "Learn more."
msgid "Let us know how we can make the app better for you. For user support related inquiries please reach out on"
msgstr "Let us know how we can make the app better for you. For user support related inquiries please reach out on"

#: src/modules/dashboard/DashboardContentWrapper.tsx
#: src/modules/markets/MarketsTopPanel.tsx
msgid "Lido"
msgstr "Lido"

#: src/modules/governance/RepresentativesInfoPanel.tsx
msgid "Linked addresses"
msgstr "Linked addresses"
Expand Down Expand Up @@ -1492,15 +1477,10 @@ msgstr "MAI has been paused due to a community decision. Supply, borrows and rep
msgid "MAX"
msgstr "MAX"

#: src/modules/markets/MarketsTopPanel.tsx
msgid "Main"
msgstr "Main"

#: src/layouts/AppFooter.tsx
msgid "Manage analytics"
msgstr "Manage analytics"

#: src/modules/markets/MarketsTopPanel.tsx
#: src/modules/reserve-overview/ReserveTopDetailsWrapper.tsx
msgid "Market"
msgstr "Market"
Expand Down
Loading

2 comments on commit df8a2c7

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit was deployed on ipfs

Please sign in to comment.