Skip to content

Commit

Permalink
Merge pull request #1157 from yieldprotocol/feat/allowClosingPosition…
Browse files Browse the repository at this point in the history
…sAfterEulerHack

Limit Actions on series
  • Loading branch information
brucedonovan authored Mar 21, 2023
2 parents 1025c39 + 6e29301 commit 6fc7946
Show file tree
Hide file tree
Showing 27 changed files with 320 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ GENERATE_SOURCEMAP=false

ALLOWED_SUPPORT_ADDRESSES='0x1Bd3Abb6ef058408734EA01cA81D325039cd7bcA, '

KILLSWITCH_ACTIVE=true
KILLSWITCH_ACTIVE=false
KILLSWITCH_CHAIN=1
KILLSWITCH_TEXT='Due to an Euler Finance security incident, we are suspending UI interaction with the Yield Protocol until we have fully assessed the implications of the breach'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app-v2",
"version": "2.5.12",
"version": "2.5.13",
"private": true,
"dependencies": {
"@ethersproject/providers": "^5.6.8",
Expand Down
6 changes: 6 additions & 0 deletions src/components/FooterInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { FaDiscord as Discord } from 'react-icons/fa';
import { ChainContext } from '../contexts/ChainContext';
import BoxWrap from './wraps/BoxWrap';
import NetworkSelector from './selectors/NetworkSelector';
import PublicNotification from './PublicNotification';

const IconSize = '1.15rem';
const IconGap = 'small';
Expand All @@ -25,7 +26,11 @@ const FooterInfo = () => {
const handleExternal = (destination: string) => {};

return (
<>

<Box gap="small" align="end" style={{ position: 'absolute', bottom: '3em', right: '3em' }}>

<Box width='50%' alignSelf="end"><PublicNotification /> </Box>
<Box alignSelf="end">
<Text size="xsmall" color="text-weak">
App version: v{process.env.REACT_APP_VERSION}
Expand Down Expand Up @@ -108,6 +113,7 @@ const FooterInfo = () => {

<NetworkSelector />
</Box>
</>
);
};

Expand Down
37 changes: 37 additions & 0 deletions src/components/PublicNotification.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { useContext } from 'react';
import { Box, ResponsiveContext, Text } from 'grommet';
import { FiAlertCircle, FiAlertTriangle } from 'react-icons/fi';
import useChainId from '../hooks/useChainId';

type PublicNotificationProps = {
children?: any;
};

const PublicNotification = ({ children }: PublicNotificationProps) => {
const chainId = useChainId();
return (
<>
{chainId === 1 ? (
<Box direction="row" align="center" justify="between">
<Box
direction="row"
border={{ color: 'red', size: 'small' }}
pad="small"
gap="small"
align="center"
round="xsmall"
>
<Text color="red" size="large">
<FiAlertTriangle />
</Text>
<Text color="red" size="xsmall">
Full functionality is temporarily resticted on Ethereum mainnet.
</Text>
</Box>
</Box>
) : null}
</>
);
};

export default PublicNotification;
30 changes: 18 additions & 12 deletions src/components/selectors/SeriesSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useContext, useEffect, useState } from 'react';
import { Avatar, Box, Grid, ResponsiveContext, Select, Text } from 'grommet';
import { FiChevronDown } from 'react-icons/fi';
import { FiAlertTriangle, FiChevronDown } from 'react-icons/fi';

import { ethers } from 'ethers';
import styled from 'styled-components';

import { maxBaseIn } from '@yield-protocol/ui-math';

import { ActionType, ISeries } from '../../types';
import { ActionCodes, ActionType, ISeries } from '../../types';
import { UserContext } from '../../contexts/UserContext';
import { useApr } from '../../hooks/useApr';
import { cleanValue } from '../../utils/appUtils';
Expand Down Expand Up @@ -157,9 +157,6 @@ function SeriesSelector({ selectSeriesLocally, inputValue, actionType, cardLayou
<Text size="xsmall">Mature</Text>
</Box>
)}
{_series && actionType !== 'POOL' && (
<AprText inputValue={_inputValue} series={_series} actionType={actionType} color="text" />
)}
</Box>
);

Expand Down Expand Up @@ -293,14 +290,23 @@ function SeriesSelector({ selectSeriesLocally, inputValue, actionType, cardLayou
>
{series.seriesMark}
</Avatar>

<Box>
<AprText
inputValue={_inputValue}
series={series}
actionType={actionType}
color={series.id === _selectedSeries?.id ? series.textColor : undefined}
/>
{
series.allowActions.includes('allow_all') ||
(series.allowActions.includes(ActionCodes.BORROW) && actionType === ActionType.BORROW) ||
(series.allowActions.includes(ActionCodes.LEND) && actionType === ActionType.LEND) ? (
<AprText
inputValue={_inputValue}
series={series}
actionType={actionType}
color={series.id === _selectedSeries?.id ? series.textColor : undefined}
/>
) : (
<Text size="xsmall" color="red">
<FiAlertTriangle /> Restricted
</Text>
)}

<Text
size="small"
weight="lighter"
Expand Down
19 changes: 13 additions & 6 deletions src/components/selectors/StrategySelector.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useContext, useEffect, useState } from 'react';
import { Avatar, Box, Text } from 'grommet';
import { toast } from 'react-toastify';
import { FiSlash } from 'react-icons/fi';
import { FiAlertTriangle, FiSlash } from 'react-icons/fi';

import styled from 'styled-components';
import { IStrategy } from '../../types';
import { ActionCodes, IStrategy } from '../../types';
import { UserContext } from '../../contexts/UserContext';
import { formatStrategyName } from '../../utils/appUtils';
import Skeleton from '../wraps/SkeletonWrap';
Expand Down Expand Up @@ -89,9 +89,9 @@ const StrategySelectItem = ({
style={{ position: 'absolute', marginTop: '-1em', marginLeft: '17em' }}
elevation="small"
>
<Text size="small" color="white" textAlign="center">
+{returns?.rewardsAPY}%
</Text>
<Text size="small" color="white" textAlign="center">
+{returns?.rewardsAPY}%
</Text>
</Box>
)}

Expand All @@ -103,7 +103,14 @@ const StrategySelectItem = ({
boxShadow: `inset 1px 1px 2px ${strategy.currentSeries?.endColor.toString().concat('69')}`,
}}
>
<Text size="small">{(+returns.blendedAPY - +returns.rewardsAPY!).toFixed(1)}%</Text>
{strategy.currentSeries?.allowActions.includes('allow_all') ||
strategy.currentSeries?.allowActions.includes(ActionCodes.ADD_LIQUIDITY) ? (
<Text size="small">{(+returns.blendedAPY - +returns.rewardsAPY!).toFixed(1)}%</Text>
) : (
<Text color="red">
<FiAlertTriangle />
</Text>
)}
</Avatar>
</Box>
)}
Expand Down
1 change: 0 additions & 1 deletion src/components/views/Pool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import StrategyItem from '../positionItems/StrategyItem';

import Navigation from '../Navigation';
import Line from '../elements/Line';
import { useAccount } from 'wagmi';
import useStrategyReturns from '../../hooks/useStrategyReturns';
import { GA_Event, GA_View, GA_Properties } from '../../types/analytics';
import useAnalytics from '../../hooks/useAnalytics';
Expand Down
Loading

0 comments on commit 6fc7946

Please sign in to comment.