From 6441726113ed0898e5ea703a9bda75d7dd51f2d7 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 10:00:59 +0330 Subject: [PATCH 001/163] make pool cards height same --- src/components/cards/BaseStakingCard.sc.tsx | 12 +++--------- src/components/cards/BaseStakingCard.tsx | 5 +---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/components/cards/BaseStakingCard.sc.tsx b/src/components/cards/BaseStakingCard.sc.tsx index 4bcb4c3c3f..a185bb82e4 100644 --- a/src/components/cards/BaseStakingCard.sc.tsx +++ b/src/components/cards/BaseStakingCard.sc.tsx @@ -15,22 +15,16 @@ import { import { Flex } from '../styled-components/Flex'; import { Shadow } from '@/components/styled-components/Shadow'; -interface IStakingPoolContainer { - shadowColor?: string; - big?: boolean; -} - -export const StakingPoolContainer = styled.div` - height: ${props => (props.big ? '542px' : '488px')}; +export const StakingPoolContainer = styled.div` + height: 542px; border-radius: 8px; background: ${brandColors.giv[600]}; color: ${neutralColors.gray[100]}; position: relative; margin-bottom: 32px; padding: 1px 0; - box-shadow: ${props => - props.shadowColor ? `0px 0px 24px 6px ${props.shadowColor}` : 'unset'}; `; + export const StakingPoolExchangeRow = styled(Flex)` margin: 16px 16px 0; height: 21px; diff --git a/src/components/cards/BaseStakingCard.tsx b/src/components/cards/BaseStakingCard.tsx index 510d0e32e2..238a379761 100644 --- a/src/components/cards/BaseStakingCard.tsx +++ b/src/components/cards/BaseStakingCard.tsx @@ -291,10 +291,7 @@ const BaseStakingCard: FC = ({ return ( <> - + {poolNetwork !== chainId && ( From 7965ec807498572bf1197cab627bb4222e156ddf Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 10:48:21 +0330 Subject: [PATCH 002/163] make cards tidy --- src/components/RegenFarm.tsx | 2 +- .../BaseStakingCard}/BaseStakingCard.sc.tsx | 6 +- .../BaseStakingCard}/BaseStakingCard.tsx | 96 ++++++++++--------- .../GIVpowerCard}/GIVpowerCardIntro.tsx | 8 +- .../GIVpowerCard}/GIVpowerStakingPoolCard.tsx | 3 +- .../PositionCard}/PositionCard.tsx | 8 +- .../PositionCard}/StakingPositionCard.tsx | 11 +-- .../{ => StakingCards}/StakingCardIntro.tsx | 6 +- .../{ => StakingCards}/StakingPoolCard.tsx | 2 +- src/components/givfarm/RegenStreamCard.tsx | 15 +-- src/components/homeTabs/GIVfarm.tsx | 6 +- src/components/modals/HarvestAll.tsx | 2 +- src/components/modals/V3Stake.tsx | 2 +- 13 files changed, 87 insertions(+), 80 deletions(-) rename src/components/cards/{ => StakingCards/BaseStakingCard}/BaseStakingCard.sc.tsx (97%) rename src/components/cards/{ => StakingCards/BaseStakingCard}/BaseStakingCard.tsx (90%) rename src/components/cards/{ => StakingCards/GIVpowerCard}/GIVpowerCardIntro.tsx (90%) rename src/components/cards/{ => StakingCards/GIVpowerCard}/GIVpowerStakingPoolCard.tsx (88%) rename src/components/cards/{ => StakingCards/PositionCard}/PositionCard.tsx (96%) rename src/components/cards/{ => StakingCards/PositionCard}/StakingPositionCard.tsx (91%) rename src/components/cards/{ => StakingCards}/StakingCardIntro.tsx (91%) rename src/components/cards/{ => StakingCards}/StakingPoolCard.tsx (92%) diff --git a/src/components/RegenFarm.tsx b/src/components/RegenFarm.tsx index 1bdc740c97..5736001a78 100644 --- a/src/components/RegenFarm.tsx +++ b/src/components/RegenFarm.tsx @@ -7,7 +7,6 @@ import { regenFarmStreamCardCol, TWO_WEEK, } from '@/lib/constants/constants'; -import StakingPoolCard from './cards/StakingPoolCard'; import { Row, Col } from './Grid'; import { PoolRow } from './homeTabs/GIVfarm.sc'; import config from '@/configuration'; @@ -16,6 +15,7 @@ import { DAOChangeNetworkModal } from './DAOChangeNetworkModal'; import { DAOContainer, DAOChangeNetwork } from './givfarm/GIVfrens.sc'; import { RegenStreamCard } from './givfarm/RegenStreamCard'; import { getNowUnixMS } from '@/helpers/time'; +import StakingPoolCard from './cards/StakingCards/StakingPoolCard'; interface IRegenFarmProps { regenFarm: RegenFarmConfig; diff --git a/src/components/cards/BaseStakingCard.sc.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx similarity index 97% rename from src/components/cards/BaseStakingCard.sc.tsx rename to src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx index a185bb82e4..051deb8587 100644 --- a/src/components/cards/BaseStakingCard.sc.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx @@ -12,8 +12,8 @@ import { Subline, GLink, } from '@giveth/ui-design-system'; -import { Flex } from '../styled-components/Flex'; import { Shadow } from '@/components/styled-components/Shadow'; +import { Flex } from '@/components/styled-components/Flex'; export const StakingPoolContainer = styled.div` height: 542px; @@ -237,3 +237,7 @@ export const GIVgardenTooltip = styled.div` width: 150px; font-size: 0.8em; `; + +export const HarvestButtonsWrapper = styled(Flex)` + flex-direction: column; +`; diff --git a/src/components/cards/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx similarity index 90% rename from src/components/cards/BaseStakingCard.tsx rename to src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 238a379761..75ba3f9340 100644 --- a/src/components/cards/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -14,7 +14,6 @@ import { constants } from 'ethers'; import BigNumber from 'bignumber.js'; import { useWeb3React } from '@web3-react/core'; import { useRouter } from 'next/router'; -import config from '../../configuration'; import { PoolStakingConfig, RegenFarmConfig, @@ -40,6 +39,7 @@ import { DisableModalText, FirstDetail, GIVgardenTooltip, + HarvestButtonsWrapper, IconContainer, IconHelpFilledWraper, IntroIcon, @@ -58,25 +58,7 @@ import { StakingPoolSubtitle, WrongNetworkContainer, } from './BaseStakingCard.sc'; -import { APRModal } from '../modals/APR'; -import { StakeModal } from '../modals/StakeLock/Stake'; -import { UnStakeModal } from '../modals/Unstake/UnStake'; -import { StakingPoolImages } from '../StakingPoolImages'; -import { V3StakeModal } from '../modals/V3Stake'; -import { IconEthereum } from '../Icons/Eth'; -import { IconGnosisChain } from '../Icons/GnosisChain'; -import { IconGIV } from '../Icons/GIV'; -import { IconHoneyswap } from '../Icons/Honeyswap'; -import { IconBalancer } from '../Icons/Balancer'; -import { IconUniswap } from '../Icons/Uniswap'; -import { HarvestAllModal } from '../modals/HarvestAll'; -import { useFarms } from '@/context/farm.context'; -import { WhatisStreamModal } from '../modals/WhatisStream'; -import { IconSushiswap } from '../Icons/Sushiswap'; -import { UniV3APRModal } from '../modals/UNIv3APR'; -import StakingCardIntro from './StakingCardIntro'; -import { getNowUnixMS } from '@/helpers/time'; -import FarmCountDown from '../FarmCountDown'; + import { Flex, FlexCenter, @@ -84,19 +66,39 @@ import { } from '@/components/styled-components/Flex'; import { IStakeInfo } from '@/hooks/useStakingPool'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; -import { GIVPowerExplainModal } from '../modals/GIVPowerExplain'; -import GIVpowerCardIntro from './GIVpowerCardIntro'; -import LockModal from '../modals/StakeLock/Lock'; -import { StakeGIVModal } from '../modals/StakeLock/StakeGIV'; -import { LockupDetailsModal } from '../modals/LockupDetailsModal'; import { useAppSelector } from '@/features/hooks'; import Routes from '@/lib/constants/Routes'; import { chainName } from '@/lib/constants/constants'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; -import { IconAngelVault } from '../Icons/AngelVault'; -import { IconWithTooltip } from '../IconWithToolTip'; import { avgAPR } from '@/helpers/givpower'; -import { BridgeGIVModal } from '../modals/BridgeGIV'; +import config from '@/configuration'; +import FarmCountDown from '@/components/FarmCountDown'; +import { IconAngelVault } from '@/components/Icons/AngelVault'; +import { IconBalancer } from '@/components/Icons/Balancer'; +import { IconEthereum } from '@/components/Icons/Eth'; +import { IconGIV } from '@/components/Icons/GIV'; +import { IconGnosisChain } from '@/components/Icons/GnosisChain'; +import { IconHoneyswap } from '@/components/Icons/Honeyswap'; +import { IconSushiswap } from '@/components/Icons/Sushiswap'; +import { IconUniswap } from '@/components/Icons/Uniswap'; +import { IconWithTooltip } from '@/components/IconWithToolTip'; +import { APRModal } from '@/components/modals/APR'; +import { BridgeGIVModal } from '@/components/modals/BridgeGIV'; +import { GIVPowerExplainModal } from '@/components/modals/GIVPowerExplain'; +import { HarvestAllModal } from '@/components/modals/HarvestAll'; +import { LockupDetailsModal } from '@/components/modals/LockupDetailsModal'; +import LockModal from '@/components/modals/StakeLock/Lock'; +import { StakeModal } from '@/components/modals/StakeLock/Stake'; +import { StakeGIVModal } from '@/components/modals/StakeLock/StakeGIV'; +import { UniV3APRModal } from '@/components/modals/UNIv3APR'; +import { UnStakeModal } from '@/components/modals/Unstake/UnStake'; +import { V3StakeModal } from '@/components/modals/V3Stake'; +import { WhatisStreamModal } from '@/components/modals/WhatisStream'; +import { StakingPoolImages } from '@/components/StakingPoolImages'; +import { useFarms } from '@/context/farm.context'; +import { getNowUnixMS } from '@/helpers/time'; +import GIVpowerCardIntro from '../GIVpowerCard/GIVpowerCardIntro'; +import StakingCardIntro from '../StakingCardIntro'; import type { LiquidityPosition } from '@/types/nfts'; export enum StakeCardState { @@ -605,28 +607,30 @@ const BaseStakingCard: FC = ({ setStarted={setStarted} /> )} - setShowHarvestModal(true)} - label={formatMessage({ - id: 'label.harvest_rewards', - })} - buttonType={ - isGIVpower ? 'secondary' : 'primary' - } - /> - {isGIVpower && ( + setShowLockModal(true)} + disabled={exploited || earned.isZero()} + onClick={() => setShowHarvestModal(true)} label={formatMessage({ - id: 'label.increase_rewards', + id: 'label.harvest_rewards', })} - buttonType='primary' + buttonType={ + isGIVpower ? 'secondary' : 'primary' + } /> - )} + {isGIVpower && ( + setShowLockModal(true)} + label={formatMessage({ + id: 'label.increase_rewards', + })} + buttonType='primary' + /> + )} + ( diff --git a/src/components/cards/StakingCardIntro.tsx b/src/components/cards/StakingCards/StakingCardIntro.tsx similarity index 91% rename from src/components/cards/StakingCardIntro.tsx rename to src/components/cards/StakingCards/StakingCardIntro.tsx index e33aecb9d8..313ec70c8f 100644 --- a/src/components/cards/StakingCardIntro.tsx +++ b/src/components/cards/StakingCards/StakingCardIntro.tsx @@ -11,9 +11,9 @@ import { useIntl } from 'react-intl'; import { Dispatch, FC, SetStateAction } from 'react'; import styled from 'styled-components'; import { IntroCardConfig } from '@/types/config'; -import { getSymbolIconWithName } from '../StakingPoolImages'; -import { Flex } from '../styled-components/Flex'; -import { StakeCardState } from './BaseStakingCard'; +import { getSymbolIconWithName } from '../../StakingPoolImages'; +import { Flex } from '../../styled-components/Flex'; +import { StakeCardState } from './BaseStakingCard/BaseStakingCard'; interface IStakingCardIntro { setState: Dispatch>; diff --git a/src/components/cards/StakingPoolCard.tsx b/src/components/cards/StakingCards/StakingPoolCard.tsx similarity index 92% rename from src/components/cards/StakingPoolCard.tsx rename to src/components/cards/StakingCards/StakingPoolCard.tsx index b8976f06c7..da591f533e 100644 --- a/src/components/cards/StakingPoolCard.tsx +++ b/src/components/cards/StakingCards/StakingPoolCard.tsx @@ -1,5 +1,5 @@ -import BaseStakingCard from './BaseStakingCard'; import { useStakingPool } from '@/hooks/useStakingPool'; +import BaseStakingCard from './BaseStakingCard/BaseStakingCard'; import type { RegenFarmConfig, RegenPoolStakingConfig, diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 2897cd3309..fafbff31d7 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -14,7 +14,7 @@ import { P, Subline, } from '@giveth/ui-design-system'; -import { constants, ethers } from 'ethers'; +import { constants, BigNumber as EthBignumber } from 'ethers'; import BigNumber from 'bignumber.js'; import styled from 'styled-components'; import { useIntl } from 'react-intl'; @@ -35,8 +35,8 @@ import { useAppSelector } from '@/features/hooks'; import config from '@/configuration'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; -import { StakeCardState } from '../cards/BaseStakingCard'; -import StakingCardIntro from '../cards/StakingCardIntro'; +import StakingCardIntro from '../cards/StakingCards/StakingCardIntro'; +import { StakeCardState } from '../cards/StakingCards/BaseStakingCard/BaseStakingCard'; interface RegenStreamProps { network: number; @@ -64,10 +64,10 @@ export const RegenStreamCard: FC = ({ const [usdAmount, setUSDAmount] = useState('0'); const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); const [rewardStream, setRewardStream] = useState(0); - const [lockedAmount, setLockedAmount] = useState( + const [lockedAmount, setLockedAmount] = useState( constants.Zero, ); - const [claimedAmount, setClaimedAmount] = useState( + const [claimedAmount, setClaimedAmount] = useState( constants.Zero, ); @@ -96,9 +96,10 @@ export const RegenStreamCard: FC = ({ ); if (!price || price.isNaN()) return; - const usd = (+ethers.utils.formatEther( + const usd = formatWeiHelper( price.times(rewardLiquidPart.toString()).toFixed(0), - )).toFixed(2); + 2, + ); setUSDAmount(usd); }, [ rewardLiquidPart, diff --git a/src/components/homeTabs/GIVfarm.tsx b/src/components/homeTabs/GIVfarm.tsx index a9ae472918..ffc2ed8736 100644 --- a/src/components/homeTabs/GIVfarm.tsx +++ b/src/components/homeTabs/GIVfarm.tsx @@ -10,7 +10,6 @@ import { BigNumber } from 'bignumber.js'; import { constants } from 'ethers'; import { useWeb3React } from '@web3-react/core'; import { Flex } from '@/components/styled-components/Flex'; -import StakingPoolCard from '@/components/cards/StakingPoolCard'; import config from '@/configuration'; import { SimplePoolStakingConfig, @@ -30,7 +29,6 @@ import { } from './GIVfarm.sc'; import RadioButton from '@/components/RadioButton'; import { NetworkSelector } from '@/components/NetworkSelector'; -import StakingPositionCard from '@/components/cards/StakingPositionCard'; import { getGivStakingConfig } from '@/helpers/networkProvider'; import useGIVTokenDistroHelper from '@/hooks/useGIVTokenDistroHelper'; import { useFarms } from '@/context/farm.context'; @@ -39,11 +37,13 @@ import { shortenAddress } from '@/lib/helpers'; import { Col, Container, Row } from '@/components/Grid'; import { GIVfrens } from '@/components/givfarm/GIVfrens'; -import GIVpowerStakingPoolCard from '../cards/GIVpowerStakingPoolCard'; import { GIVpowerProvider } from '@/context/givpower.context'; import { DaoCard } from '../givfarm/DaoCard'; import { getNowUnixMS } from '@/helpers/time'; import { TWO_WEEK } from '@/lib/constants/constants'; +import GIVpowerStakingPoolCard from '../cards/StakingCards/GIVpowerCard/GIVpowerStakingPoolCard'; +import StakingPositionCard from '../cards/StakingCards/PositionCard/StakingPositionCard'; +import StakingPoolCard from '../cards/StakingCards/StakingPoolCard'; const renderPool = ( pool: SimplePoolStakingConfig | UniswapV3PoolStakingConfig, diff --git a/src/components/modals/HarvestAll.tsx b/src/components/modals/HarvestAll.tsx index 6c695c8ad9..7f221c7dd2 100644 --- a/src/components/modals/HarvestAll.tsx +++ b/src/components/modals/HarvestAll.tsx @@ -58,7 +58,6 @@ import { claimReward, fetchAirDropClaimData } from '@/lib/claim'; import config from '@/configuration'; import { IconWithTooltip } from '../IconWithToolTip'; import { AmountBoxWithPrice } from '@/components/AmountBoxWithPrice'; -import { getPoolIconWithName } from '../cards/BaseStakingCard'; import { IModal } from '@/types/common'; import { useAppSelector } from '@/features/hooks'; import { LiquidityPosition } from '@/types/nfts'; @@ -66,6 +65,7 @@ import { Flex } from '../styled-components/Flex'; import { useModalAnimation } from '@/hooks/useModalAnimation'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; import LottieControl from '@/components/animations/lottieControl'; +import { getPoolIconWithName } from '../cards/StakingCards/BaseStakingCard/BaseStakingCard'; import type { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; interface IHarvestAllModalProps extends IModal { diff --git a/src/components/modals/V3Stake.tsx b/src/components/modals/V3Stake.tsx index 229db24a23..139d5740f7 100644 --- a/src/components/modals/V3Stake.tsx +++ b/src/components/modals/V3Stake.tsx @@ -16,7 +16,7 @@ import { CancelButton, HarvestButton, HelpRow, Pending } from './HarvestAll.sc'; import { Flex } from '../styled-components/Flex'; import { PoolStakingConfig } from '@/types/config'; import { StakingPoolImages } from '../StakingPoolImages'; -import V3StakingCard from '../cards/PositionCard'; +import V3StakingCard from '../cards/StakingCards/PositionCard/PositionCard'; import LoadingAnimation from '@/animations/loading.json'; import { exit, getReward, transfer } from '@/lib/stakingNFT'; import { From c5afd83d46b8a24208dbc225f8638f1c2aecfabf Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 11:03:06 +0330 Subject: [PATCH 003/163] move claim card to specific folder --- src/components/views/claim/Claim.view.tsx | 33 ++++--------------- .../{ => views/claim}/cards/Claim.tsx | 10 +++--- .../claim}/cards/Congratulations.tsx | 6 ++-- .../{ => views/claim}/cards/Connect.tsx | 14 ++++---- .../{ => views/claim}/cards/Donate.tsx | 10 +++--- .../claim}/cards/GivEconomyProjectCards.tsx | 2 +- .../{ => views/claim}/cards/Govern.tsx | 7 ++-- .../{ => views/claim}/cards/Stake.tsx | 6 ++-- .../{ => views/claim}/cards/Stream.tsx | 4 +-- .../{ => views/claim}/cards/common.tsx | 2 +- 10 files changed, 38 insertions(+), 56 deletions(-) rename src/components/{ => views/claim}/cards/Claim.tsx (90%) rename src/components/{ => views/claim}/cards/Congratulations.tsx (97%) rename src/components/{ => views/claim}/cards/Connect.tsx (95%) rename src/components/{ => views/claim}/cards/Donate.tsx (95%) rename src/components/{ => views/claim}/cards/GivEconomyProjectCards.tsx (95%) rename src/components/{ => views/claim}/cards/Govern.tsx (97%) rename src/components/{ => views/claim}/cards/Stake.tsx (97%) rename src/components/{ => views/claim}/cards/Stream.tsx (96%) rename src/components/{ => views/claim}/cards/common.tsx (98%) diff --git a/src/components/views/claim/Claim.view.tsx b/src/components/views/claim/Claim.view.tsx index 055fd5c18a..b12c5fa586 100644 --- a/src/components/views/claim/Claim.view.tsx +++ b/src/components/views/claim/Claim.view.tsx @@ -2,13 +2,13 @@ import React, { FC } from 'react'; import styled from 'styled-components'; import { useWeb3React } from '@web3-react/core'; import config from '@/configuration'; -import { CongratulationsCard } from '@/components/cards/Congratulations'; -import ClaimCard from '@/components/cards/Claim'; -import { ConnectCard } from '@/components/cards/Connect'; -import { DonateCard } from '@/components/cards/Donate'; -import { StreamCard } from '@/components/cards/Stream'; -import GovernCard from '@/components/cards/Govern'; -import InvestCard from '@/components/cards/Stake'; +import ClaimCard from '@/components/views/claim/cards/Claim'; +import { CongratulationsCard } from '@/components/views/claim/cards/Congratulations'; +import { ConnectCard } from '@/components/views/claim/cards/Connect'; +import { DonateCard } from '@/components/views/claim/cards/Donate'; +import { StreamCard } from '@/components/views/claim/cards/Stream'; +import GovernCard from '@/components/views/claim/cards/Govern'; +import InvestCard from '@/components/views/claim/cards/Stake'; import { Flex } from '@/components/styled-components/Flex'; import useClaim, { GiveDropStateType } from '@/context/claim.context'; @@ -117,25 +117,6 @@ const ClaimView = () => { return ( <> - {/* */} {step < 6 ? ( = ({ index }) => { > { deactivate(); setWalletIsChanged(true); dispatch(setShowWalletModal(true)); }} - > - {btnLabel} - + label={btnLabel || ''} + /> {giveDropState === GiveDropStateType.Missed && ( diff --git a/src/components/cards/Donate.tsx b/src/components/views/claim/cards/Donate.tsx similarity index 95% rename from src/components/cards/Donate.tsx rename to src/components/views/claim/cards/Donate.tsx index d95a541890..fc55b208b6 100644 --- a/src/components/cards/Donate.tsx +++ b/src/components/views/claim/cards/Donate.tsx @@ -11,8 +11,7 @@ import { IconHelpFilled16, } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; -import { InputWithUnit } from '../input/index'; -import { Flex } from '../styled-components/Flex'; + import { APRRow, ArrowButton, @@ -30,10 +29,13 @@ import { PreviousArrowButton, } from './common'; import { IClaimViewCardProps } from '@/components/views/claim/Claim.view'; -import { formatWeiHelper, Zero } from '@/helpers/number'; -import { IconWithTooltip } from '../IconWithToolTip'; + import useClaim from '@/context/claim.context'; import useGIVTokenDistroHelper from '@/hooks/useGIVTokenDistroHelper'; +import { IconWithTooltip } from '@/components/IconWithToolTip'; +import { InputWithUnit } from '@/components/input'; +import { Flex } from '@/components/styled-components/Flex'; +import { Zero, formatWeiHelper } from '@/helpers/number'; const DonatePoolCard = styled(PoolCard)` height: 127px; diff --git a/src/components/cards/GivEconomyProjectCards.tsx b/src/components/views/claim/cards/GivEconomyProjectCards.tsx similarity index 95% rename from src/components/cards/GivEconomyProjectCards.tsx rename to src/components/views/claim/cards/GivEconomyProjectCards.tsx index 28eb58271f..8e04d87ef3 100644 --- a/src/components/cards/GivEconomyProjectCards.tsx +++ b/src/components/views/claim/cards/GivEconomyProjectCards.tsx @@ -2,8 +2,8 @@ import Link from 'next/link'; import { useIntl } from 'react-intl'; import { Row, Col } from '@/components/Grid'; import Routes from '@/lib/constants/Routes'; -import { GsButton, IGsDataBox } from '../homeTabs/GIVstream.sc'; import config from '@/configuration'; +import { IGsDataBox, GsButton } from '@/components/homeTabs/GIVstream.sc'; const GivEconomyProjectCards = () => { const { formatMessage } = useIntl(); diff --git a/src/components/cards/Govern.tsx b/src/components/views/claim/cards/Govern.tsx similarity index 97% rename from src/components/cards/Govern.tsx rename to src/components/views/claim/cards/Govern.tsx index 7729aac0bd..9e78ff84a6 100644 --- a/src/components/cards/Govern.tsx +++ b/src/components/views/claim/cards/Govern.tsx @@ -23,9 +23,7 @@ import { PoolItems, PreviousArrowButton, } from './common'; -import { InputWithUnit } from '../input/index'; -import { Flex } from '../styled-components/Flex'; -import { IClaimViewCardProps } from '../views/claim/Claim.view'; + import config from '@/configuration'; import { formatEthHelper, formatWeiHelper, Zero } from '@/helpers/number'; import { getGivStakingAPR } from '@/lib/stakingPool'; @@ -33,6 +31,9 @@ import { APR } from '@/types/poolInfo'; import useClaim from '@/context/claim.context'; import { useAppSelector } from '@/features/hooks'; import useGIVTokenDistroHelper from '@/hooks/useGIVTokenDistroHelper'; +import { InputWithUnit } from '@/components/input'; +import { Flex } from '@/components/styled-components/Flex'; +import { IClaimViewCardProps } from '../Claim.view'; const GovernCardContainer = styled(Card)` padding-left: 254px; diff --git a/src/components/cards/Stake.tsx b/src/components/views/claim/cards/Stake.tsx similarity index 97% rename from src/components/cards/Stake.tsx rename to src/components/views/claim/cards/Stake.tsx index 07bae563f2..b8ce682719 100644 --- a/src/components/cards/Stake.tsx +++ b/src/components/views/claim/cards/Stake.tsx @@ -5,8 +5,6 @@ import { BigNumber as EthersBigNumber, constants, utils } from 'ethers'; import BigNumber from 'bignumber.js'; import { H2, H5, Lead } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; -import { InputWithUnit } from '../input/index'; -import { Flex } from '../styled-components/Flex'; import { APRRow, ArrowButton, @@ -24,7 +22,6 @@ import { PoolItems, PreviousArrowButton, } from './common'; -import { IClaimViewCardProps } from '../views/claim/Claim.view'; import useClaim from '@/context/claim.context'; import config from '@/configuration'; import { formatEthHelper, formatWeiHelper, Zero } from '@/helpers/number'; @@ -35,6 +32,9 @@ import { networkProviders } from '@/helpers/networkProvider'; import { useAppSelector } from '@/features/hooks'; import { SimplePoolStakingConfig, StakingType } from '@/types/config'; import { getNowUnixMS } from '@/helpers/time'; +import { InputWithUnit } from '@/components/input'; +import { Flex } from '@/components/styled-components/Flex'; +import { IClaimViewCardProps } from '../Claim.view'; const InvestCardContainer = styled(Card)` ::before { diff --git a/src/components/cards/Stream.tsx b/src/components/views/claim/cards/Stream.tsx similarity index 96% rename from src/components/cards/Stream.tsx rename to src/components/views/claim/cards/Stream.tsx index 8e2126d675..53704faf0d 100644 --- a/src/components/cards/Stream.tsx +++ b/src/components/views/claim/cards/Stream.tsx @@ -3,14 +3,14 @@ import Image from 'next/image'; import styled from 'styled-components'; import { useIntl } from 'react-intl'; import { H2, Lead, H5 } from '@giveth/ui-design-system'; -import { Flex } from '../styled-components/Flex'; import { ArrowButton, Card, PreviousArrowButton } from './common'; -import { IClaimViewCardProps } from '../views/claim/Claim.view'; import useGIVTokenDistroHelper from '@/hooks/useGIVTokenDistroHelper'; import { formatWeiHelper } from '@/helpers/number'; import { durationToString } from '@/lib/helpers'; import useClaim from '@/context/claim.context'; +import { Flex } from '@/components/styled-components/Flex'; +import { IClaimViewCardProps } from '../Claim.view'; const StreamCardContainer = styled(Card)` ::before { diff --git a/src/components/cards/common.tsx b/src/components/views/claim/cards/common.tsx similarity index 98% rename from src/components/cards/common.tsx rename to src/components/views/claim/cards/common.tsx index 6eaf3ec59c..667837a9de 100644 --- a/src/components/cards/common.tsx +++ b/src/components/views/claim/cards/common.tsx @@ -1,5 +1,5 @@ import styled from 'styled-components'; -import { Flex } from '../styled-components/Flex'; +import { Flex } from '@/components/styled-components/Flex'; export interface ICardProps { activeIndex: number; From 43721bc03286d913c3f6408bb197d687448d8d58 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 11:17:00 +0330 Subject: [PATCH 004/163] move disable modal to archive cover --- .../BaseStakingCard/ArchiveCover.tsx | 121 ++++++++++++++++++ .../BaseStakingCard/BaseStakingCard.sc.tsx | 51 -------- .../BaseStakingCard/BaseStakingCard.tsx | 63 +-------- 3 files changed, 124 insertions(+), 111 deletions(-) create mode 100644 src/components/cards/StakingCards/BaseStakingCard/ArchiveCover.tsx diff --git a/src/components/cards/StakingCards/BaseStakingCard/ArchiveCover.tsx b/src/components/cards/StakingCards/BaseStakingCard/ArchiveCover.tsx new file mode 100644 index 0000000000..a7c4018579 --- /dev/null +++ b/src/components/cards/StakingCards/BaseStakingCard/ArchiveCover.tsx @@ -0,0 +1,121 @@ +import { + brandColors, + GLink, + IconInfoFilled24, + OutlineButton, + P, +} from '@giveth/ui-design-system'; +import { FC, useState } from 'react'; +import { useIntl } from 'react-intl'; +import styled from 'styled-components'; +import { Flex } from '@/components/styled-components/Flex'; +import { Shadow } from '@/components/styled-components/Shadow'; + +interface IArchiveCoverProps { + isExploited?: boolean; +} + +export const ArchiveCover: FC = ({ isExploited }) => { + const [disableModal, setDisableModal] = useState(true); + const { formatMessage } = useIntl(); + + return disableModal ? ( + + + + + + + + {formatMessage({ + id: 'label.this_farm_has_ended', + })} + + + {isExploited ? ( + <> + {formatMessage({ + id: 'label.an_exploit_has_removed_available_rewards', + })} + +   + {formatMessage({ + id: 'label.this_forum_post', + })} +   + + {formatMessage({ + id: 'label.for_details', + })} + + ) : ( + formatMessage({ + id: 'label.harvest_your_rewards_and_remove_your_funds', + }) + )} + + setDisableModal(false)} + /> + + + + ) : null; +}; + +const DisableModal = styled.div` + position: absolute; + width: 100%; + height: 100%; + background: transparent; + z-index: 10; + display: flex; + justify-content: center; + align-items: center; + background-color: #00000070; +`; + +const DisableModalContent = styled.div` + display: flex; + background: white; + gap: 12px; + border-radius: 12px; + box-shadow: ${Shadow.Neutral[400]}; + max-width: 80%; + height: 190px; + padding: 16px 12px; +`; + +const DisableModalText = styled(P)<{ weight?: number }>` + color: ${brandColors.giv[500]}; + font-weight: ${props => (props.weight ? props.weight : 400)}; +`; + +const DisableModalLink = styled(GLink)` + color: ${brandColors.pinky[500]}; +`; + +const DisableModalCloseButton = styled(OutlineButton)` + border: none; + color: ${brandColors.giv[500]}; + font-weight: 700; + margin-left: auto; + padding-right: 4px; + + &:hover { + background-color: transparent; + } +`; + +const DisableModalImage = styled.div` + width: 36px; + color: ${brandColors.giv[500]}; +`; diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx index 051deb8587..9dc7a0a8d8 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx @@ -10,9 +10,7 @@ import { Button, OutlineButton, Subline, - GLink, } from '@giveth/ui-design-system'; -import { Shadow } from '@/components/styled-components/Shadow'; import { Flex } from '@/components/styled-components/Flex'; export const StakingPoolContainer = styled.div` @@ -161,55 +159,6 @@ export const IntroIcon = styled.div` } `; -export const DisableModal = styled.div` - position: absolute; - width: 100%; - height: 100%; - background: transparent; - z-index: 10; - display: flex; - justify-content: center; - align-items: center; - background-color: #00000070; -`; - -export const DisableModalContent = styled.div` - display: flex; - background: white; - gap: 12px; - border-radius: 12px; - box-shadow: ${Shadow.Neutral[400]}; - max-width: 80%; - height: 190px; - padding: 16px 12px; -`; - -export const DisableModalText = styled(P)<{ weight?: number }>` - color: ${brandColors.giv[500]}; - font-weight: ${props => (props.weight ? props.weight : 400)}; -`; - -export const DisableModalLink = styled(GLink)` - color: ${brandColors.pinky[500]}; -`; - -export const DisableModalCloseButton = styled(OutlineButton)` - border: none; - color: ${brandColors.giv[500]}; - font-weight: 700; - margin-left: auto; - padding-right: 4px; - - &:hover { - background-color: transparent; - } -`; - -export const DisableModalImage = styled.div` - width: 36px; - color: ${brandColors.giv[500]}; -`; - export const LockInfotooltip = styled(Subline)` color: ${neutralColors.gray[100]}; width: 180px; diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 75ba3f9340..3066471f8a 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -7,7 +7,6 @@ import { Caption, IconAlertCircle32, IconHelpFilled16, - IconInfoFilled24, } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; import { constants } from 'ethers'; @@ -31,12 +30,6 @@ import { Details, DetailUnit, DetailValue, - DisableModal, - DisableModalCloseButton, - DisableModalContent, - DisableModalImage, - DisableModalLink, - DisableModalText, FirstDetail, GIVgardenTooltip, HarvestButtonsWrapper, @@ -99,6 +92,7 @@ import { useFarms } from '@/context/farm.context'; import { getNowUnixMS } from '@/helpers/time'; import GIVpowerCardIntro from '../GIVpowerCard/GIVpowerCardIntro'; import StakingCardIntro from '../StakingCardIntro'; +import { ArchiveCover } from './ArchiveCover'; import type { LiquidityPosition } from '@/types/nfts'; export enum StakeCardState { @@ -174,7 +168,6 @@ const BaseStakingCard: FC = ({ const [rewardStream, setRewardStream] = useState(0); const [tokenDistroHelper, setTokenDistroHelper] = useState(); - const [disableModal, setDisableModal] = useState(true); const router = useRouter(); const { setInfo } = useFarms(); const { chainId, account, active: isWalletActive } = useWeb3React(); @@ -310,58 +303,8 @@ const BaseStakingCard: FC = ({ )} - {(isDiscontinued || exploited) && disableModal && ( - - - - - - - - {formatMessage({ - id: 'label.this_farm_has_ended', - })} - - - {exploited ? ( - <> - {formatMessage({ - id: 'label.an_exploit_has_removed_available_rewards', - })} - -   - {formatMessage({ - id: 'label.this_forum_post', - })} -   - - {formatMessage({ - id: 'label.for_details', - })} - - ) : ( - formatMessage({ - id: 'label.harvest_your_rewards_and_remove_your_funds', - }) - )} - - setDisableModal(false)} - /> - - - + {(isDiscontinued || exploited) && ( + )} {state === StakeCardState.NORMAL ? ( <> From d14a26d991bee96ff4195ec7536109d6b258c2ae Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 11:17:55 +0330 Subject: [PATCH 005/163] fix typo --- .../BaseStakingCard/BaseStakingCard.sc.tsx | 2 +- .../BaseStakingCard/BaseStakingCard.tsx | 6 +++--- src/components/modals/Boost/BoostInnerModal.tsx | 10 +++++----- src/components/modals/StakeLock/Lock.tsx | 6 +++--- src/components/modals/StakeLock/LockInfo.tsx | 14 +++++++------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx index 9dc7a0a8d8..72c57f3930 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx @@ -159,7 +159,7 @@ export const IntroIcon = styled.div` } `; -export const LockInfotooltip = styled(Subline)` +export const LockInfoTooltip = styled(Subline)` color: ${neutralColors.gray[100]}; width: 180px; `; diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 3066471f8a..faf6237d49 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -37,7 +37,7 @@ import { IconHelpFilledWraper, IntroIcon, LiquidityButton, - LockInfotooltip, + LockInfoTooltip, SPTitle, StakeAmount, StakeButton, @@ -621,11 +621,11 @@ const BaseStakingCard: FC = ({ icon={} direction={'top'} > - + {formatMessage({ id: 'label.some_or_all_of_your_staked_giv_is_locked', })} - + )} diff --git a/src/components/modals/Boost/BoostInnerModal.tsx b/src/components/modals/Boost/BoostInnerModal.tsx index 6e2b6d9b07..38fab92110 100644 --- a/src/components/modals/Boost/BoostInnerModal.tsx +++ b/src/components/modals/Boost/BoostInnerModal.tsx @@ -16,7 +16,7 @@ import Link from 'next/link'; import LottieControl from '@/components/animations/lottieControl'; import { IconWithTooltip } from '@/components/IconWithToolTip'; -import { LockInfotooltip } from '../StakeLock/LockInfo'; +import { LockInfoTooltip } from '../StakeLock/LockInfo'; import { Flex } from '@/components/styled-components/Flex'; import 'rc-slider/assets/index.css'; import { formatWeiHelper } from '@/helpers/number'; @@ -251,11 +251,11 @@ const BoostInnerModal: FC = ({ icon={} direction={'bottom'} > - + {formatMessage({ id: 'label.get_more_givpower_by_staking', })} - + @@ -267,11 +267,11 @@ const BoostInnerModal: FC = ({ icon={} direction={'bottom'} > - + {formatMessage({ id: 'label.this_is_the_number_of_projects_you_have_boosted', })} - + diff --git a/src/components/modals/StakeLock/Lock.tsx b/src/components/modals/StakeLock/Lock.tsx index a0772c3863..af6c3a222e 100644 --- a/src/components/modals/StakeLock/Lock.tsx +++ b/src/components/modals/StakeLock/Lock.tsx @@ -24,7 +24,7 @@ import { } from './StakeLock.sc'; import { AmountInput } from '@/components/AmountInput'; import LockSlider from './LockSlider'; -import LockInfo, { LockInfotooltip } from './LockInfo'; +import LockInfo, { LockInfoTooltip } from './LockInfo'; import LockingBrief from './LockingBrief'; import { lockToken } from '@/lib/stakingPool'; import config from '@/configuration'; @@ -123,11 +123,11 @@ const LockModal: FC = ({ direction='right' align='top' > - + {formatMessage({ id: 'label.rounds_are_two_weeks_periods', })} - + diff --git a/src/components/modals/StakeLock/LockInfo.tsx b/src/components/modals/StakeLock/LockInfo.tsx index 365de7a815..da13ad611a 100644 --- a/src/components/modals/StakeLock/LockInfo.tsx +++ b/src/components/modals/StakeLock/LockInfo.tsx @@ -37,10 +37,10 @@ const LockInfo: FC = ({ round, amount }) => { icon={} direction={'top'} > - + The longer you lock your GIV, the greater your APR & GIVpower. - + @@ -53,10 +53,10 @@ const LockInfo: FC = ({ round, amount }) => { icon={} direction={'right'} > - + This is your rate of return for this set of GIV tokens. - + @@ -79,10 +79,10 @@ const LockInfo: FC = ({ round, amount }) => { icon={} direction={'right'} > - + GIVpower allows you to support verified projects on Giveth while earning rewards. - + @@ -155,7 +155,7 @@ const LockInfoRowSpark = styled.div` } `; -export const LockInfotooltip = styled(Subline)` +export const LockInfoTooltip = styled(Subline)` color: ${neutralColors.gray[100]}; width: 160px; `; From df81f171828ef38fc4ba3e937fef5e02e3b8c5e7 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 11:19:07 +0330 Subject: [PATCH 006/163] fix typo --- .vscode/settings.json | 1 + src/components/RewardCard.tsx | 6 +++--- .../StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx | 2 +- .../cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d966ce36d4..93ed8dda53 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,6 +4,7 @@ "GIVback", "GIVBACKS", "GIVeconomy", + "GIVgarden", "giveth", "GIVfarm", "GIVfrens", diff --git a/src/components/RewardCard.tsx b/src/components/RewardCard.tsx index 9d4dd58028..4aa7cdd59a 100644 --- a/src/components/RewardCard.tsx +++ b/src/components/RewardCard.tsx @@ -110,7 +110,7 @@ export const RewardCard: FC = ({ {rewardTokenSymbol} {formatMessage({ id: 'label./week' })} - { setShowWhatIsGIVstreamModal(true); }} @@ -118,7 +118,7 @@ export const RewardCard: FC = ({ - + {actionLabel && actionCb ? ( = ({ id: 'label.streaming', })} - { setShowWhatIsGIVstreamModal( true, @@ -519,7 +519,7 @@ const BaseStakingCard: FC = ({ }} > - + From 5ac58cbd2ccde7fbc22a0d409e29a80ee75a15d0 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 13:39:57 +0330 Subject: [PATCH 007/163] remove UniswapV3PoolStakingConfig --- src/types/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/config.ts b/src/types/config.ts index ff6271772f..9cd4e71d41 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -45,7 +45,7 @@ export enum StreamType { export type PoolStakingConfig = | SimplePoolStakingConfig | BalancerPoolStakingConfig - | UniswapV3PoolStakingConfig + // | UniswapV3PoolStakingConfig | RegenPoolStakingConfig | ICHIPoolStakingConfig; From fe4a9ba8248fad0d3d46bfd94a2d8b7ae63c667b Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 13:41:27 +0330 Subject: [PATCH 008/163] remove GIVpowerContext --- src/context/givpower.context.tsx | 63 -------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 src/context/givpower.context.tsx diff --git a/src/context/givpower.context.tsx b/src/context/givpower.context.tsx deleted file mode 100644 index 79157a4516..0000000000 --- a/src/context/givpower.context.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { createContext, FC, ReactNode, useContext } from 'react'; -import { Zero } from '@ethersproject/constants'; -import { Zero as BNZero } from '@/helpers/number'; -import { useStakingPool } from '@/hooks/useStakingPool'; -import { getGivStakingConfig } from '@/helpers/networkProvider'; -import config from '@/configuration'; - -import type { IStakeInfo } from '@/hooks/useStakingPool'; -import type { PoolStakingConfig } from '@/types/config'; - -interface IGIVpowerContext extends IStakeInfo { - poolStakingConfig: PoolStakingConfig; -} - -const givPoolstakingConfigGnosis = getGivStakingConfig(config.XDAI_CONFIG); - -const zeroAPR = { - effectiveAPR: BNZero, - vaultIRR: BNZero, -}; - -export const GIVpowerContext = createContext({ - poolStakingConfig: givPoolstakingConfigGnosis, - apr: zeroAPR, - earned: Zero, - stakedAmount: Zero, - notStakedAmount: Zero, -}); - -GIVpowerContext.displayName = 'GIVpowerContext'; - -interface IGIVpowerProvider { - children: ReactNode; -} - -export const GIVpowerProvider: FC = ({ children }) => { - const { apr, notStakedAmount, stakedAmount, earned } = useStakingPool( - givPoolstakingConfigGnosis, - ); - return ( - - {children} - - ); -}; - -export function useGIVpower() { - const context = useContext(GIVpowerContext); - - if (!context) { - throw new Error('GIVpower context not found!'); - } - - return context; -} From 9909b0734f42ae493de507b7a1b414fdaffdfc8d Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 13:41:58 +0330 Subject: [PATCH 009/163] use useStakingPool instead of useGIVpower in LockupDetailsModal --- src/components/modals/LockupDetailsModal.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/modals/LockupDetailsModal.tsx b/src/components/modals/LockupDetailsModal.tsx index b4e2ba3318..f7ae7306c5 100644 --- a/src/components/modals/LockupDetailsModal.tsx +++ b/src/components/modals/LockupDetailsModal.tsx @@ -16,13 +16,14 @@ import { Flex } from '../styled-components/Flex'; import { Modal } from './Modal'; import { IconWithTooltip } from '../IconWithToolTip'; import { formatEthHelper, formatWeiHelper } from '@/helpers/number'; -import { useGIVpower } from '@/context/givpower.context'; import { fetchSubgraph } from '@/services/subgraph.service'; import config from '@/configuration'; import { SubgraphQueryBuilder } from '@/lib/subgraph/subgraphQueryBuilder'; import { mediaQueries } from '@/lib/constants/constants'; import { useModalAnimation } from '@/hooks/useModalAnimation'; import { RowWrapper, TableCell, TableHeader } from '../styled-components/Table'; +import { getGivStakingConfig } from '@/helpers/networkProvider'; +import { useStakingPool } from '@/hooks/useStakingPool'; import type { IGIVpowerPosition } from '@/types/subgraph'; import type { BigNumber } from 'ethers'; import type { IModal } from '@/types/common'; @@ -35,7 +36,9 @@ export const LockupDetailsModal: FC = ({ unstakeable, setShowModal, }) => { - const { apr, stakedAmount } = useGIVpower(); + const { apr, stakedAmount } = useStakingPool( + getGivStakingConfig(config.XDAI_CONFIG), + ); const { account } = useWeb3React(); const [locksInfo, setLocksInfo] = useState([]); const { isAnimating, closeModal } = useModalAnimation(setShowModal); From 6d29fdc517dde4f5d019232f630ce348476f85e7 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 13:42:44 +0330 Subject: [PATCH 010/163] remove tokenDistroHelper from apr modal helper --- src/components/modals/APR.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/modals/APR.tsx b/src/components/modals/APR.tsx index d25f5a551a..b95c956223 100644 --- a/src/components/modals/APR.tsx +++ b/src/components/modals/APR.tsx @@ -14,16 +14,13 @@ import { IModal } from '@/types/common'; import { useModalAnimation } from '@/hooks/useModalAnimation'; import { mediaQueries } from '@/lib/constants/constants'; import { RegenFarmConfig } from '@/types/config'; -import type { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; interface IAPRModalProps extends IModal { - tokenDistroHelper?: TokenDistroHelper; regenStreamConfig?: RegenFarmConfig; } export const APRModal: FC = ({ setShowModal, - tokenDistroHelper, regenStreamConfig, }) => { const { rewardTokenSymbol = 'GIV' } = regenStreamConfig || {}; @@ -58,14 +55,13 @@ export const APRModal: FC = ({ Current Distribution: Claimable immediately:{' '} - {tokenDistroHelper?.GlobalReleasePercentage.toFixed(2)}% + {/* {tokenDistroHelper?.GlobalReleasePercentage.toFixed(2)}% */} Increasing your {streamName}:{' '} - {( - 100 - - (tokenDistroHelper?.GlobalReleasePercentage || 0) - ).toFixed(2)} + {(100) + // (tokenDistroHelper?.GlobalReleasePercentage || 0) + .toFixed(2)} % From 1eaaa6e09318a93da7525290d8087a1ebb167826 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 13:46:01 +0330 Subject: [PATCH 011/163] show givpower card like other cars --- src/components/homeTabs/GIVfarm.tsx | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/components/homeTabs/GIVfarm.tsx b/src/components/homeTabs/GIVfarm.tsx index ffc2ed8736..fb03583de8 100644 --- a/src/components/homeTabs/GIVfarm.tsx +++ b/src/components/homeTabs/GIVfarm.tsx @@ -13,7 +13,6 @@ import { Flex } from '@/components/styled-components/Flex'; import config from '@/configuration'; import { SimplePoolStakingConfig, - StakingType, UniswapV3PoolStakingConfig, } from '@/types/config'; import { @@ -37,12 +36,9 @@ import { shortenAddress } from '@/lib/helpers'; import { Col, Container, Row } from '@/components/Grid'; import { GIVfrens } from '@/components/givfarm/GIVfrens'; -import { GIVpowerProvider } from '@/context/givpower.context'; import { DaoCard } from '../givfarm/DaoCard'; import { getNowUnixMS } from '@/helpers/time'; import { TWO_WEEK } from '@/lib/constants/constants'; -import GIVpowerStakingPoolCard from '../cards/StakingCards/GIVpowerCard/GIVpowerStakingPoolCard'; -import StakingPositionCard from '../cards/StakingCards/PositionCard/StakingPositionCard'; import StakingPoolCard from '../cards/StakingCards/StakingPoolCard'; const renderPool = ( @@ -50,13 +46,11 @@ const renderPool = ( id: number, ) => ( - {pool.type === StakingType.UNISWAPV3_ETH_GIV ? ( + {/* {pool.type === StakingType.UNISWAPV3_ETH_GIV ? ( ) : ( - - )} + )} */} + ); @@ -220,11 +214,13 @@ export const TabGIVfarmBottom = () => { /> - - - - - + + + {showArchivedPools && ( Date: Thu, 23 Feb 2023 13:46:30 +0330 Subject: [PATCH 012/163] remove GIVpowerStakingPoolCard --- .../GIVpowerCard/GIVpowerStakingPoolCard.tsx | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 src/components/cards/StakingCards/GIVpowerCard/GIVpowerStakingPoolCard.tsx diff --git a/src/components/cards/StakingCards/GIVpowerCard/GIVpowerStakingPoolCard.tsx b/src/components/cards/StakingCards/GIVpowerCard/GIVpowerStakingPoolCard.tsx deleted file mode 100644 index 74fc060553..0000000000 --- a/src/components/cards/StakingCards/GIVpowerCard/GIVpowerStakingPoolCard.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { useGIVpower } from '@/context/givpower.context'; -import BaseStakingCard from '../BaseStakingCard/BaseStakingCard'; -import type { FC } from 'react'; - -interface IGIVpowerStakingPoolCardProps {} - -const GIVpowerStakingPoolCard: FC = ({}) => { - const { poolStakingConfig, apr, notStakedAmount, stakedAmount, earned } = - useGIVpower(); - const stakeInfo = { - apr, - notStakedAmount, - earned, - stakedAmount, - }; - - return ( - - ); -}; - -export default GIVpowerStakingPoolCard; From dd7d2a298c08f5e6a3459c3a9bd7655744e13b80 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 13:46:45 +0330 Subject: [PATCH 013/163] use useStakingPool instead of useGIVpower in GIVpowerCardIntro --- .../cards/StakingCards/GIVpowerCard/GIVpowerCardIntro.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/cards/StakingCards/GIVpowerCard/GIVpowerCardIntro.tsx b/src/components/cards/StakingCards/GIVpowerCard/GIVpowerCardIntro.tsx index 0ec830fda5..68f7d3a6a6 100644 --- a/src/components/cards/StakingCards/GIVpowerCard/GIVpowerCardIntro.tsx +++ b/src/components/cards/StakingCards/GIVpowerCard/GIVpowerCardIntro.tsx @@ -13,7 +13,6 @@ import { useIntl } from 'react-intl'; import styled from 'styled-components'; import Link from 'next/link'; import links from '@/lib/constants/links'; -import { useGIVpower } from '@/context/givpower.context'; import { useAppSelector } from '@/features/hooks'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; import Routes from '@/lib/constants/Routes'; @@ -21,6 +20,9 @@ import { LockupDetailsModal } from '@/components/modals/LockupDetailsModal'; import TotalGIVpowerBox from '@/components/modals/StakeLock/TotalGIVpowerBox'; import { FlexSpacer, Flex } from '@/components/styled-components/Flex'; import { StakeCardState } from '../BaseStakingCard/BaseStakingCard'; +import { getGivStakingConfig } from '@/helpers/networkProvider'; +import { useStakingPool } from '@/hooks/useStakingPool'; +import config from '@/configuration'; import type { Dispatch, FC, SetStateAction } from 'react'; interface IGIVpowerCardIntro { @@ -30,7 +32,9 @@ interface IGIVpowerCardIntro { const GIVpowerCardIntro: FC = ({ setState }) => { const { formatMessage } = useIntl(); const [showLockDetailModal, setShowLockDetailModal] = useState(false); - const { stakedAmount } = useGIVpower(); + const { stakedAmount } = useStakingPool( + getGivStakingConfig(config.XDAI_CONFIG), + ); const currentValues = useAppSelector(state => state.subgraph.currentValues); const sdh = new SubgraphDataHelper(currentValues); From aab45c28e99a19b7ad88f9d235adad07eab7c624 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 13:47:21 +0330 Subject: [PATCH 014/163] separate StakingCardHeader --- .../BaseStakingCard/StakingCardHeader.tsx | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx new file mode 100644 index 0000000000..8c8200f2db --- /dev/null +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx @@ -0,0 +1,83 @@ +import { + IconHelpFilled, + brandColors, + IconHelpFilled16, +} from '@giveth/ui-design-system'; +import { Dispatch, FC, ReactNode, SetStateAction } from 'react'; +import { useIntl } from 'react-intl'; +import { IconWithTooltip } from '@/components/IconWithToolTip'; +import { FlexSpacer } from '@/components/styled-components/Flex'; +import { PoolStakingConfig, StakingType } from '@/types/config'; +import { getPoolIconWithName, StakeCardState } from './BaseStakingCard'; +import { + StakingPoolExchangeRow, + StakingPoolExchange, + GIVgardenTooltip, + IntroIcon, +} from './BaseStakingCard.sc'; +import config from '@/configuration'; + +interface IStakingCardHeaderProps { + poolStakingConfig: PoolStakingConfig; + setState: Dispatch>; + isGIVpower: boolean; + notif?: ReactNode; +} + +export const StakingCardHeader: FC = ({ + poolStakingConfig, + setState, + isGIVpower, + notif, +}) => { + const { formatMessage } = useIntl(); + + const { + type, + platform, + platformTitle, + introCard, + network: poolNetwork, + } = poolStakingConfig; + + return ( + + {getPoolIconWithName(platform, poolNetwork)} + + {platformTitle || platform} + + {poolNetwork === config.XDAI_NETWORK_NUMBER && + type === StakingType.GIV_LM && ( + + } + > + + {formatMessage({ + id: 'label.staking_giv_in_this_pool_allows_to_support_verified_projects', + })} + + + )} + + {notif && notif} + {introCard && ( + setState(StakeCardState.INTRO)}> + + + )} + {isGIVpower && ( + setState(StakeCardState.GIVPOWER_INTRO)} + > + + + )} + + ); +}; From 219f0277015ba6325d8d60e2f3a82f93d62fccfc Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 13:47:42 +0330 Subject: [PATCH 015/163] separate StakingPoolInfoAndActions --- .../BaseStakingCard/BaseStakingCard.tsx | 544 ++---------------- .../StakingPoolInfoAndActions.tsx | 428 ++++++++++++++ 2 files changed, 467 insertions(+), 505 deletions(-) create mode 100644 src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 9b24680b81..03fdf8b1b0 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -1,71 +1,25 @@ import React, { FC, ReactNode, useEffect, useState } from 'react'; -import { - brandColors, - IconExternalLink, - IconHelpFilled, - IconSpark, - Caption, - IconAlertCircle32, - IconHelpFilled16, -} from '@giveth/ui-design-system'; +import { Caption, IconAlertCircle32 } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; -import { constants } from 'ethers'; -import BigNumber from 'bignumber.js'; -import { useWeb3React } from '@web3-react/core'; import { useRouter } from 'next/router'; +import { useWeb3React } from '@web3-react/core'; import { PoolStakingConfig, RegenFarmConfig, RegenPoolStakingConfig, - SimplePoolStakingConfig, StakingPlatform, StakingType, } from '@/types/config'; -import { BN, formatEthHelper, formatWeiHelper } from '@/helpers/number'; import { - AngelVaultTooltip, - ClaimButton, - Detail, - DetailLabel, - Details, - DetailUnit, - DetailValue, - FirstDetail, - GIVgardenTooltip, - HarvestButtonsWrapper, - IconContainer, - IconHelpFilledWrapper, - IntroIcon, - LiquidityButton, - LockInfoTooltip, SPTitle, - StakeAmount, - StakeButton, - StakeButtonsRow, - StakeContainer, - StakePoolInfoContainer, StakingPoolContainer, - StakingPoolExchange, - StakingPoolExchangeRow, StakingPoolLabel, StakingPoolSubtitle, WrongNetworkContainer, } from './BaseStakingCard.sc'; -import { - Flex, - FlexCenter, - FlexSpacer, -} from '@/components/styled-components/Flex'; -import { IStakeInfo } from '@/hooks/useStakingPool'; -import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; -import { useAppSelector } from '@/features/hooks'; -import Routes from '@/lib/constants/Routes'; import { chainName } from '@/lib/constants/constants'; -import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; -import { avgAPR } from '@/helpers/givpower'; import config from '@/configuration'; -import FarmCountDown from '@/components/FarmCountDown'; import { IconAngelVault } from '@/components/Icons/AngelVault'; import { IconBalancer } from '@/components/Icons/Balancer'; import { IconEthereum } from '@/components/Icons/Eth'; @@ -74,25 +28,16 @@ import { IconGnosisChain } from '@/components/Icons/GnosisChain'; import { IconHoneyswap } from '@/components/Icons/Honeyswap'; import { IconSushiswap } from '@/components/Icons/Sushiswap'; import { IconUniswap } from '@/components/Icons/Uniswap'; -import { IconWithTooltip } from '@/components/IconWithToolTip'; import { APRModal } from '@/components/modals/APR'; -import { BridgeGIVModal } from '@/components/modals/BridgeGIV'; import { GIVPowerExplainModal } from '@/components/modals/GIVPowerExplain'; -import { HarvestAllModal } from '@/components/modals/HarvestAll'; -import { LockupDetailsModal } from '@/components/modals/LockupDetailsModal'; -import LockModal from '@/components/modals/StakeLock/Lock'; -import { StakeModal } from '@/components/modals/StakeLock/Stake'; -import { StakeGIVModal } from '@/components/modals/StakeLock/StakeGIV'; -import { UniV3APRModal } from '@/components/modals/UNIv3APR'; -import { UnStakeModal } from '@/components/modals/Unstake/UnStake'; -import { V3StakeModal } from '@/components/modals/V3Stake'; -import { WhatisStreamModal } from '@/components/modals/WhatisStream'; import { StakingPoolImages } from '@/components/StakingPoolImages'; -import { useFarms } from '@/context/farm.context'; -import { getNowUnixMS } from '@/helpers/time'; import GIVpowerCardIntro from '../GIVpowerCard/GIVpowerCardIntro'; import StakingCardIntro from '../StakingCardIntro'; import { ArchiveCover } from './ArchiveCover'; +import { StakingCardHeader } from './StakingCardHeader'; +import Routes from '@/lib/constants/Routes'; +import { getNowUnixMS } from '@/helpers/time'; +import { StakingPoolInfoAndActions } from './StakingPoolInfoAndActions'; import type { LiquidityPosition } from '@/types/nfts'; export enum StakeCardState { @@ -131,7 +76,6 @@ export const getPoolIconWithName = ( }; interface IBaseStakingCardProps { poolStakingConfig: PoolStakingConfig | RegenPoolStakingConfig; - stakeInfo: IStakeInfo; notif?: ReactNode; regenStreamConfig?: RegenFarmConfig; stakedPositions?: LiquidityPosition[]; @@ -142,7 +86,6 @@ interface IBaseStakingCardProps { } const BaseStakingCard: FC = ({ - stakeInfo, poolStakingConfig, notif, regenStreamConfig, @@ -152,7 +95,6 @@ const BaseStakingCard: FC = ({ }) => { const { formatMessage } = useIntl(); const [state, setState] = useState(StakeCardState.NORMAL); - const [started, setStarted] = useState(true); const [showAPRModal, setShowAPRModal] = useState(false); const [showUniV3APRModal, setShowUniV3APRModal] = useState(false); const [showStakeModal, setShowStakeModal] = useState(false); @@ -163,53 +105,26 @@ const BaseStakingCard: FC = ({ const [showGIVPowerExplain, setShowGIVPowerExplain] = useState(false); const [showWhatIsGIVstreamModal, setShowWhatIsGIVstreamModal] = useState(false); - const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); const [showLockDetailModal, setShowLockDetailModal] = useState(false); - const [rewardStream, setRewardStream] = useState(0); - const [tokenDistroHelper, setTokenDistroHelper] = - useState(); + const router = useRouter(); - const { setInfo } = useFarms(); + const { chainId, account, active: isWalletActive } = useWeb3React(); - const { mainnetValues, xDaiValues } = useAppSelector( - state => state.subgraph, - ); const { regenStreamType } = poolStakingConfig as RegenPoolStakingConfig; const { type, - platform, - platformTitle, title, icon, description, provideLiquidityLink, unit, - farmStartTimeMS, farmEndTimeMS, exploited, - introCard, network: poolNetwork, } = poolStakingConfig; - const currentValues = - poolNetwork === config.XDAI_NETWORK_NUMBER ? xDaiValues : mainnetValues; - const sdh = new SubgraphDataHelper(currentValues); - - const { - apr, - earned, - stakedAmount: stakedLpAmount, - notStakedAmount: userNotStakedAmount, - } = stakeInfo; - - const userGIVLocked = sdh.getUserGIVLockedBalance(); - const userGIVPowerBalance = sdh.getUserGIVPowerBalance(); - const isDiscontinued = farmEndTimeMS - ? getNowUnixMS() > farmEndTimeMS - : false; - useEffect(() => { if (isFirstStakeShown || !router) return; const { open, chain } = router.query; @@ -237,52 +152,15 @@ const BaseStakingCard: FC = ({ checkNetworkAndShowStakeModal(); }, [router, account, isWalletActive]); - useEffect(() => { - if (regenStreamType) { - setTokenDistroHelper( - new TokenDistroHelper( - sdh.getTokenDistro( - regenStreamConfig?.tokenDistroAddress as string, - ), - ), - ); - } else { - setTokenDistroHelper( - new TokenDistroHelper(sdh.getGIVTokenDistro()), - ); - } - }, [currentValues, poolStakingConfig, regenStreamConfig]); - - useEffect(() => { - if (tokenDistroHelper) { - setRewardLiquidPart(tokenDistroHelper.getLiquidPart(earned)); - setRewardStream( - tokenDistroHelper.getStreamPartTokenPerWeek(earned), - ); - } - }, [earned, tokenDistroHelper]); - useEffect(() => { - if (!(exploited || regenStreamConfig)) - setInfo(poolNetwork, type, earned); - }, [poolNetwork, earned, type, regenStreamConfig, setInfo]); - - const rewardTokenSymbol = regenStreamConfig?.rewardTokenSymbol || 'GIV'; - - useEffect(() => { - setStarted(farmStartTimeMS ? getNowUnixMS() > farmStartTimeMS : true); - }, [farmStartTimeMS]); - const isGIVStaking = type === StakingType.GIV_LM; const isBridge = isGIVStaking && poolNetwork === config.MAINNET_NETWORK_NUMBER; const isGIVpower = isGIVStaking && poolNetwork === config.XDAI_NETWORK_NUMBER; - const isLocked = isGIVpower && userGIVLocked.balance !== '0'; - const isZeroGIVStacked = - isGIVpower && (!account || userGIVPowerBalance.balance === '0'); - const availableStakedToken = isGIVpower - ? stakedLpAmount.sub(userGIVLocked.balance) - : stakedLpAmount; + + const isDiscontinued = farmEndTimeMS + ? getNowUnixMS() > farmEndTimeMS + : false; return ( <> @@ -308,50 +186,12 @@ const BaseStakingCard: FC = ({ )} {state === StakeCardState.NORMAL ? ( <> - - {getPoolIconWithName(platform, poolNetwork)} - - {platformTitle || platform} - - {poolNetwork === config.XDAI_NETWORK_NUMBER && - type === StakingType.GIV_LM && ( - - } - > - - {formatMessage({ - id: 'label.staking_giv_in_this_pool_allows_to_support_verified_projects', - })} - - - )} - - {notif && notif} - {introCard && ( - - setState(StakeCardState.INTRO) - } - > - - - )} - {isGIVpower && ( - - setState(StakeCardState.GIVPOWER_INTRO) - } - > - - - )} - +
@@ -363,318 +203,13 @@ const BaseStakingCard: FC = ({
- - {started ? ( -
- - - APR - {type === - StakingType.ICHI_GIV_ONEGIV && ( - } - > - - {formatMessage({ - id: 'label.your_cummulative_apr_including_both_rewards', - })}{' '} - ( - {apr?.vaultIRR && - formatEthHelper( - apr.vaultIRR, - )} - % IRR),{' '} - {formatMessage({ - id: 'label.and_rewards_earned_in_giv', - })}{' '} - ( - {apr && - formatEthHelper( - apr.effectiveAPR, - )} - % APR). - - - )} - {isGIVpower && ( - } - > - - {isZeroGIVStacked - ? formatMessage({ - id: 'label.this_is_the_range_of_possible_apr', - }) - : `${formatMessage({ - id: 'label.this_is_the_weighed_average_apr', - })} ${ - apr && - formatEthHelper( - apr.effectiveAPR, - ) - }%-${ - apr && - formatEthHelper( - apr.effectiveAPR.multipliedBy( - 5.2, // sqrt(1 + max rounds) - ), - ) - }%. ${formatMessage( - { - id: 'label.lock_your_giv_for_longer', - }, - )}`} - - - )} - - - {!(exploited || isDiscontinued) ? ( - <> - - <> - - {apr && - formatEthHelper( - isLocked - ? avgAPR( - apr.effectiveAPR, - stakedLpAmount.toString(), - userGIVPowerBalance.balance, - ) - : apr.effectiveAPR, - )} - % - {isZeroGIVStacked && - `-${ - apr && - formatEthHelper( - apr.effectiveAPR.multipliedBy( - 5.2, // sqrt(1 + max rounds) - ), - ) - }%`} - - - setShowAPRModal( - true, - ) - } - > - - - - - ) : ( -
- {formatMessage({ - id: 'label.n/a', - })}{' '} - % -
- )} -
-
- - - {formatMessage({ - id: 'label.claimable', - })} - - - {!exploited ? ( - `${formatWeiHelper( - rewardLiquidPart, - )} ${rewardTokenSymbol}` - ) : ( -
- {formatMessage({ - id: 'label.n/a', - })} -
- )} -
-
- - - - {formatMessage({ - id: 'label.streaming', - })} - - { - setShowWhatIsGIVstreamModal( - true, - ); - }} - > - - - - - - {!exploited ? ( - formatWeiHelper( - rewardStream, - ) - ) : ( -
- {formatMessage({ - id: 'label.n/a', - })} -
- )} -
- - {rewardTokenSymbol} - {formatMessage({ - id: 'label./week', - })} - -
-
-
- ) : ( - - )} - - setShowHarvestModal(true)} - label={formatMessage({ - id: 'label.harvest_rewards', - })} - buttonType={ - isGIVpower ? 'secondary' : 'primary' - } - /> - {isGIVpower && ( - setShowLockModal(true)} - label={formatMessage({ - id: 'label.increase_rewards', - })} - buttonType='primary' - /> - )} - - - - setShowStakeModal(true)} - /> - - {type === StakingType.UNISWAPV3_ETH_GIV - ? `${userNotStakedAmount.toNumber()} ${unit}` - : `${formatWeiHelper( - userNotStakedAmount, - )} ${unit}`} - - - - - setShowUnStakeModal(true) - } - /> - - - {type === - StakingType.UNISWAPV3_ETH_GIV - ? `${stakedLpAmount.toNumber()} ${unit}` - : `${formatWeiHelper( - stakedLpAmount, - )} ${unit}`} - - {isLocked && ( - } - direction={'top'} - > - - {formatMessage({ - id: 'label.some_or_all_of_your_staked_giv_is_locked', - })} - - - )} - - - - {!(exploited || isDiscontinued) && - (!isGIVpower ? ( - - { - if ( - type === - StakingType.UNISWAPV3_ETH_GIV - ) { - setShowUniV3APRModal(true); - } else { - window.open( - provideLiquidityLink, - ); - } - }} - buttonType='texty' - icon={ - - } - /> - - ) : ( - { - setShowLockDetailModal(true); - }} - /> - ))} -
+ ) : state === StakeCardState.GIVPOWER_INTRO ? ( @@ -692,17 +227,16 @@ const BaseStakingCard: FC = ({ {showAPRModal && ( )} - {showUniV3APRModal && ( + {/* {showUniV3APRModal && ( - )} - {showStakeModal && + )} */} + {/* {showStakeModal && (type === StakingType.UNISWAPV3_ETH_GIV ? ( = ({ regenStreamConfig={regenStreamConfig} maxAmount={userNotStakedAmount} /> - ))} - {showUnStakeModal && + ))} */} + {/* {showUnStakeModal && (type === StakingType.UNISWAPV3_ETH_GIV ? ( = ({ regenStreamConfig={regenStreamConfig} maxAmount={availableStakedToken} /> - ))} - {showHarvestModal && chainId && ( + ))} */} + {/* {showHarvestModal && chainId && ( = ({ stakedPositions={stakedPositions} currentIncentive={currentIncentive} /> - )} - {showLockModal && ( + )} */} + {/* {showLockModal && ( - )} - {showWhatIsGIVstreamModal && ( + )} */} + {/* {showWhatIsGIVstreamModal && ( - )} - {showLockDetailModal && ( + )} */} + {/* {showLockDetailModal && ( - )} + )} */} ); }; diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx new file mode 100644 index 0000000000..36f000a202 --- /dev/null +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -0,0 +1,428 @@ +import { + IconHelpFilled16, + IconSpark, + brandColors, + IconHelpFilled, + IconExternalLink, +} from '@giveth/ui-design-system'; +import { FC, useEffect, useState } from 'react'; +import { useIntl } from 'react-intl'; +import BigNumber from 'bignumber.js'; +import { constants } from 'ethers'; +import { useWeb3React } from '@web3-react/core'; +import FarmCountDown from '@/components/FarmCountDown'; +import { IconWithTooltip } from '@/components/IconWithToolTip'; +import { FlexCenter, Flex } from '@/components/styled-components/Flex'; +import { avgAPR } from '@/helpers/givpower'; +import { BN, formatEthHelper, formatWeiHelper } from '@/helpers/number'; +import { + PoolStakingConfig, + RegenFarmConfig, + RegenPoolStakingConfig, + StakingType, +} from '@/types/config'; +import { + Details, + FirstDetail, + DetailLabel, + AngelVaultTooltip, + DetailValue, + IconContainer, + Detail, + IconHelpFilledWrapper, + DetailUnit, + StakePoolInfoContainer, + ClaimButton, + HarvestButtonsWrapper, + LiquidityButton, + LockInfoTooltip, + StakeAmount, + StakeButton, + StakeButtonsRow, + StakeContainer, +} from './BaseStakingCard.sc'; +import { getNowUnixMS } from '@/helpers/time'; +import { useStakingPool } from '@/hooks/useStakingPool'; +import config from '@/configuration'; +import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; +import { useAppSelector } from '@/features/hooks'; +import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; +import { useFarms } from '@/context/farm.context'; +interface IStakingPoolInfoAndActionsProps { + poolStakingConfig: PoolStakingConfig | RegenPoolStakingConfig; + regenStreamConfig?: RegenFarmConfig; + isDiscontinued: boolean; + isGIVpower: boolean; + setShowAPRModal: React.Dispatch>; +} + +export const StakingPoolInfoAndActions: FC = ({ + poolStakingConfig, + regenStreamConfig, + isDiscontinued, + isGIVpower, + setShowAPRModal, +}) => { + const [started, setStarted] = useState(true); + const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); + const [rewardStream, setRewardStream] = useState(0); + const [tokenDistroHelper, setTokenDistroHelper] = + useState(); + + const { mainnetValues, xDaiValues } = useAppSelector( + state => state.subgraph, + ); + const { formatMessage } = useIntl(); + const { setInfo } = useFarms(); + const { chainId, account, active: isWalletActive } = useWeb3React(); + const { + apr, + notStakedAmount: userNotStakedAmount, + stakedAmount: stakedLpAmount, + earned, + } = useStakingPool(poolStakingConfig); + + const { regenStreamType } = poolStakingConfig as RegenPoolStakingConfig; + + const { + type, + provideLiquidityLink, + unit, + farmStartTimeMS, + farmEndTimeMS, + exploited, + network: poolNetwork, + } = poolStakingConfig; + + const currentValues = + poolNetwork === config.XDAI_NETWORK_NUMBER ? xDaiValues : mainnetValues; + const sdh = new SubgraphDataHelper(currentValues); + + const userGIVLocked = sdh.getUserGIVLockedBalance(); + + useEffect(() => { + setStarted(farmStartTimeMS ? getNowUnixMS() > farmStartTimeMS : true); + }, [farmStartTimeMS]); + + useEffect(() => { + if (regenStreamType) { + setTokenDistroHelper( + new TokenDistroHelper( + sdh.getTokenDistro( + regenStreamConfig?.tokenDistroAddress as string, + ), + ), + ); + } else { + setTokenDistroHelper( + new TokenDistroHelper(sdh.getGIVTokenDistro()), + ); + } + }, [currentValues, poolStakingConfig, regenStreamConfig]); + + useEffect(() => { + if (!(exploited || regenStreamConfig)) + setInfo(poolNetwork, type, earned); + }, [poolNetwork, earned, type, regenStreamConfig, setInfo]); + + const isLocked = isGIVpower && userGIVLocked.balance !== '0'; + + const availableStakedToken = isGIVpower + ? stakedLpAmount.sub(userGIVLocked.balance) + : stakedLpAmount; + + useEffect(() => { + if (tokenDistroHelper) { + setRewardLiquidPart(tokenDistroHelper.getLiquidPart(earned)); + setRewardStream( + tokenDistroHelper.getStreamPartTokenPerWeek(earned), + ); + } + }, [earned, tokenDistroHelper]); + + const userGIVPowerBalance = sdh.getUserGIVPowerBalance(); + const rewardTokenSymbol = regenStreamConfig?.rewardTokenSymbol || 'GIV'; + const isZeroGIVStacked = + isGIVpower && (!account || userGIVPowerBalance.balance === '0'); + + return ( + + {started ? ( +
+ + + APR + {type === StakingType.ICHI_GIV_ONEGIV && ( + } + > + + {formatMessage({ + id: 'label.your_cummulative_apr_including_both_rewards', + })}{' '} + ( + {apr?.vaultIRR && + formatEthHelper(apr.vaultIRR)} + % IRR),{' '} + {formatMessage({ + id: 'label.and_rewards_earned_in_giv', + })}{' '} + ( + {apr && + formatEthHelper(apr.effectiveAPR)} + % APR). + + + )} + {isGIVpower && ( + } + > + + {isZeroGIVStacked + ? formatMessage({ + id: 'label.this_is_the_range_of_possible_apr', + }) + : `${formatMessage({ + id: 'label.this_is_the_weighed_average_apr', + })} ${ + apr && + formatEthHelper( + apr.effectiveAPR, + ) + }%-${ + apr && + formatEthHelper( + apr.effectiveAPR.multipliedBy( + 5.2, // sqrt(1 + max rounds) + ), + ) + }%. ${formatMessage({ + id: 'label.lock_your_giv_for_longer', + })}`} + + + )} + + + {!(exploited || isDiscontinued) ? ( + <> + + <> + + {apr && + formatEthHelper( + isLocked + ? avgAPR( + apr.effectiveAPR, + stakedLpAmount.toString(), + userGIVPowerBalance.balance, + ) + : apr.effectiveAPR, + )} + % + {isZeroGIVStacked && + `-${ + apr && + formatEthHelper( + apr.effectiveAPR.multipliedBy( + 5.2, // sqrt(1 + max rounds) + ), + ) + }%`} + + + setShowAPRModal(true) + } + > + + + + + ) : ( +
+ {formatMessage({ + id: 'label.n/a', + })}{' '} + % +
+ )} +
+
+ + + {formatMessage({ + id: 'label.claimable', + })} + + + {!exploited ? ( + `${formatWeiHelper( + rewardLiquidPart, + )} ${rewardTokenSymbol}` + ) : ( +
+ {formatMessage({ + id: 'label.n/a', + })} +
+ )} +
+
+ + + + {formatMessage({ + id: 'label.streaming', + })} + + { + // setShowWhatIsGIVstreamModal(true); + // }} + > + + + + + + {!exploited ? ( + formatWeiHelper(rewardStream) + ) : ( +
+ {formatMessage({ + id: 'label.n/a', + })} +
+ )} +
+ + {rewardTokenSymbol} + {formatMessage({ + id: 'label./week', + })} + +
+
+
+ ) : ( + + )} + + setShowHarvestModal(true)} + label={formatMessage({ + id: 'label.harvest_rewards', + })} + buttonType={isGIVpower ? 'secondary' : 'primary'} + /> + {isGIVpower && ( + setShowLockModal(true)} + label={formatMessage({ + id: 'label.increase_rewards', + })} + buttonType='primary' + /> + )} + + + + setShowStakeModal(true)} + /> + + {type === StakingType.UNISWAPV3_ETH_GIV + ? `${userNotStakedAmount.toNumber()} ${unit}` + : `${formatWeiHelper(userNotStakedAmount)} ${unit}`} + + + + setShowUnStakeModal(true)} + /> + + + {type === StakingType.UNISWAPV3_ETH_GIV + ? `${stakedLpAmount.toNumber()} ${unit}` + : `${formatWeiHelper(stakedLpAmount)} ${unit}`} + + {isLocked && ( + } + direction={'top'} + > + + {formatMessage({ + id: 'label.some_or_all_of_your_staked_giv_is_locked', + })} + + + )} + + + + {!(exploited || isDiscontinued) && + (!isGIVpower ? ( + + { + // if (type === StakingType.UNISWAPV3_ETH_GIV) { + // setShowUniV3APRModal(true); + // } else { + // window.open(provideLiquidityLink); + // } + // }} + buttonType='texty' + icon={ + + } + /> + + ) : ( + { + // setShowLockDetailModal(true); + // }} + /> + ))} +
+ ); +}; From c67dc3a75a43c7b09eee1cf9a0b511dfaa86afa9 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 14:00:15 +0330 Subject: [PATCH 016/163] remove stake card from StakingPoolCard --- src/components/cards/StakingCards/StakingPoolCard.tsx | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/components/cards/StakingCards/StakingPoolCard.tsx b/src/components/cards/StakingCards/StakingPoolCard.tsx index da591f533e..4809ba717e 100644 --- a/src/components/cards/StakingCards/StakingPoolCard.tsx +++ b/src/components/cards/StakingCards/StakingPoolCard.tsx @@ -1,4 +1,3 @@ -import { useStakingPool } from '@/hooks/useStakingPool'; import BaseStakingCard from './BaseStakingCard/BaseStakingCard'; import type { RegenFarmConfig, @@ -15,18 +14,8 @@ const StakingPoolCard: FC = ({ poolStakingConfig, regenStreamConfig, }) => { - const { apr, notStakedAmount, stakedAmount, earned } = - useStakingPool(poolStakingConfig); - const stakeInfo = { - apr: apr, - notStakedAmount: notStakedAmount, - earned: earned, - stakedAmount: stakedAmount, - }; - return ( From 48c39ecca18acf236089edc9a7f2661449723e5c Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 14:00:28 +0330 Subject: [PATCH 017/163] remove stake card from StakingPositionCard --- .../cards/StakingCards/PositionCard/StakingPositionCard.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/cards/StakingCards/PositionCard/StakingPositionCard.tsx b/src/components/cards/StakingCards/PositionCard/StakingPositionCard.tsx index a8817bb359..72a26a8e21 100644 --- a/src/components/cards/StakingCards/PositionCard/StakingPositionCard.tsx +++ b/src/components/cards/StakingCards/PositionCard/StakingPositionCard.tsx @@ -60,7 +60,6 @@ const StakingPositionCard: FC = ({ return ( Date: Thu, 23 Feb 2023 15:45:06 +0330 Subject: [PATCH 018/163] add useTokenDistroHelper --- src/hooks/useTokenDistroHelper.tsx | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/hooks/useTokenDistroHelper.tsx diff --git a/src/hooks/useTokenDistroHelper.tsx b/src/hooks/useTokenDistroHelper.tsx new file mode 100644 index 0000000000..534e3fda08 --- /dev/null +++ b/src/hooks/useTokenDistroHelper.tsx @@ -0,0 +1,39 @@ +import { useState, useEffect } from 'react'; +import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; +import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; +import config from '@/configuration'; +import { StreamType, RegenFarmConfig } from '@/types/config'; +import { useAppSelector } from '@/features/hooks'; + +export const useTokenDistroHelper = ( + poolNetwork: number, + regenStreamType?: StreamType, + regenStreamConfig?: RegenFarmConfig, +) => { + const [tokenDistroHelper, setTokenDistroHelper] = + useState(); + + const { mainnetValues, xDaiValues } = useAppSelector( + state => state.subgraph, + ); + const currentValues = + poolNetwork === config.XDAI_NETWORK_NUMBER ? xDaiValues : mainnetValues; + const sdh = new SubgraphDataHelper(currentValues); + + useEffect(() => { + if (regenStreamType) { + setTokenDistroHelper( + new TokenDistroHelper( + sdh.getTokenDistro( + regenStreamConfig?.tokenDistroAddress as string, + ), + ), + ); + } else { + setTokenDistroHelper( + new TokenDistroHelper(sdh.getGIVTokenDistro()), + ); + } + }, [currentValues, regenStreamConfig, regenStreamType]); + return { tokenDistroHelper, sdh }; +}; From acb228ac42b61338831e2533c5a88c1017a28279 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 15:45:19 +0330 Subject: [PATCH 019/163] use useTokenDistroHelper in StakingPoolInfoAndActions --- .../StakingPoolInfoAndActions.tsx | 37 +++---------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index 36f000a202..486d3a12c1 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -43,11 +43,8 @@ import { } from './BaseStakingCard.sc'; import { getNowUnixMS } from '@/helpers/time'; import { useStakingPool } from '@/hooks/useStakingPool'; -import config from '@/configuration'; -import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; -import { useAppSelector } from '@/features/hooks'; -import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; import { useFarms } from '@/context/farm.context'; +import { useTokenDistroHelper } from '@/hooks/useTokenDistroHelper'; interface IStakingPoolInfoAndActionsProps { poolStakingConfig: PoolStakingConfig | RegenPoolStakingConfig; regenStreamConfig?: RegenFarmConfig; @@ -66,12 +63,7 @@ export const StakingPoolInfoAndActions: FC = ({ const [started, setStarted] = useState(true); const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); const [rewardStream, setRewardStream] = useState(0); - const [tokenDistroHelper, setTokenDistroHelper] = - useState(); - const { mainnetValues, xDaiValues } = useAppSelector( - state => state.subgraph, - ); const { formatMessage } = useIntl(); const { setInfo } = useFarms(); const { chainId, account, active: isWalletActive } = useWeb3React(); @@ -86,17 +78,16 @@ export const StakingPoolInfoAndActions: FC = ({ const { type, - provideLiquidityLink, unit, farmStartTimeMS, - farmEndTimeMS, exploited, network: poolNetwork, } = poolStakingConfig; - - const currentValues = - poolNetwork === config.XDAI_NETWORK_NUMBER ? xDaiValues : mainnetValues; - const sdh = new SubgraphDataHelper(currentValues); + const { tokenDistroHelper, sdh } = useTokenDistroHelper( + poolNetwork, + regenStreamType, + regenStreamConfig, + ); const userGIVLocked = sdh.getUserGIVLockedBalance(); @@ -104,22 +95,6 @@ export const StakingPoolInfoAndActions: FC = ({ setStarted(farmStartTimeMS ? getNowUnixMS() > farmStartTimeMS : true); }, [farmStartTimeMS]); - useEffect(() => { - if (regenStreamType) { - setTokenDistroHelper( - new TokenDistroHelper( - sdh.getTokenDistro( - regenStreamConfig?.tokenDistroAddress as string, - ), - ), - ); - } else { - setTokenDistroHelper( - new TokenDistroHelper(sdh.getGIVTokenDistro()), - ); - } - }, [currentValues, poolStakingConfig, regenStreamConfig]); - useEffect(() => { if (!(exploited || regenStreamConfig)) setInfo(poolNetwork, type, earned); From 57308687db51fad40169e1f5d554c2ad1b470a70 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:12:49 +0330 Subject: [PATCH 020/163] fix apr modal --- .../BaseStakingCard/BaseStakingCard.tsx | 2 + src/components/modals/APR.tsx | 55 ++++++++++++++----- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 03fdf8b1b0..a3659d4550 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -228,6 +228,8 @@ const BaseStakingCard: FC = ({ )} {/* {showUniV3APRModal && ( diff --git a/src/components/modals/APR.tsx b/src/components/modals/APR.tsx index b95c956223..0542aab7ea 100644 --- a/src/components/modals/APR.tsx +++ b/src/components/modals/APR.tsx @@ -11,20 +11,24 @@ import { import { Modal } from './Modal'; import { Flex } from '../styled-components/Flex'; import { IModal } from '@/types/common'; -import { useModalAnimation } from '@/hooks/useModalAnimation'; import { mediaQueries } from '@/lib/constants/constants'; -import { RegenFarmConfig } from '@/types/config'; +import { RegenFarmConfig, StreamType } from '@/types/config'; +import { useTokenDistroHelper } from '@/hooks/useTokenDistroHelper'; +import { useModalAnimation } from '@/hooks/useModalAnimation'; interface IAPRModalProps extends IModal { + poolNetwork: number; regenStreamConfig?: RegenFarmConfig; + regenStreamType?: StreamType; } export const APRModal: FC = ({ setShowModal, regenStreamConfig, + poolNetwork, + regenStreamType, }) => { const { rewardTokenSymbol = 'GIV' } = regenStreamConfig || {}; - const streamName = regenStreamConfig ? 'RegenStream' : 'GIVstream'; const { isAnimating, closeModal } = useModalAnimation(setShowModal); @@ -53,23 +57,46 @@ export const APRModal: FC = ({ total earnings will be claimable immediately. Current Distribution: - - Claimable immediately:{' '} - {/* {tokenDistroHelper?.GlobalReleasePercentage.toFixed(2)}% */} - - - Increasing your {streamName}:{' '} - {(100) - // (tokenDistroHelper?.GlobalReleasePercentage || 0) - .toFixed(2)} - % - + ); }; +const Content: FC<{ + poolNetwork: number; + regenStreamConfig?: RegenFarmConfig; + regenStreamType?: StreamType; +}> = ({ regenStreamConfig, poolNetwork, regenStreamType }) => { + const { tokenDistroHelper } = useTokenDistroHelper( + poolNetwork, + regenStreamType, + regenStreamConfig, + ); + const streamName = regenStreamConfig ? 'RegenStream' : 'GIVstream'; + + return ( + <> + + Claimable immediately:{' '} + {tokenDistroHelper?.GlobalReleasePercentage.toFixed(2)}% + + + Increasing your {streamName}:{' '} + {( + 100 - (tokenDistroHelper?.GlobalReleasePercentage || 0) + ).toFixed(2)} + % + + + ); +}; + const APRModalContainer = styled.div` padding: 16px 24px; margin-bottom: 22px; From d0585f0e1dac5cedea050701b88e8cfceec52864 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:27:22 +0330 Subject: [PATCH 021/163] fix unStake stakedAmount --- src/components/modals/Unstake/UnStake.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/modals/Unstake/UnStake.tsx b/src/components/modals/Unstake/UnStake.tsx index 05bf676873..fde0206330 100644 --- a/src/components/modals/Unstake/UnStake.tsx +++ b/src/components/modals/Unstake/UnStake.tsx @@ -32,8 +32,9 @@ import { formatWeiHelper } from '@/helpers/number'; import { LockupDetailsModal } from '../LockupDetailsModal'; import { mediaQueries } from '@/lib/constants/constants'; import { useModalAnimation } from '@/hooks/useModalAnimation'; -import { useGIVpower } from '@/context/givpower.context'; import config from '@/configuration'; +import { getGivStakingConfig } from '@/helpers/networkProvider'; +import { useStakingPool } from '@/hooks/useStakingPool'; interface IUnStakeModalProps extends IModal { poolStakingConfig: PoolStakingConfig; @@ -53,7 +54,9 @@ export const UnStakeModal: FC = ({ const [unStakeState, setUnstakeState] = useState( StakeState.UNSTAKE, ); - const { stakedAmount } = useGIVpower(); + const { stakedAmount } = useStakingPool( + getGivStakingConfig(config.XDAI_CONFIG), + ); const { library, chainId } = useWeb3React(); const { isAnimating, closeModal } = useModalAnimation(setShowModal); const { title, type, LM_ADDRESS, GARDEN_ADDRESS } = From 2599dbb2fa1b3888911d6d90d830f2ddbd96f69c Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:27:44 +0330 Subject: [PATCH 022/163] fix LockInfo apr --- src/components/modals/StakeLock/LockInfo.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/modals/StakeLock/LockInfo.tsx b/src/components/modals/StakeLock/LockInfo.tsx index da13ad611a..05f5685929 100644 --- a/src/components/modals/StakeLock/LockInfo.tsx +++ b/src/components/modals/StakeLock/LockInfo.tsx @@ -13,8 +13,10 @@ import styled from 'styled-components'; import BigNumber from 'bignumber.js'; import { Flex } from '@/components/styled-components/Flex'; import { IconWithTooltip } from '@/components/IconWithToolTip'; -import { useGIVpower } from '@/context/givpower.context'; import { formatEthHelper, formatWeiHelper } from '@/helpers/number'; +import { getGivStakingConfig } from '@/helpers/networkProvider'; +import { useStakingPool } from '@/hooks/useStakingPool'; +import config from '@/configuration'; import type { FC } from 'react'; interface ILockInfo { @@ -23,7 +25,7 @@ interface ILockInfo { } const LockInfo: FC = ({ round, amount }) => { - const { apr } = useGIVpower(); + const { apr } = useStakingPool(getGivStakingConfig(config.XDAI_CONFIG)); const multipler = Math.sqrt(1 + round); return ( From 6fe274da84809a5220885c691c02a6afbedf7ea6 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:32:45 +0330 Subject: [PATCH 023/163] move maxAmount calculation to the stake modal --- src/components/modals/StakeLock/Stake.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/modals/StakeLock/Stake.tsx b/src/components/modals/StakeLock/Stake.tsx index 49c0e9032f..0946253a06 100644 --- a/src/components/modals/StakeLock/Stake.tsx +++ b/src/components/modals/StakeLock/Stake.tsx @@ -39,17 +39,16 @@ import { StakingPlatform, } from '@/types/config'; import LottieControl from '@/components/animations/lottieControl'; +import { useStakingPool } from '@/hooks/useStakingPool'; interface IStakeModalProps extends IModal { poolStakingConfig: PoolStakingConfig; regenStreamConfig?: RegenFarmConfig; - maxAmount: BigNumber; } export const StakeModal: FC = ({ poolStakingConfig, regenStreamConfig, - maxAmount, setShowModal, }) => { const [amount, setAmount] = useState('0'); @@ -60,6 +59,7 @@ export const StakeModal: FC = ({ ); const { chainId, library } = useWeb3React(); const { isAnimating, closeModal } = useModalAnimation(setShowModal); + const { notStakedAmount: maxAmount } = useStakingPool(poolStakingConfig); const { title, LM_ADDRESS, POOL_ADDRESS, platform } = poolStakingConfig as SimplePoolStakingConfig; From 4a33f385092746389a5ad3213779206b3eaa5103 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:32:54 +0330 Subject: [PATCH 024/163] move maxAmount calculation to the stakeGIV modal --- src/components/modals/StakeLock/StakeGIV.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/modals/StakeLock/StakeGIV.tsx b/src/components/modals/StakeLock/StakeGIV.tsx index d995da5858..c65b291104 100644 --- a/src/components/modals/StakeLock/StakeGIV.tsx +++ b/src/components/modals/StakeLock/StakeGIV.tsx @@ -27,6 +27,7 @@ import { formatWeiHelper } from '@/helpers/number'; import LockInfo from './LockInfo'; import { useModalAnimation } from '@/hooks/useModalAnimation'; import config from '@/configuration'; +import { useStakingPool } from '@/hooks/useStakingPool'; import type { PoolStakingConfig, SimplePoolStakingConfig, @@ -34,7 +35,6 @@ import type { interface IStakeModalProps extends IModal { poolStakingConfig: PoolStakingConfig; - maxAmount: BigNumber; showLockModal: () => void; } @@ -49,7 +49,6 @@ export const loadingAnimationOptions = { export const StakeGIVModal: FC = ({ poolStakingConfig, - maxAmount, showLockModal, setShowModal, }) => { @@ -60,6 +59,7 @@ export const StakeGIVModal: FC = ({ ); const { chainId, library } = useWeb3React(); const { isAnimating, closeModal } = useModalAnimation(setShowModal); + const { notStakedAmount: maxAmount } = useStakingPool(poolStakingConfig); const { POOL_ADDRESS, GARDEN_ADDRESS } = poolStakingConfig as SimplePoolStakingConfig; From 8cc667493e7bb8476c7f786c1f58eda459fd298f Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:33:23 +0330 Subject: [PATCH 025/163] add setShowStakeModal to StakingPoolInfoAndActions --- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index 486d3a12c1..d15aa9888d 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -51,6 +51,7 @@ interface IStakingPoolInfoAndActionsProps { isDiscontinued: boolean; isGIVpower: boolean; setShowAPRModal: React.Dispatch>; + setShowStakeModal: React.Dispatch>; } export const StakingPoolInfoAndActions: FC = ({ @@ -59,6 +60,7 @@ export const StakingPoolInfoAndActions: FC = ({ isDiscontinued, isGIVpower, setShowAPRModal, + setShowStakeModal, }) => { const [started, setStarted] = useState(true); const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); @@ -324,7 +326,7 @@ export const StakingPoolInfoAndActions: FC = ({ exploited || BN(userNotStakedAmount).isZero() } - // onClick={() => setShowStakeModal(true)} + onClick={() => setShowStakeModal(true)} /> {type === StakingType.UNISWAPV3_ETH_GIV From ebf97f0939e65745217002b1f43ccd9c934ea716 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:33:53 +0330 Subject: [PATCH 026/163] add StakeGIVModal and StakeModal --- .../BaseStakingCard/BaseStakingCard.tsx | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index a3659d4550..c977276bef 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -7,6 +7,7 @@ import { PoolStakingConfig, RegenFarmConfig, RegenPoolStakingConfig, + SimplePoolStakingConfig, StakingPlatform, StakingType, } from '@/types/config'; @@ -38,6 +39,8 @@ import { StakingCardHeader } from './StakingCardHeader'; import Routes from '@/lib/constants/Routes'; import { getNowUnixMS } from '@/helpers/time'; import { StakingPoolInfoAndActions } from './StakingPoolInfoAndActions'; +import { StakeModal } from '@/components/modals/StakeLock/Stake'; +import { StakeGIVModal } from '@/components/modals/StakeLock/StakeGIV'; import type { LiquidityPosition } from '@/types/nfts'; export enum StakeCardState { @@ -153,8 +156,6 @@ const BaseStakingCard: FC = ({ }, [router, account, isWalletActive]); const isGIVStaking = type === StakingType.GIV_LM; - const isBridge = - isGIVStaking && poolNetwork === config.MAINNET_NETWORK_NUMBER; const isGIVpower = isGIVStaking && poolNetwork === config.XDAI_NETWORK_NUMBER; @@ -209,6 +210,7 @@ const BaseStakingCard: FC = ({ isDiscontinued={isDiscontinued} isGIVpower={isGIVpower} setShowAPRModal={setShowAPRModal} + setShowStakeModal={setShowStakeModal} /> ) : state === StakeCardState.GIVPOWER_INTRO ? ( @@ -238,30 +240,15 @@ const BaseStakingCard: FC = ({ poolStakingConfig={poolStakingConfig} /> )} */} - {/* {showStakeModal && - (type === StakingType.UNISWAPV3_ETH_GIV ? ( - - ) : isGIVpower ? ( + {showStakeModal && + (isGIVpower ? ( setShowLockModal(true)} /> - ) : isBridge ? ( - ) : ( = ({ poolStakingConfig as SimplePoolStakingConfig } regenStreamConfig={regenStreamConfig} - maxAmount={userNotStakedAmount} /> - ))} */} + ))} {/* {showUnStakeModal && (type === StakingType.UNISWAPV3_ETH_GIV ? ( Date: Thu, 23 Feb 2023 16:37:42 +0330 Subject: [PATCH 027/163] fix apr modal interfaces --- src/components/modals/APR.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/modals/APR.tsx b/src/components/modals/APR.tsx index 0542aab7ea..9a45711511 100644 --- a/src/components/modals/APR.tsx +++ b/src/components/modals/APR.tsx @@ -16,12 +16,14 @@ import { RegenFarmConfig, StreamType } from '@/types/config'; import { useTokenDistroHelper } from '@/hooks/useTokenDistroHelper'; import { useModalAnimation } from '@/hooks/useModalAnimation'; -interface IAPRModalProps extends IModal { +interface IAPRInnerModalProps { poolNetwork: number; regenStreamConfig?: RegenFarmConfig; regenStreamType?: StreamType; } +interface IAPRModalProps extends IModal, IAPRInnerModalProps {} + export const APRModal: FC = ({ setShowModal, regenStreamConfig, @@ -68,11 +70,11 @@ export const APRModal: FC = ({ ); }; -const Content: FC<{ - poolNetwork: number; - regenStreamConfig?: RegenFarmConfig; - regenStreamType?: StreamType; -}> = ({ regenStreamConfig, poolNetwork, regenStreamType }) => { +const Content: FC = ({ + regenStreamConfig, + poolNetwork, + regenStreamType, +}) => { const { tokenDistroHelper } = useTokenDistroHelper( poolNetwork, regenStreamType, From 50fecea992b38027758968c66704e2548cc0b627 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:41:23 +0330 Subject: [PATCH 028/163] rename StakeInnerModal with StakeInnerModalContainer --- src/components/modals/StakeLock/Lock.tsx | 6 +++--- src/components/modals/StakeLock/Stake.tsx | 6 +++--- src/components/modals/StakeLock/StakeGIV.tsx | 14 ++++++++------ src/components/modals/StakeLock/StakeLock.sc.tsx | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/components/modals/StakeLock/Lock.tsx b/src/components/modals/StakeLock/Lock.tsx index af6c3a222e..98ef34856a 100644 --- a/src/components/modals/StakeLock/Lock.tsx +++ b/src/components/modals/StakeLock/Lock.tsx @@ -19,7 +19,7 @@ import { CancelButton, StyledButton, SectionTitle, - StakeInnerModal, + StakeInnerModalContainer, StakeModalContainer, } from './StakeLock.sc'; import { AmountInput } from '@/components/AmountInput'; @@ -101,7 +101,7 @@ const LockModal: FC = ({ headerIcon={} > - + {lockState === ELockState.LOCK && ( <> @@ -206,7 +206,7 @@ const LockModal: FC = ({ )} - + ); diff --git a/src/components/modals/StakeLock/Stake.tsx b/src/components/modals/StakeLock/Stake.tsx index 0946253a06..040b7f0130 100644 --- a/src/components/modals/StakeLock/Stake.tsx +++ b/src/components/modals/StakeLock/Stake.tsx @@ -26,7 +26,7 @@ import { StakeModalContainer, StakeModalTitle, StakeModalTitleText, - StakeInnerModal, + StakeInnerModalContainer, StyledOutlineButton, StyledButton, ToggleContainer, @@ -189,7 +189,7 @@ export const StakeModal: FC = ({ Stake - + = ({ setShowModal(false); }} /> - + )} {chainId && stakeState === StakeState.CONFIRMING && ( diff --git a/src/components/modals/StakeLock/StakeGIV.tsx b/src/components/modals/StakeLock/StakeGIV.tsx index c65b291104..c33a38f71f 100644 --- a/src/components/modals/StakeLock/StakeGIV.tsx +++ b/src/components/modals/StakeLock/StakeGIV.tsx @@ -17,7 +17,7 @@ import { ERC20 } from '@/types/contracts'; import { CancelButton, StakeModalContainer, - StakeInnerModal, + StakeInnerModalContainer, StyledOutlineButton, SectionTitle, StyledButton, @@ -33,11 +33,13 @@ import type { SimplePoolStakingConfig, } from '@/types/config'; -interface IStakeModalProps extends IModal { +interface IStakeInnerModalProps { poolStakingConfig: PoolStakingConfig; showLockModal: () => void; } +interface IStakeModalProps extends IModal, IStakeInnerModalProps {} + export const loadingAnimationOptions = { loop: true, autoplay: true, @@ -176,7 +178,7 @@ export const StakeGIVModal: FC = ({ {stakeState !== StakeState.CONFIRMED && stakeState !== StakeState.ERROR && ( <> - + {(stakeState === StakeState.APPROVE || stakeState === StakeState.APPROVING) && ( @@ -265,11 +267,11 @@ export const StakeGIVModal: FC = ({ /> )} - + )} {chainId && stakeState === StakeState.CONFIRMED && ( - +
Successful!
You have staked @@ -296,7 +298,7 @@ export const StakeGIVModal: FC = ({ showLockModal(); }} /> -
+ )} {chainId && stakeState === StakeState.ERROR && ( Date: Thu, 23 Feb 2023 16:46:22 +0330 Subject: [PATCH 029/163] fix StakeGIVModal inner modal --- src/components/modals/StakeLock/StakeGIV.tsx | 280 ++++++++++--------- 1 file changed, 141 insertions(+), 139 deletions(-) diff --git a/src/components/modals/StakeLock/StakeGIV.tsx b/src/components/modals/StakeLock/StakeGIV.tsx index c33a38f71f..fe111101d6 100644 --- a/src/components/modals/StakeLock/StakeGIV.tsx +++ b/src/components/modals/StakeLock/StakeGIV.tsx @@ -53,6 +53,29 @@ export const StakeGIVModal: FC = ({ poolStakingConfig, showLockModal, setShowModal, +}) => { + const { isAnimating, closeModal } = useModalAnimation(setShowModal); + + return ( + + + + ); +}; + +const StakeGIVInnerModal: FC = ({ + poolStakingConfig, + showLockModal, + setShowModal, }) => { const [amount, setAmount] = useState('0'); const [txHash, setTxHash] = useState(''); @@ -60,7 +83,6 @@ export const StakeGIVModal: FC = ({ StakeState.APPROVE, ); const { chainId, library } = useWeb3React(); - const { isAnimating, closeModal } = useModalAnimation(setShowModal); const { notStakedAmount: maxAmount } = useStakingPool(poolStakingConfig); const { POOL_ADDRESS, GARDEN_ADDRESS } = @@ -166,148 +188,128 @@ export const StakeGIVModal: FC = ({ }); } }; - return ( - - - {stakeState !== StakeState.CONFIRMED && - stakeState !== StakeState.ERROR && ( - <> - - - {(stakeState === StakeState.APPROVE || - stakeState === StakeState.APPROVING) && ( - <> - - Amount to stake - - - - - } - /> - - )} + + {stakeState !== StakeState.CONFIRMED && + stakeState !== StakeState.ERROR && ( + <> + + + {(stakeState === StakeState.APPROVE || + stakeState === StakeState.APPROVING) && ( + <> + Amount to stake + + + } + /> + + )} - {(stakeState === StakeState.WRAP || - stakeState === StakeState.WRAPPING) && ( - <> - -
You are staking
- - {formatWeiHelper(amount)} GIV - -
- - { - setShowModal(false); - }} - /> - - )} -
- - )} - {chainId && stakeState === StakeState.CONFIRMED && ( - - -
Successful!
- You have staked - - {formatWeiHelper(amount)} GIV - - } - href={`${config.XDAI_CONFIG.blockExplorerUrls}/tx/${txHash}`} - target='_blank' - /> -
- - + +
You are staking
+ + {formatWeiHelper(amount)} GIV + +
+ + { + setShowModal(false); + }} + /> + + )} +
+ + )} + {chainId && stakeState === StakeState.CONFIRMED && ( + + +
Successful!
+ You have staked + + {formatWeiHelper(amount)} GIV + + { - setShowModal(false); - showLockModal(); - }} + icon={} + href={`${config.XDAI_CONFIG.blockExplorerUrls}/tx/${txHash}`} + target='_blank' /> -
- )} - {chainId && stakeState === StakeState.ERROR && ( - + + { + setShowModal(false); + showLockModal(); + }} /> - )} -
-
+ + )} + {chainId && stakeState === StakeState.ERROR && ( + + )} + ); }; From 34693d3a2b155b2975e8a94b968a0d2c11af06a6 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:50:14 +0330 Subject: [PATCH 030/163] fix StakeModal modal rerender issue --- src/components/modals/StakeLock/Stake.tsx | 255 +++++++++++----------- 1 file changed, 130 insertions(+), 125 deletions(-) diff --git a/src/components/modals/StakeLock/Stake.tsx b/src/components/modals/StakeLock/Stake.tsx index 040b7f0130..f6545af74a 100644 --- a/src/components/modals/StakeLock/Stake.tsx +++ b/src/components/modals/StakeLock/Stake.tsx @@ -41,15 +41,35 @@ import { import LottieControl from '@/components/animations/lottieControl'; import { useStakingPool } from '@/hooks/useStakingPool'; -interface IStakeModalProps extends IModal { +interface IStakeInnerModalProps { poolStakingConfig: PoolStakingConfig; regenStreamConfig?: RegenFarmConfig; } +interface IStakeModalProps extends IModal, IStakeInnerModalProps {} + export const StakeModal: FC = ({ poolStakingConfig, regenStreamConfig, setShowModal, +}) => { + const { isAnimating, closeModal } = useModalAnimation(setShowModal); + + return ( + + + + ); +}; + +const StakeInnerModal: FC = ({ + poolStakingConfig, + regenStreamConfig, + setShowModal, }) => { const [amount, setAmount] = useState('0'); const [txHash, setTxHash] = useState(''); @@ -58,7 +78,6 @@ export const StakeModal: FC = ({ StakeState.APPROVE, ); const { chainId, library } = useWeb3React(); - const { isAnimating, closeModal } = useModalAnimation(setShowModal); const { notStakedAmount: maxAmount } = useStakingPool(poolStakingConfig); const { title, LM_ADDRESS, POOL_ADDRESS, platform } = @@ -175,135 +194,121 @@ export const StakeModal: FC = ({ setStakeState(StakeState.STAKE); } }; - return ( - - - {stakeState !== StakeState.CONFIRMING && - stakeState !== StakeState.CONFIRMED && - stakeState !== StakeState.ERROR && ( - <> - - - - Stake - - - - - - {!onlyApproveMode && ( - - -

- {permit ? 'Permit' : 'Approve'} mode -

-
- )} - {stakeState === StakeState.APPROVE && ( - + {stakeState !== StakeState.CONFIRMING && + stakeState !== StakeState.CONFIRMED && + stakeState !== StakeState.ERROR && ( + <> + + + + Stake + + + + + + {!onlyApproveMode && ( + + - )} - {stakeState === StakeState.APPROVING && ( - - -  APPROVE PENDING - - )} - {stakeState === StakeState.STAKE && ( - {permit ? 'Permit' : 'Approve'} mode

+
+ )} + {stakeState === StakeState.APPROVE && ( + + )} + {stakeState === StakeState.APPROVING && ( + + - )} - {stakeState === StakeState.STAKING && ( - - -  STAKE PENDING - - )} - { - setShowModal(false); - }} +  APPROVE PENDING + + )} + {stakeState === StakeState.STAKE && ( + -
- - )} - {chainId && stakeState === StakeState.CONFIRMING && ( - - )} - {chainId && stakeState === StakeState.CONFIRMED && ( - - )} - {chainId && stakeState === StakeState.ERROR && ( - + )} + {stakeState === StakeState.STAKING && ( + + +  STAKE PENDING + + )} + { + setShowModal(false); + }} + /> +
+ )} -
-
+ {chainId && stakeState === StakeState.CONFIRMING && ( + + )} + {chainId && stakeState === StakeState.CONFIRMED && ( + + )} + {chainId && stakeState === StakeState.ERROR && ( + + )} + ); }; From a1d155a77a7e6afa1d9de0793a3e1b77c199bae1 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:50:55 +0330 Subject: [PATCH 031/163] remove UniV3APRModal from BaseStakingCard --- .../cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index c977276bef..ea145e2f8f 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -234,12 +234,6 @@ const BaseStakingCard: FC = ({ poolNetwork={poolNetwork} /> )} - {/* {showUniV3APRModal && ( - - )} */} {showStakeModal && (isGIVpower ? ( Date: Thu, 23 Feb 2023 16:52:55 +0330 Subject: [PATCH 032/163] move maxAmount calculation to the unStake modal --- src/components/modals/Unstake/UnStake.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/modals/Unstake/UnStake.tsx b/src/components/modals/Unstake/UnStake.tsx index fde0206330..bb8710a9ae 100644 --- a/src/components/modals/Unstake/UnStake.tsx +++ b/src/components/modals/Unstake/UnStake.tsx @@ -8,7 +8,6 @@ import { P, } from '@giveth/ui-design-system'; import styled from 'styled-components'; -import { BigNumber } from 'ethers'; import { useWeb3React } from '@web3-react/core'; import { Modal } from '../Modal'; import { Flex } from '../../styled-components/Flex'; @@ -39,13 +38,11 @@ import { useStakingPool } from '@/hooks/useStakingPool'; interface IUnStakeModalProps extends IModal { poolStakingConfig: PoolStakingConfig; regenStreamConfig?: RegenFarmConfig; - maxAmount: BigNumber; } export const UnStakeModal: FC = ({ poolStakingConfig, regenStreamConfig, - maxAmount, setShowModal, }) => { const [txHash, setTxHash] = useState(''); @@ -54,7 +51,7 @@ export const UnStakeModal: FC = ({ const [unStakeState, setUnstakeState] = useState( StakeState.UNSTAKE, ); - const { stakedAmount } = useStakingPool( + const { stakedAmount, notStakedAmount: maxAmount } = useStakingPool( getGivStakingConfig(config.XDAI_CONFIG), ); const { library, chainId } = useWeb3React(); From 9c85d0156fbf7b54d1c5c76bccc866ff45d502b6 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:54:30 +0330 Subject: [PATCH 033/163] separate IUnStakeModalProps interface --- src/components/modals/Unstake/UnStake.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/modals/Unstake/UnStake.tsx b/src/components/modals/Unstake/UnStake.tsx index bb8710a9ae..95293dd63c 100644 --- a/src/components/modals/Unstake/UnStake.tsx +++ b/src/components/modals/Unstake/UnStake.tsx @@ -35,11 +35,13 @@ import config from '@/configuration'; import { getGivStakingConfig } from '@/helpers/networkProvider'; import { useStakingPool } from '@/hooks/useStakingPool'; -interface IUnStakeModalProps extends IModal { +interface IUnStakeInnerModalProps { poolStakingConfig: PoolStakingConfig; regenStreamConfig?: RegenFarmConfig; } +interface IUnStakeModalProps extends IModal, IUnStakeInnerModalProps {} + export const UnStakeModal: FC = ({ poolStakingConfig, regenStreamConfig, From a74edfca49f06afb2d7634f054ccd3435536d8dc Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 16:59:53 +0330 Subject: [PATCH 034/163] fix UnStakeModal modal rerender issue --- src/components/modals/Unstake/UnStake.tsx | 24 +++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/components/modals/Unstake/UnStake.tsx b/src/components/modals/Unstake/UnStake.tsx index 95293dd63c..14a0bc09b1 100644 --- a/src/components/modals/Unstake/UnStake.tsx +++ b/src/components/modals/Unstake/UnStake.tsx @@ -46,6 +46,24 @@ export const UnStakeModal: FC = ({ poolStakingConfig, regenStreamConfig, setShowModal, +}) => { + const { isAnimating, closeModal } = useModalAnimation(setShowModal); + + return ( + + + + ); +}; + +const UnStakeInnerModal: FC = ({ + poolStakingConfig, + regenStreamConfig, + setShowModal, }) => { const [txHash, setTxHash] = useState(''); const [amount, setAmount] = useState('0'); @@ -57,7 +75,6 @@ export const UnStakeModal: FC = ({ getGivStakingConfig(config.XDAI_CONFIG), ); const { library, chainId } = useWeb3React(); - const { isAnimating, closeModal } = useModalAnimation(setShowModal); const { title, type, LM_ADDRESS, GARDEN_ADDRESS } = poolStakingConfig as SimplePoolStakingConfig; @@ -84,9 +101,8 @@ export const UnStakeModal: FC = ({ setUnstakeState(StakeState.ERROR); } }; - return ( - + <> {(unStakeState === StakeState.UNSTAKE || unStakeState === StakeState.UNSTAKING) && ( @@ -213,7 +229,7 @@ export const UnStakeModal: FC = ({ unstakeable={maxAmount} /> )} - + ); }; From 1816d2db29c50a05f72774e400548a6b13f504fa Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 17:00:29 +0330 Subject: [PATCH 035/163] add unStake modal to the BaseStakingCard --- .../BaseStakingCard/BaseStakingCard.tsx | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index ea145e2f8f..769975145c 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -41,6 +41,7 @@ import { getNowUnixMS } from '@/helpers/time'; import { StakingPoolInfoAndActions } from './StakingPoolInfoAndActions'; import { StakeModal } from '@/components/modals/StakeLock/Stake'; import { StakeGIVModal } from '@/components/modals/StakeLock/StakeGIV'; +import { UnStakeModal } from '@/components/modals/Unstake/UnStake'; import type { LiquidityPosition } from '@/types/nfts'; export enum StakeCardState { @@ -252,30 +253,15 @@ const BaseStakingCard: FC = ({ regenStreamConfig={regenStreamConfig} /> ))} - {/* {showUnStakeModal && - (type === StakingType.UNISWAPV3_ETH_GIV ? ( - - ) : ( - - ))} */} + {showUnStakeModal && ( + + )} {/* {showHarvestModal && chainId && ( Date: Thu, 23 Feb 2023 17:20:14 +0330 Subject: [PATCH 036/163] pass setShowUnStakeModal to StakingPoolInfoAndActions --- .../cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx | 1 + .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 769975145c..30f8013aa0 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -212,6 +212,7 @@ const BaseStakingCard: FC = ({ isGIVpower={isGIVpower} setShowAPRModal={setShowAPRModal} setShowStakeModal={setShowStakeModal} + setShowUnStakeModal={setShowUnStakeModal} /> ) : state === StakeCardState.GIVPOWER_INTRO ? ( diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index d15aa9888d..95f4de77ea 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -52,6 +52,7 @@ interface IStakingPoolInfoAndActionsProps { isGIVpower: boolean; setShowAPRModal: React.Dispatch>; setShowStakeModal: React.Dispatch>; + setShowUnStakeModal: React.Dispatch>; } export const StakingPoolInfoAndActions: FC = ({ @@ -61,6 +62,7 @@ export const StakingPoolInfoAndActions: FC = ({ isGIVpower, setShowAPRModal, setShowStakeModal, + setShowUnStakeModal, }) => { const [started, setStarted] = useState(true); const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); @@ -341,7 +343,7 @@ export const StakingPoolInfoAndActions: FC = ({ })} size='small' disabled={availableStakedToken.isZero()} - // onClick={() => setShowUnStakeModal(true)} + onClick={() => setShowUnStakeModal(true)} /> From f2f39ee8fd8f5b6da750ff9ad2a4a2e562425db6 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 18:54:42 +0330 Subject: [PATCH 037/163] removed unused --- src/hooks/useStakingPool.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useStakingPool.tsx b/src/hooks/useStakingPool.tsx index 41350e69c5..b143b6e8ab 100644 --- a/src/hooks/useStakingPool.tsx +++ b/src/hooks/useStakingPool.tsx @@ -42,7 +42,7 @@ export const useStakingPool = ( ? xDaiValues : mainnetValues; const { isLoaded } = currentValues; - const { type, LM_ADDRESS } = poolStakingConfig; + const { type } = poolStakingConfig; const providerNetwork = library?.network?.chainId; const _library = chainId === network ? library : undefined; From a961c70dc75c61b0b00d00dffbfe4e686b104d50 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 18:55:10 +0330 Subject: [PATCH 038/163] return GivEconomyProjectCards to cards folder --- .../cards/GivEconomyProjectCards.tsx | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/components/cards/GivEconomyProjectCards.tsx diff --git a/src/components/cards/GivEconomyProjectCards.tsx b/src/components/cards/GivEconomyProjectCards.tsx new file mode 100644 index 0000000000..8e04d87ef3 --- /dev/null +++ b/src/components/cards/GivEconomyProjectCards.tsx @@ -0,0 +1,76 @@ +import Link from 'next/link'; +import { useIntl } from 'react-intl'; +import { Row, Col } from '@/components/Grid'; +import Routes from '@/lib/constants/Routes'; +import config from '@/configuration'; +import { IGsDataBox, GsButton } from '@/components/homeTabs/GIVstream.sc'; + +const GivEconomyProjectCards = () => { + const { formatMessage } = useIntl(); + return ( + + + + + + } + > + {formatMessage({ + id: 'label.donate_to_verified_projects_on_giveth', + })} + + + + + } + > + {formatMessage({ + id: 'label.the_givgarden_is_the_descentralized_gov_platform', + })} + + + + + + + } + > + {formatMessage({ + id: 'label.stake_giv_or_become_a_liquidity_provider', + })} + + + + ); +}; + +export default GivEconomyProjectCards; From aa6cdb1da35e3a99af441f1d90fbaefeaf26b4e7 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 19:32:25 +0330 Subject: [PATCH 039/163] add setShowHarvestModal --- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index 95f4de77ea..3890fbda2b 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -53,6 +53,7 @@ interface IStakingPoolInfoAndActionsProps { setShowAPRModal: React.Dispatch>; setShowStakeModal: React.Dispatch>; setShowUnStakeModal: React.Dispatch>; + setShowHarvestModal: React.Dispatch>; } export const StakingPoolInfoAndActions: FC = ({ @@ -63,6 +64,7 @@ export const StakingPoolInfoAndActions: FC = ({ setShowAPRModal, setShowStakeModal, setShowUnStakeModal, + setShowHarvestModal, }) => { const [started, setStarted] = useState(true); const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); @@ -299,7 +301,7 @@ export const StakingPoolInfoAndActions: FC = ({ setShowHarvestModal(true)} + onClick={() => setShowHarvestModal(true)} label={formatMessage({ id: 'label.harvest_rewards', })} From 193343c72224ea7d3fa01e5b1fbafc8ff6e87d81 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 19:32:38 +0330 Subject: [PATCH 040/163] remove GivEconomyProjectCards --- .../claim/cards/GivEconomyProjectCards.tsx | 76 ------------------- 1 file changed, 76 deletions(-) delete mode 100644 src/components/views/claim/cards/GivEconomyProjectCards.tsx diff --git a/src/components/views/claim/cards/GivEconomyProjectCards.tsx b/src/components/views/claim/cards/GivEconomyProjectCards.tsx deleted file mode 100644 index 8e04d87ef3..0000000000 --- a/src/components/views/claim/cards/GivEconomyProjectCards.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import Link from 'next/link'; -import { useIntl } from 'react-intl'; -import { Row, Col } from '@/components/Grid'; -import Routes from '@/lib/constants/Routes'; -import config from '@/configuration'; -import { IGsDataBox, GsButton } from '@/components/homeTabs/GIVstream.sc'; - -const GivEconomyProjectCards = () => { - const { formatMessage } = useIntl(); - return ( - - - - - - } - > - {formatMessage({ - id: 'label.donate_to_verified_projects_on_giveth', - })} - - - - - } - > - {formatMessage({ - id: 'label.the_givgarden_is_the_descentralized_gov_platform', - })} - - - - - - - } - > - {formatMessage({ - id: 'label.stake_giv_or_become_a_liquidity_provider', - })} - - - - ); -}; - -export default GivEconomyProjectCards; From 6eb183c6eabfcf396933bce88e868a375755578a Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 19:34:14 +0330 Subject: [PATCH 041/163] fix useModalAnimation close modal --- src/hooks/useModalAnimation.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks/useModalAnimation.tsx b/src/hooks/useModalAnimation.tsx index 82ac0b3908..f337b5fd74 100644 --- a/src/hooks/useModalAnimation.tsx +++ b/src/hooks/useModalAnimation.tsx @@ -1,14 +1,14 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; export const useModalAnimation = (setShowModal: (value: boolean) => void) => { const [isAnimating, setIsAnimating] = useState(true); - const closeModal = () => { + const closeModal = useCallback(() => { setIsAnimating(true); setTimeout(() => { setShowModal(false); }, 300); - }; + }, []); useEffect(() => { setIsAnimating(false); From c5bd8cbb5dada5addf51f010ed94060dd0be4730 Mon Sep 17 00:00:00 2001 From: Cherik Date: Thu, 23 Feb 2023 19:39:24 +0330 Subject: [PATCH 042/163] fix harvest all modal --- .../BaseStakingCard/BaseStakingCard.tsx | 8 +- src/components/modals/HarvestAll.tsx | 194 +++++++++++------- 2 files changed, 126 insertions(+), 76 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 30f8013aa0..5278579f16 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -42,6 +42,7 @@ import { StakingPoolInfoAndActions } from './StakingPoolInfoAndActions'; import { StakeModal } from '@/components/modals/StakeLock/Stake'; import { StakeGIVModal } from '@/components/modals/StakeLock/StakeGIV'; import { UnStakeModal } from '@/components/modals/Unstake/UnStake'; +import { HarvestAllModal } from '@/components/modals/HarvestAll'; import type { LiquidityPosition } from '@/types/nfts'; export enum StakeCardState { @@ -213,6 +214,7 @@ const BaseStakingCard: FC = ({ setShowAPRModal={setShowAPRModal} setShowStakeModal={setShowStakeModal} setShowUnStakeModal={setShowUnStakeModal} + setShowHarvestModal={setShowHarvestModal} /> ) : state === StakeCardState.GIVPOWER_INTRO ? ( @@ -263,19 +265,17 @@ const BaseStakingCard: FC = ({ regenStreamConfig={regenStreamConfig} /> )} - {/* {showHarvestModal && chainId && ( + {showHarvestModal && chainId && ( - )} */} + )} {/* {showLockModal && ( = ({ title, setShowModal, poolStakingConfig, - earned, network, - tokenDistroHelper, regenStreamConfig, + regenStreamType, stakedPositions, currentIncentive, }) => { const [state, setState] = useState(HarvestStates.HARVEST); const tokenSymbol = regenStreamConfig?.rewardTokenSymbol || 'GIV'; - const sdh = new SubgraphDataHelper( - useAppSelector(state => state.subgraph.currentValues), - ); const { formatMessage } = useIntl(); const { mainnetThirdPartyTokensPrice, @@ -131,6 +147,12 @@ export const HarvestAllModal: FC = ({ const [sumStream, setSumStream] = useState(Zero); const { isAnimating, closeModal } = useModalAnimation(setShowModal); + const { tokenDistroHelper, sdh } = useTokenDistroHelper( + network, + regenStreamType, + regenStreamConfig, + ); + const tokenDistroBalance = regenStreamConfig ? sdh.getTokenDistroBalance(regenStreamConfig.tokenDistroAddress) : sdh.getGIVTokenDistroBalance(); @@ -156,12 +178,6 @@ export const HarvestAllModal: FC = ({ useEffect(() => { if (!tokenDistroHelper) return; - if (earned) { - setRewardLiquidPart(tokenDistroHelper.getLiquidPart(earned)); - setEarnedStream( - tokenDistroHelper.getStreamPartTokenPerWeek(earned), - ); - } setEarnedLiquid( tokenDistroHelper.getUserClaimableNow(tokenDistroBalance), ); @@ -172,13 +188,7 @@ export const HarvestAllModal: FC = ({ tokenDistroHelper.getStreamPartTokenPerWeek(lockedAmount), ); setGivBackStream(tokenDistroHelper.getStreamPartTokenPerWeek(givback)); - }, [ - earned, - tokenDistroBalance, - tokenDistroHelper, - givback, - regenStreamConfig, - ]); + }, [tokenDistroBalance, tokenDistroHelper, givback, regenStreamConfig]); //calculate Liquid Sum useEffect(() => { @@ -499,54 +509,27 @@ export const HarvestAllModal: FC = ({ )} - {poolStakingConfig && - earned && - earned.gt(0) && ( - - - - - -

- {regenStreamConfig - ? 'RegenFarm' - : 'GIVfarm'} -

- {poolStakingConfig.title} - - {getPoolIconWithName( - poolStakingConfig.platform, - )} - -
- - {formatWeiHelper( - rewardLiquidPart, - config.TOKEN_PRECISION, - false, - )} - - - {tokenSymbol} - - - + - {formatWeiHelper( - earnedStream, - config.TOKEN_PRECISION, - false, - )} - - - {tokenSymbol} - {formatMessage({ - id: 'label./week', - })} - -
- )} + {poolStakingConfig && tokenDistroHelper && ( + + )} +
@@ -647,3 +630,70 @@ export const HarvestAllModal: FC = ({ ); }; + +interface IEarnedBreakDownProps { + poolStakingConfig: PoolStakingConfig; + tokenDistroHelper: TokenDistroHelper; + setRewardLiquidPart: Dispatch>; + setEarnedStream: Dispatch>; + regenStreamConfig?: RegenFarmConfig; + rewardLiquidPart: ethers.BigNumber; + tokenSymbol: string; + earnedStream: BigNumber; +} + +const EarnedBreakDown: FC = ({ + poolStakingConfig, + regenStreamConfig, + tokenDistroHelper, + setRewardLiquidPart, + setEarnedStream, + rewardLiquidPart, + tokenSymbol, + earnedStream, +}) => { + const { earned } = useStakingPool(poolStakingConfig); + const { formatMessage } = useIntl(); + + useEffect(() => { + if (!tokenDistroHelper) return; + if (earned) { + setRewardLiquidPart(tokenDistroHelper.getLiquidPart(earned)); + setEarnedStream( + tokenDistroHelper.getStreamPartTokenPerWeek(earned), + ); + } + }, [earned, tokenDistroHelper]); + + return earned && earned.gt(0) ? ( + + + + + +

{regenStreamConfig ? 'RegenFarm' : 'GIVfarm'}

+ {poolStakingConfig.title} + + {getPoolIconWithName(poolStakingConfig.platform)} + +
+ + {formatWeiHelper( + rewardLiquidPart, + config.TOKEN_PRECISION, + false, + )} + + {tokenSymbol} + + +{formatWeiHelper(earnedStream, config.TOKEN_PRECISION, false)} + + + {tokenSymbol} + {formatMessage({ + id: 'label./week', + })} + +
+ ) : null; +}; From 7af0f3bd2c29be9d4cc4e000199cc96c2c89d4a6 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 10:44:47 +0330 Subject: [PATCH 043/163] reduce import size --- src/components/modals/HarvestAll.tsx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/components/modals/HarvestAll.tsx b/src/components/modals/HarvestAll.tsx index f9edb7d610..ab19348eab 100644 --- a/src/components/modals/HarvestAll.tsx +++ b/src/components/modals/HarvestAll.tsx @@ -16,7 +16,7 @@ import { Lead, P, } from '@giveth/ui-design-system'; -import { ethers } from 'ethers'; +import { constants, BigNumber as EthBigNumber } from 'ethers'; import { useIntl } from 'react-intl'; import BigNumber from 'bignumber.js'; import { useWeb3React } from '@web3-react/core'; @@ -130,20 +130,18 @@ export const HarvestAllModal: FC = ({ const { account, library } = useWeb3React(); const [txHash, setTxHash] = useState(''); //GIVdrop TODO: Should we show Givdrop in new design? - const [givDrop, setGIVdrop] = useState(ethers.constants.Zero); + const [givDrop, setGIVdrop] = useState(constants.Zero); const [givDropStream, setGIVdropStream] = useState(Zero); //GIVstream - const [rewardLiquidPart, setRewardLiquidPart] = useState( - ethers.constants.Zero, - ); + const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); const [rewardStream, setRewardStream] = useState(Zero); //GIVfarm - const [earnedLiquid, setEarnedLiquid] = useState(ethers.constants.Zero); + const [earnedLiquid, setEarnedLiquid] = useState(constants.Zero); const [earnedStream, setEarnedStream] = useState(Zero); //GIVbacks const [givBackStream, setGivBackStream] = useState(0); //Sum - const [sumLiquid, setSumLiquid] = useState(ethers.constants.Zero); + const [sumLiquid, setSumLiquid] = useState(constants.Zero); const [sumStream, setSumStream] = useState(Zero); const { isAnimating, closeModal } = useModalAnimation(setShowModal); @@ -156,11 +154,11 @@ export const HarvestAllModal: FC = ({ const tokenDistroBalance = regenStreamConfig ? sdh.getTokenDistroBalance(regenStreamConfig.tokenDistroAddress) : sdh.getGIVTokenDistroBalance(); - const givback = useMemo( + const givback = useMemo( () => BN(tokenDistroBalance.givback), [tokenDistroBalance], ); - const givbackLiquidPart = useMemo( + const givbackLiquidPart = useMemo( () => BN(tokenDistroBalance.givbackLiquidPart), [tokenDistroBalance], ); @@ -210,7 +208,7 @@ export const HarvestAllModal: FC = ({ ) { fetchAirDropClaimData(account).then(claimData => { if (claimData) { - const givDrop = ethers.BigNumber.from(claimData.amount); + const givDrop = EthBigNumber.from(claimData.amount); setGIVdrop(givDrop.div(10)); setGIVdropStream( tokenDistroHelper.getStreamPartTokenPerWeek(givDrop), @@ -634,10 +632,10 @@ export const HarvestAllModal: FC = ({ interface IEarnedBreakDownProps { poolStakingConfig: PoolStakingConfig; tokenDistroHelper: TokenDistroHelper; - setRewardLiquidPart: Dispatch>; + setRewardLiquidPart: Dispatch>; setEarnedStream: Dispatch>; regenStreamConfig?: RegenFarmConfig; - rewardLiquidPart: ethers.BigNumber; + rewardLiquidPart: EthBigNumber; tokenSymbol: string; earnedStream: BigNumber; } From 7d30f1c978d57538812854c2e90047b9d519719f Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 10:53:10 +0330 Subject: [PATCH 044/163] fix build issues --- src/components/givfarm/RegenStreamCard.tsx | 1 - src/components/homeTabs/GIVbacks.tsx | 1 - src/components/homeTabs/GIVgarden.tsx | 2 -- src/components/homeTabs/GIVstream.tsx | 1 - 4 files changed, 5 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index fafbff31d7..87522367ec 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -239,7 +239,6 @@ export const RegenStreamCard: FC = ({ setShowModal={setShowModal} network={network} regenStreamConfig={streamConfig} - tokenDistroHelper={regenTokenDistroHelper} /> )} diff --git a/src/components/homeTabs/GIVbacks.tsx b/src/components/homeTabs/GIVbacks.tsx index 4ffa1944bf..8d36819b8b 100644 --- a/src/components/homeTabs/GIVbacks.tsx +++ b/src/components/homeTabs/GIVbacks.tsx @@ -121,7 +121,6 @@ export const TabGIVbacksTop = () => { title={formatMessage({ id: 'label.givbacks_rewards' })} setShowModal={setShowHarvestModal} network={config.XDAI_NETWORK_NUMBER} - tokenDistroHelper={givTokenDistroHelper} /> )} {showGivBackExplain && ( diff --git a/src/components/homeTabs/GIVgarden.tsx b/src/components/homeTabs/GIVgarden.tsx index 6e09e79146..3b3441b831 100644 --- a/src/components/homeTabs/GIVgarden.tsx +++ b/src/components/homeTabs/GIVgarden.tsx @@ -96,9 +96,7 @@ export const TabGardenTop = () => { title={formatMessage({ id: 'label.givgarden_rewards' })} setShowModal={setShowModal} poolStakingConfig={poolStakingConfig} - earned={earned} network={config.XDAI_NETWORK_NUMBER} - tokenDistroHelper={givTokenDistroHelper} /> )} diff --git a/src/components/homeTabs/GIVstream.tsx b/src/components/homeTabs/GIVstream.tsx index 3bc7571e21..91d0eb2c0a 100644 --- a/src/components/homeTabs/GIVstream.tsx +++ b/src/components/homeTabs/GIVstream.tsx @@ -144,7 +144,6 @@ export const TabGIVstreamTop = () => { title='GIVstream Rewards' setShowModal={setShowModal} network={chainId} - tokenDistroHelper={givTokenDistroHelper} /> )} From 22265930a1eaa4a3219dcf236f7ef521470d16d0 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 11:36:58 +0330 Subject: [PATCH 045/163] add more tests --- pages/test1.tsx | 69 +++++++++++++++++++++++++++++------- src/context/test.context.tsx | 44 +++++++++++++++++++++++ 2 files changed, 100 insertions(+), 13 deletions(-) create mode 100644 src/context/test.context.tsx diff --git a/pages/test1.tsx b/pages/test1.tsx index 26018d9036..2f4118c2b8 100644 --- a/pages/test1.tsx +++ b/pages/test1.tsx @@ -2,7 +2,7 @@ import styled from 'styled-components'; import { GetServerSideProps } from 'next'; import { useWeb3React } from '@web3-react/core'; import { IconHelpFilled16 } from '@giveth/ui-design-system'; -import { useRef, useState } from 'react'; +import { FC, useEffect, useRef, useState } from 'react'; import dynamic from 'next/dynamic'; import { useRouter } from 'next/router'; import { gToast, ToastType } from '@/components/toasts'; @@ -10,25 +10,45 @@ import { useAppDispatch } from '@/features/hooks'; import { fetchXDaiInfoAsync } from '@/features/subgraph/subgraph.thunks'; import { FlowRateTooltip } from '@/components/homeTabs/GIVstream.sc'; import { IconWithTooltip } from '@/components/IconWithToolTip'; -import { zIndex } from '@/lib/constants/constants'; import { Container } from '@/components/Grid'; import { removeQueryParamAndRedirect } from '@/helpers/url'; import { EthDenverBanner } from '@/components/EthDenverBanner'; +import { TestProvider, useTestData } from '@/context/test.context'; +import { IModal } from '@/types/common'; +import { useModalAnimation } from '@/hooks/useModalAnimation'; +import { Modal } from '@/components/modals/Modal'; const RichTextInput = dynamic(() => import('@/components/RichTextInput'), { ssr: false, }); const TestRoute = () => { + return ( + + + + ); +}; + +const TestIndex = () => { // const xDaiValues = useSelector( // (state: RootState) => state.subgraph.xDaiValues, // ); + const [showModal, setShowModal] = useState(false); const { account } = useWeb3React(); const dispatch = useAppDispatch(); const functionRef = useRef(); const [state, setState] = useState(0); const [description, setDescription] = useState(''); const router = useRouter(); + const { setTest } = useTestData(); + console.log('Index rerender'); + + useEffect(() => { + setInterval(() => { + setTest(test => !test); + }, 1000); + }, [setTest]); // const { data, isLoading, error, refetch } = useGetSubgraphValuesQuery({ // chain: chainId, @@ -120,6 +140,9 @@ const TestRoute = () => { > remove search +
-------------------------------------------- { /> + {showModal && } ); }; +interface ITestInnerModalProps {} -export default TestRoute; +interface ITestModalProps extends IModal, ITestInnerModalProps {} + +const TestModal: FC = ({ setShowModal }) => { + const { isAnimating, closeModal } = useModalAnimation(setShowModal); + console.log('Modal rerender'); + return ( + + + + ); +}; + +const TestInnerModal: FC = () => { + const { test } = useTestData(); + console.log('Inner Modal rerender'); + return ( +
+
Hiii there this is test:
+
{test.toString()}
+
+ ); +}; export const getServerSideProps: GetServerSideProps = async context => { // let { statusCode } = context.res; @@ -159,15 +209,8 @@ export const getServerSideProps: GetServerSideProps = async context => { }; const TestContainer = styled(Container)` - padding: 200px 0; + padding-top: 200px; + padding-bottom: 200px; `; -const TooltipContainer = styled.div` - position: fixed; - padding: 0; - background-color: black; - color: #fff; - border-radius: 6px; - padding: 8px; - z-index: ${zIndex.TOOLTIP}; -`; +export default TestRoute; diff --git a/src/context/test.context.tsx b/src/context/test.context.tsx new file mode 100644 index 0000000000..a39729091f --- /dev/null +++ b/src/context/test.context.tsx @@ -0,0 +1,44 @@ +import { + createContext, + Dispatch, + FC, + ReactNode, + SetStateAction, + useContext, + useState, +} from 'react'; + +interface ITestContext { + test: boolean; + setTest: Dispatch>; +} + +interface IProviderProps { + children: ReactNode; +} + +const TestContext = createContext({ + setTest: () => { + console.log('setTest Not Implemented Yet'); + }, + test: false, +}); + +TestContext.displayName = 'TestContext'; + +export const TestProvider: FC = props => { + const [test, setTest] = useState(false); + return ( + + {props.children} + + ); +}; + +export const useTestData = () => { + const context = useContext(TestContext); + if (context === undefined) { + throw new Error('useTestData must be used within a Provider'); + } + return context; +}; From 6a0351d10eba8b0980fc10257d612ddeef77356e Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 11:58:26 +0330 Subject: [PATCH 046/163] add disable feature to useGIVTokenDistroHelper --- src/hooks/useGIVTokenDistroHelper.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hooks/useGIVTokenDistroHelper.tsx b/src/hooks/useGIVTokenDistroHelper.tsx index 549014c1d9..72779eb350 100644 --- a/src/hooks/useGIVTokenDistroHelper.tsx +++ b/src/hooks/useGIVTokenDistroHelper.tsx @@ -4,6 +4,7 @@ import { AddressZero } from '@ethersproject/constants'; import { useAppSelector } from '@/features/hooks'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; +import { defaultXdaiSubgraphValues } from '@/features/subgraph/subgraph.slice'; export const defaultTokenDistroHelper = new TokenDistroHelper({ contractAddress: AddressZero, @@ -15,12 +16,13 @@ export const defaultTokenDistroHelper = new TokenDistroHelper({ endTime: 0, }); -const useGIVTokenDistroHelper = () => { +const useGIVTokenDistroHelper = (disable = false) => { const [givTokenDistroHelper, setGIVTokenDistroHelper] = useState(defaultTokenDistroHelper); const [isLoaded, setIsLoaded] = useState(false); const currentValue = useAppSelector( - state => state.subgraph.currentValues, + state => + disable ? defaultXdaiSubgraphValues : state.subgraph.currentValues, shallowEqual, ); useEffect(() => { From 9888038c750dfc9e241026752987fd5540006434 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:00:50 +0330 Subject: [PATCH 047/163] add defaultXdaiSubgraphValues --- src/features/subgraph/subgraph.slice.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/features/subgraph/subgraph.slice.ts b/src/features/subgraph/subgraph.slice.ts index 6754c32adc..8859d8d62b 100644 --- a/src/features/subgraph/subgraph.slice.ts +++ b/src/features/subgraph/subgraph.slice.ts @@ -25,6 +25,14 @@ export const defaultSubgraphValues: ISubgraphState = { isLoaded: false, }; +export const defaultXdaiSubgraphValues: ISubgraphState = { + userNotStakedPositions: [], + userStakedPositions: [], + allPositions: [], + networkNumber: config.XDAI_NETWORK_NUMBER, + isLoaded: false, +}; + const initialState: { currentValues: ISubgraphState; mainnetValues: ISubgraphState; @@ -32,7 +40,7 @@ const initialState: { } = { currentValues: defaultSubgraphValues, mainnetValues: defaultSubgraphValues, - xDaiValues: defaultSubgraphValues, + xDaiValues: defaultXdaiSubgraphValues, }; export const subgraphSlice = createSlice({ From 111e2f7ff0082bdadf8969a6bc2d43944e6d9ed8 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:01:39 +0330 Subject: [PATCH 048/163] optimize TabGIVstreamTop --- src/components/homeTabs/GIVstream.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/homeTabs/GIVstream.tsx b/src/components/homeTabs/GIVstream.tsx index 91d0eb2c0a..579b8f269a 100644 --- a/src/components/homeTabs/GIVstream.tsx +++ b/src/components/homeTabs/GIVstream.tsx @@ -69,16 +69,18 @@ import { Container, Row, Col } from '@/components/Grid'; import GivEconomyProjectCards from '../cards/GivEconomyProjectCards'; import { useAppSelector } from '@/features/hooks'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; +import { defaultSubgraphValues } from '@/features/subgraph/subgraph.slice'; export const TabGIVstreamTop = () => { const { formatMessage } = useIntl(); const [showModal, setShowModal] = useState(false); const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); const [rewardStream, setRewardStream] = useState(0); - const { givTokenDistroHelper } = useGIVTokenDistroHelper(); - const sdh = new SubgraphDataHelper( - useAppSelector(state => state.subgraph.currentValues), + const { givTokenDistroHelper } = useGIVTokenDistroHelper(showModal); + const currentValues = useAppSelector(state => + !showModal ? state.subgraph.currentValues : defaultSubgraphValues, ); + const sdh = new SubgraphDataHelper(currentValues); const { allocatedTokens, claimed, givback } = sdh.getGIVTokenDistroBalance(); const { chainId } = useWeb3React(); From aa46b91371329809cd05d07b397cbed655eb1d74 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:14:35 +0330 Subject: [PATCH 049/163] fix WhatIsStreamModal --- src/components/modals/WhatIsStream.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/modals/WhatIsStream.tsx b/src/components/modals/WhatIsStream.tsx index a880d33792..640c963dba 100644 --- a/src/components/modals/WhatIsStream.tsx +++ b/src/components/modals/WhatIsStream.tsx @@ -42,7 +42,7 @@ export const WhatIsStreamModal: FC = ({ }; const closeModalWithCb = () => { closeModal(); - cb(); + cb && cb(); }; return ( From b3d6d089353f14cf212327ec4b81b15f16704b05 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:30:26 +0330 Subject: [PATCH 050/163] prevent show zero on useGIVTokenDistroHelper --- src/hooks/useGIVTokenDistroHelper.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/hooks/useGIVTokenDistroHelper.tsx b/src/hooks/useGIVTokenDistroHelper.tsx index 72779eb350..908f925b04 100644 --- a/src/hooks/useGIVTokenDistroHelper.tsx +++ b/src/hooks/useGIVTokenDistroHelper.tsx @@ -4,7 +4,6 @@ import { AddressZero } from '@ethersproject/constants'; import { useAppSelector } from '@/features/hooks'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; -import { defaultXdaiSubgraphValues } from '@/features/subgraph/subgraph.slice'; export const defaultTokenDistroHelper = new TokenDistroHelper({ contractAddress: AddressZero, @@ -21,9 +20,8 @@ const useGIVTokenDistroHelper = (disable = false) => { useState(defaultTokenDistroHelper); const [isLoaded, setIsLoaded] = useState(false); const currentValue = useAppSelector( - state => - disable ? defaultXdaiSubgraphValues : state.subgraph.currentValues, - shallowEqual, + state => state.subgraph.currentValues, + (objA, objB) => (disable ? true : shallowEqual(objA, objB)), ); useEffect(() => { const sdh = new SubgraphDataHelper(currentValue); From d62a8757a9629b982d1193a90e523399518f720c Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:31:04 +0330 Subject: [PATCH 051/163] optimize TabGIVstreamTop --- src/components/homeTabs/GIVstream.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/homeTabs/GIVstream.tsx b/src/components/homeTabs/GIVstream.tsx index 579b8f269a..36548c324c 100644 --- a/src/components/homeTabs/GIVstream.tsx +++ b/src/components/homeTabs/GIVstream.tsx @@ -69,7 +69,6 @@ import { Container, Row, Col } from '@/components/Grid'; import GivEconomyProjectCards from '../cards/GivEconomyProjectCards'; import { useAppSelector } from '@/features/hooks'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; -import { defaultSubgraphValues } from '@/features/subgraph/subgraph.slice'; export const TabGIVstreamTop = () => { const { formatMessage } = useIntl(); @@ -77,8 +76,9 @@ export const TabGIVstreamTop = () => { const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); const [rewardStream, setRewardStream] = useState(0); const { givTokenDistroHelper } = useGIVTokenDistroHelper(showModal); - const currentValues = useAppSelector(state => - !showModal ? state.subgraph.currentValues : defaultSubgraphValues, + const currentValues = useAppSelector( + state => state.subgraph.currentValues, + () => (showModal ? true : false), ); const sdh = new SubgraphDataHelper(currentValues); const { allocatedTokens, claimed, givback } = From 6c2458e2a1024bc9ad4dc5ddc2054b79663f1a1f Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:31:57 +0330 Subject: [PATCH 052/163] optimize TabGardenTop --- src/components/homeTabs/GIVgarden.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/components/homeTabs/GIVgarden.tsx b/src/components/homeTabs/GIVgarden.tsx index 3b3441b831..48aa7141fc 100644 --- a/src/components/homeTabs/GIVgarden.tsx +++ b/src/components/homeTabs/GIVgarden.tsx @@ -37,15 +37,14 @@ const poolStakingConfig = getGivStakingConfig(config.XDAI_CONFIG); export const TabGardenTop = () => { const { chainId } = useWeb3React(); - const { givTokenDistroHelper } = useGIVTokenDistroHelper(); - const { formatMessage } = useIntl(); - const [showModal, setShowModal] = useState(false); const [earnedLiquidPart, setEarnedLiquidPart] = useState(Zero); const [earnedStream, setEarnedStream] = useState( new BigNumber(0), ); + const { givTokenDistroHelper } = useGIVTokenDistroHelper(showModal); + const { formatMessage } = useIntl(); const { earned } = useStakingPool(poolStakingConfig); From d2008fd2e8156260e2098c1220c038a1b8916a8a Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:32:08 +0330 Subject: [PATCH 053/163] optimize givbacks --- src/components/homeTabs/GIVbacks.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/homeTabs/GIVbacks.tsx b/src/components/homeTabs/GIVbacks.tsx index 8d36819b8b..7d67e542f7 100644 --- a/src/components/homeTabs/GIVbacks.tsx +++ b/src/components/homeTabs/GIVbacks.tsx @@ -50,8 +50,11 @@ export const TabGIVbacksTop = () => { const [showHarvestModal, setShowHarvestModal] = useState(false); const [showGivBackExplain, setShowGivBackExplain] = useState(false); const [givBackStream, setGivBackStream] = useState(0); - const { givTokenDistroHelper } = useGIVTokenDistroHelper(); - const xDaiValues = useAppSelector(state => state.subgraph.xDaiValues); + const { givTokenDistroHelper } = useGIVTokenDistroHelper(showHarvestModal); + const xDaiValues = useAppSelector( + state => state.subgraph.xDaiValues, + () => (showHarvestModal ? true : false), + ); const givTokenDistroBalance = useMemo(() => { const sdh = new SubgraphDataHelper(xDaiValues); return sdh.getGIVTokenDistroBalance(); From 92ee058e4e7cf9c425926747f130e2b02257432e Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:38:01 +0330 Subject: [PATCH 054/163] change disable to hold --- src/hooks/useGIVTokenDistroHelper.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useGIVTokenDistroHelper.tsx b/src/hooks/useGIVTokenDistroHelper.tsx index 908f925b04..0c9cb513a0 100644 --- a/src/hooks/useGIVTokenDistroHelper.tsx +++ b/src/hooks/useGIVTokenDistroHelper.tsx @@ -15,13 +15,13 @@ export const defaultTokenDistroHelper = new TokenDistroHelper({ endTime: 0, }); -const useGIVTokenDistroHelper = (disable = false) => { +const useGIVTokenDistroHelper = (hold = false) => { const [givTokenDistroHelper, setGIVTokenDistroHelper] = useState(defaultTokenDistroHelper); const [isLoaded, setIsLoaded] = useState(false); const currentValue = useAppSelector( state => state.subgraph.currentValues, - (objA, objB) => (disable ? true : shallowEqual(objA, objB)), + (objA, objB) => (hold ? true : shallowEqual(objA, objB)), ); useEffect(() => { const sdh = new SubgraphDataHelper(currentValue); From 2f634a536965b3952da706d7164463845ea76e31 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:40:37 +0330 Subject: [PATCH 055/163] add hold ability to useTokenDistroHelper --- src/hooks/useTokenDistroHelper.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hooks/useTokenDistroHelper.tsx b/src/hooks/useTokenDistroHelper.tsx index 534e3fda08..fb5d97a433 100644 --- a/src/hooks/useTokenDistroHelper.tsx +++ b/src/hooks/useTokenDistroHelper.tsx @@ -9,15 +9,18 @@ export const useTokenDistroHelper = ( poolNetwork: number, regenStreamType?: StreamType, regenStreamConfig?: RegenFarmConfig, + hold?: boolean, ) => { const [tokenDistroHelper, setTokenDistroHelper] = useState(); - const { mainnetValues, xDaiValues } = useAppSelector( - state => state.subgraph, + const currentValues = useAppSelector( + state => + poolNetwork === config.XDAI_NETWORK_NUMBER + ? state.subgraph.xDaiValues + : state.subgraph.mainnetValues, + () => (hold ? true : false), ); - const currentValues = - poolNetwork === config.XDAI_NETWORK_NUMBER ? xDaiValues : mainnetValues; const sdh = new SubgraphDataHelper(currentValues); useEffect(() => { From fa425756cc9f58d844709e7e4d8ca30930bec13b Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:40:57 +0330 Subject: [PATCH 056/163] optimize RegenStreamCard --- src/components/givfarm/RegenStreamCard.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 87522367ec..37d4a996c1 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -71,7 +71,10 @@ export const RegenStreamCard: FC = ({ constants.Zero, ); - const currentValues = useAppSelector(state => state.subgraph.currentValues); + const currentValues = useAppSelector( + state => state.subgraph.currentValues, + () => (showModal ? true : false), + ); const { regenTokenDistroHelper, tokenDistroBalance } = useMemo(() => { const sdh = new SubgraphDataHelper(currentValues); const tokenDistroBalance = sdh.getTokenDistroBalance( From 1283c765f92bb60481bf246af183aa36b58a2f9e Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:45:36 +0330 Subject: [PATCH 057/163] make hold disable by default --- src/hooks/useTokenDistroHelper.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useTokenDistroHelper.tsx b/src/hooks/useTokenDistroHelper.tsx index fb5d97a433..2ac7e8565c 100644 --- a/src/hooks/useTokenDistroHelper.tsx +++ b/src/hooks/useTokenDistroHelper.tsx @@ -9,7 +9,7 @@ export const useTokenDistroHelper = ( poolNetwork: number, regenStreamType?: StreamType, regenStreamConfig?: RegenFarmConfig, - hold?: boolean, + hold: boolean = false, ) => { const [tokenDistroHelper, setTokenDistroHelper] = useState(); From 38d05daff5e4ec4f99e0d26215ff4b8d94419957 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:45:53 +0330 Subject: [PATCH 058/163] add hold ability to useStakingPool --- src/hooks/useStakingPool.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hooks/useStakingPool.tsx b/src/hooks/useStakingPool.tsx index b143b6e8ab..c292384872 100644 --- a/src/hooks/useStakingPool.tsx +++ b/src/hooks/useStakingPool.tsx @@ -22,6 +22,7 @@ export interface IStakeInfo { export const useStakingPool = ( poolStakingConfig: SimplePoolStakingConfig, + hold: boolean = false, ): IStakeInfo => { const [apr, setApr] = useState(null); const [userStakeInfo, setUserStakeInfo] = useState({ @@ -32,15 +33,15 @@ export const useStakingPool = ( const stakePoolInfoPoll = useRef(null); const { library, chainId } = useWeb3React(); - const { mainnetValues, xDaiValues } = useAppSelector( - state => state.subgraph, + const currentValues = useAppSelector( + state => + poolStakingConfig.network === config.XDAI_NETWORK_NUMBER + ? state.subgraph.xDaiValues + : state.subgraph.mainnetValues, + () => (hold ? true : false), ); const { network } = poolStakingConfig; - const currentValues = - poolStakingConfig.network === config.XDAI_NETWORK_NUMBER - ? xDaiValues - : mainnetValues; const { isLoaded } = currentValues; const { type } = poolStakingConfig; const providerNetwork = library?.network?.chainId; From 38de2775c3f816bee4c6e07ca4090e1923edd859 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 12:53:11 +0330 Subject: [PATCH 059/163] move apr modal to StakingPoolInfoAndActions --- .../BaseStakingCard/BaseStakingCard.tsx | 11 ----------- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 5278579f16..399947755b 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -29,7 +29,6 @@ import { IconGnosisChain } from '@/components/Icons/GnosisChain'; import { IconHoneyswap } from '@/components/Icons/Honeyswap'; import { IconSushiswap } from '@/components/Icons/Sushiswap'; import { IconUniswap } from '@/components/Icons/Uniswap'; -import { APRModal } from '@/components/modals/APR'; import { GIVPowerExplainModal } from '@/components/modals/GIVPowerExplain'; import { StakingPoolImages } from '@/components/StakingPoolImages'; import GIVpowerCardIntro from '../GIVpowerCard/GIVpowerCardIntro'; @@ -100,7 +99,6 @@ const BaseStakingCard: FC = ({ }) => { const { formatMessage } = useIntl(); const [state, setState] = useState(StakeCardState.NORMAL); - const [showAPRModal, setShowAPRModal] = useState(false); const [showUniV3APRModal, setShowUniV3APRModal] = useState(false); const [showStakeModal, setShowStakeModal] = useState(false); const [isFirstStakeShown, setIsFirstStakeShown] = useState(false); @@ -211,7 +209,6 @@ const BaseStakingCard: FC = ({ regenStreamConfig={regenStreamConfig} isDiscontinued={isDiscontinued} isGIVpower={isGIVpower} - setShowAPRModal={setShowAPRModal} setShowStakeModal={setShowStakeModal} setShowUnStakeModal={setShowUnStakeModal} setShowHarvestModal={setShowHarvestModal} @@ -230,14 +227,6 @@ const BaseStakingCard: FC = ({ {showGIVPowerExplain && ( )} - {showAPRModal && ( - - )} {showStakeModal && (isGIVpower ? ( >; setShowStakeModal: React.Dispatch>; setShowUnStakeModal: React.Dispatch>; setShowHarvestModal: React.Dispatch>; @@ -61,7 +61,6 @@ export const StakingPoolInfoAndActions: FC = ({ regenStreamConfig, isDiscontinued, isGIVpower, - setShowAPRModal, setShowStakeModal, setShowUnStakeModal, setShowHarvestModal, @@ -69,10 +68,12 @@ export const StakingPoolInfoAndActions: FC = ({ const [started, setStarted] = useState(true); const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); const [rewardStream, setRewardStream] = useState(0); + //Modals + const [showAPRModal, setShowAPRModal] = useState(false); const { formatMessage } = useIntl(); const { setInfo } = useFarms(); - const { chainId, account, active: isWalletActive } = useWeb3React(); + const { account } = useWeb3React(); const { apr, notStakedAmount: userNotStakedAmount, @@ -404,6 +405,14 @@ export const StakingPoolInfoAndActions: FC = ({ // }} /> ))} + {showAPRModal && ( + + )} ); }; From 77ea8bab48b5601eb249db158ace1150f1ad00d7 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 13:14:35 +0330 Subject: [PATCH 060/163] move stake modal to StakingPoolInfoAndActions --- .../BaseStakingCard/BaseStakingCard.tsx | 59 +------------------ .../StakingPoolInfoAndActions.tsx | 59 ++++++++++++++++++- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 399947755b..9b2a8436fb 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -1,7 +1,6 @@ -import React, { FC, ReactNode, useEffect, useState } from 'react'; +import React, { FC, ReactNode, useState } from 'react'; import { Caption, IconAlertCircle32 } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; -import { useRouter } from 'next/router'; import { useWeb3React } from '@web3-react/core'; import { PoolStakingConfig, @@ -35,11 +34,8 @@ import GIVpowerCardIntro from '../GIVpowerCard/GIVpowerCardIntro'; import StakingCardIntro from '../StakingCardIntro'; import { ArchiveCover } from './ArchiveCover'; import { StakingCardHeader } from './StakingCardHeader'; -import Routes from '@/lib/constants/Routes'; import { getNowUnixMS } from '@/helpers/time'; import { StakingPoolInfoAndActions } from './StakingPoolInfoAndActions'; -import { StakeModal } from '@/components/modals/StakeLock/Stake'; -import { StakeGIVModal } from '@/components/modals/StakeLock/StakeGIV'; import { UnStakeModal } from '@/components/modals/Unstake/UnStake'; import { HarvestAllModal } from '@/components/modals/HarvestAll'; import type { LiquidityPosition } from '@/types/nfts'; @@ -100,8 +96,6 @@ const BaseStakingCard: FC = ({ const { formatMessage } = useIntl(); const [state, setState] = useState(StakeCardState.NORMAL); const [showUniV3APRModal, setShowUniV3APRModal] = useState(false); - const [showStakeModal, setShowStakeModal] = useState(false); - const [isFirstStakeShown, setIsFirstStakeShown] = useState(false); const [showUnStakeModal, setShowUnStakeModal] = useState(false); const [showHarvestModal, setShowHarvestModal] = useState(false); const [showLockModal, setShowLockModal] = useState(false); @@ -110,9 +104,7 @@ const BaseStakingCard: FC = ({ useState(false); const [showLockDetailModal, setShowLockDetailModal] = useState(false); - const router = useRouter(); - - const { chainId, account, active: isWalletActive } = useWeb3React(); + const { chainId } = useWeb3React(); const { regenStreamType } = poolStakingConfig as RegenPoolStakingConfig; @@ -128,33 +120,6 @@ const BaseStakingCard: FC = ({ network: poolNetwork, } = poolStakingConfig; - useEffect(() => { - if (isFirstStakeShown || !router) return; - const { open, chain } = router.query; - const _open = Array.isArray(open) ? open[0] : open; - const _chain = Array.isArray(chain) ? chain[0] : chain; - const _chainId = - _chain === 'gnosis' - ? config.XDAI_NETWORK_NUMBER - : config.MAINNET_NETWORK_NUMBER; - const checkNetworkAndShowStakeModal = async () => { - if ( - _chainId === chainId && - _chainId === poolNetwork && - _open === type - ) { - if (account) { - setShowStakeModal(true); - setIsFirstStakeShown(true); - router.replace(Routes.GIVfarm, undefined, { - shallow: true, - }); - } - } - }; - checkNetworkAndShowStakeModal(); - }, [router, account, isWalletActive]); - const isGIVStaking = type === StakingType.GIV_LM; const isGIVpower = isGIVStaking && poolNetwork === config.XDAI_NETWORK_NUMBER; @@ -209,7 +174,6 @@ const BaseStakingCard: FC = ({ regenStreamConfig={regenStreamConfig} isDiscontinued={isDiscontinued} isGIVpower={isGIVpower} - setShowStakeModal={setShowStakeModal} setShowUnStakeModal={setShowUnStakeModal} setShowHarvestModal={setShowHarvestModal} /> @@ -227,24 +191,7 @@ const BaseStakingCard: FC = ({ {showGIVPowerExplain && ( )} - {showStakeModal && - (isGIVpower ? ( - setShowLockModal(true)} - /> - ) : ( - - ))} + {showUnStakeModal && ( >; setShowUnStakeModal: React.Dispatch>; setShowHarvestModal: React.Dispatch>; } @@ -61,25 +66,27 @@ export const StakingPoolInfoAndActions: FC = ({ regenStreamConfig, isDiscontinued, isGIVpower, - setShowStakeModal, setShowUnStakeModal, setShowHarvestModal, }) => { const [started, setStarted] = useState(true); const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); const [rewardStream, setRewardStream] = useState(0); + const [isFirstStakeShown, setIsFirstStakeShown] = useState(false); //Modals const [showAPRModal, setShowAPRModal] = useState(false); + const [showStakeModal, setShowStakeModal] = useState(false); const { formatMessage } = useIntl(); const { setInfo } = useFarms(); - const { account } = useWeb3React(); + const router = useRouter(); const { apr, notStakedAmount: userNotStakedAmount, stakedAmount: stakedLpAmount, earned, } = useStakingPool(poolStakingConfig); + const { chainId, account, active: isWalletActive } = useWeb3React(); const { regenStreamType } = poolStakingConfig as RegenPoolStakingConfig; @@ -122,6 +129,33 @@ export const StakingPoolInfoAndActions: FC = ({ } }, [earned, tokenDistroHelper]); + useEffect(() => { + if (isFirstStakeShown || !router) return; + const { open, chain } = router.query; + const _open = Array.isArray(open) ? open[0] : open; + const _chain = Array.isArray(chain) ? chain[0] : chain; + const _chainId = + _chain === 'gnosis' + ? config.XDAI_NETWORK_NUMBER + : config.MAINNET_NETWORK_NUMBER; + const checkNetworkAndShowStakeModal = async () => { + if ( + _chainId === chainId && + _chainId === poolNetwork && + _open === type + ) { + if (account) { + setShowStakeModal(true); + setIsFirstStakeShown(true); + router.replace(Routes.GIVfarm, undefined, { + shallow: true, + }); + } + } + }; + checkNetworkAndShowStakeModal(); + }, [router, account, isWalletActive]); + const userGIVPowerBalance = sdh.getUserGIVPowerBalance(); const rewardTokenSymbol = regenStreamConfig?.rewardTokenSymbol || 'GIV'; const isZeroGIVStacked = @@ -413,6 +447,25 @@ export const StakingPoolInfoAndActions: FC = ({ poolNetwork={poolNetwork} /> )} + {showStakeModal && + (isGIVpower ? ( + setShowLockModal(true)} + showLockModal={() => console.log('TODO!')} + /> + ) : ( + + ))} ); }; From 96cab4459f1c5b75cec49d963f0fcf6e0c7685da Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 13:16:15 +0330 Subject: [PATCH 061/163] move unStake modal to StakingPoolInfoAndActions --- .../BaseStakingCard/BaseStakingCard.tsx | 13 ------------- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 13 +++++++++++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 9b2a8436fb..39f2ba035b 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -6,7 +6,6 @@ import { PoolStakingConfig, RegenFarmConfig, RegenPoolStakingConfig, - SimplePoolStakingConfig, StakingPlatform, StakingType, } from '@/types/config'; @@ -36,7 +35,6 @@ import { ArchiveCover } from './ArchiveCover'; import { StakingCardHeader } from './StakingCardHeader'; import { getNowUnixMS } from '@/helpers/time'; import { StakingPoolInfoAndActions } from './StakingPoolInfoAndActions'; -import { UnStakeModal } from '@/components/modals/Unstake/UnStake'; import { HarvestAllModal } from '@/components/modals/HarvestAll'; import type { LiquidityPosition } from '@/types/nfts'; @@ -96,7 +94,6 @@ const BaseStakingCard: FC = ({ const { formatMessage } = useIntl(); const [state, setState] = useState(StakeCardState.NORMAL); const [showUniV3APRModal, setShowUniV3APRModal] = useState(false); - const [showUnStakeModal, setShowUnStakeModal] = useState(false); const [showHarvestModal, setShowHarvestModal] = useState(false); const [showLockModal, setShowLockModal] = useState(false); const [showGIVPowerExplain, setShowGIVPowerExplain] = useState(false); @@ -174,7 +171,6 @@ const BaseStakingCard: FC = ({ regenStreamConfig={regenStreamConfig} isDiscontinued={isDiscontinued} isGIVpower={isGIVpower} - setShowUnStakeModal={setShowUnStakeModal} setShowHarvestModal={setShowHarvestModal} /> @@ -192,15 +188,6 @@ const BaseStakingCard: FC = ({ )} - {showUnStakeModal && ( - - )} {showHarvestModal && chainId && ( >; setShowHarvestModal: React.Dispatch>; } @@ -66,7 +66,6 @@ export const StakingPoolInfoAndActions: FC = ({ regenStreamConfig, isDiscontinued, isGIVpower, - setShowUnStakeModal, setShowHarvestModal, }) => { const [started, setStarted] = useState(true); @@ -76,6 +75,7 @@ export const StakingPoolInfoAndActions: FC = ({ //Modals const [showAPRModal, setShowAPRModal] = useState(false); const [showStakeModal, setShowStakeModal] = useState(false); + const [showUnStakeModal, setShowUnStakeModal] = useState(false); const { formatMessage } = useIntl(); const { setInfo } = useFarms(); @@ -466,6 +466,15 @@ export const StakingPoolInfoAndActions: FC = ({ regenStreamConfig={regenStreamConfig} /> ))} + {showUnStakeModal && ( + + )} ); }; From c8d8555bf5ea677154ca2ef5b53008be8a91a753 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 13:48:22 +0330 Subject: [PATCH 062/163] move harvest modal to StakingPoolInfoAndActions --- .../BaseStakingCard/BaseStakingCard.tsx | 17 +++---------- .../StakingPoolInfoAndActions.tsx | 24 +++++++++++++++++-- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 39f2ba035b..38455aaad6 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -35,7 +35,6 @@ import { ArchiveCover } from './ArchiveCover'; import { StakingCardHeader } from './StakingCardHeader'; import { getNowUnixMS } from '@/helpers/time'; import { StakingPoolInfoAndActions } from './StakingPoolInfoAndActions'; -import { HarvestAllModal } from '@/components/modals/HarvestAll'; import type { LiquidityPosition } from '@/types/nfts'; export enum StakeCardState { @@ -94,7 +93,6 @@ const BaseStakingCard: FC = ({ const { formatMessage } = useIntl(); const [state, setState] = useState(StakeCardState.NORMAL); const [showUniV3APRModal, setShowUniV3APRModal] = useState(false); - const [showHarvestModal, setShowHarvestModal] = useState(false); const [showLockModal, setShowLockModal] = useState(false); const [showGIVPowerExplain, setShowGIVPowerExplain] = useState(false); const [showWhatIsGIVstreamModal, setShowWhatIsGIVstreamModal] = @@ -171,7 +169,9 @@ const BaseStakingCard: FC = ({ regenStreamConfig={regenStreamConfig} isDiscontinued={isDiscontinued} isGIVpower={isGIVpower} - setShowHarvestModal={setShowHarvestModal} + stakedPositions={stakedPositions} + unstakedPositions={unstakedPositions} + currentIncentive={currentIncentive} /> ) : state === StakeCardState.GIVPOWER_INTRO ? ( @@ -188,17 +188,6 @@ const BaseStakingCard: FC = ({ )} - {showHarvestModal && chainId && ( - - )} {/* {showLockModal && ( >; + stakedPositions?: LiquidityPosition[]; + unstakedPositions?: LiquidityPosition[]; + currentIncentive?: { + key?: (string | number)[] | null | undefined; + }; } export const StakingPoolInfoAndActions: FC = ({ @@ -66,7 +72,9 @@ export const StakingPoolInfoAndActions: FC = ({ regenStreamConfig, isDiscontinued, isGIVpower, - setShowHarvestModal, + stakedPositions, + unstakedPositions, + currentIncentive, }) => { const [started, setStarted] = useState(true); const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); @@ -76,6 +84,7 @@ export const StakingPoolInfoAndActions: FC = ({ const [showAPRModal, setShowAPRModal] = useState(false); const [showStakeModal, setShowStakeModal] = useState(false); const [showUnStakeModal, setShowUnStakeModal] = useState(false); + const [showHarvestModal, setShowHarvestModal] = useState(false); const { formatMessage } = useIntl(); const { setInfo } = useFarms(); @@ -475,6 +484,17 @@ export const StakingPoolInfoAndActions: FC = ({ regenStreamConfig={regenStreamConfig} /> )} + {showHarvestModal && chainId && ( + + )} ); }; From 7c6ec32d6471ddedf93d8abf480fcec78655cfb6 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 13:57:24 +0330 Subject: [PATCH 063/163] move lock modal to StakingPoolInfoAndActions --- .../StakingCards/BaseStakingCard/BaseStakingCard.tsx | 8 -------- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 38455aaad6..ed712b6e0f 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -93,7 +93,6 @@ const BaseStakingCard: FC = ({ const { formatMessage } = useIntl(); const [state, setState] = useState(StakeCardState.NORMAL); const [showUniV3APRModal, setShowUniV3APRModal] = useState(false); - const [showLockModal, setShowLockModal] = useState(false); const [showGIVPowerExplain, setShowGIVPowerExplain] = useState(false); const [showWhatIsGIVstreamModal, setShowWhatIsGIVstreamModal] = useState(false); @@ -188,13 +187,6 @@ const BaseStakingCard: FC = ({ )} - {/* {showLockModal && ( - - )} */} {/* {showWhatIsGIVstreamModal && ( = ({ const [showStakeModal, setShowStakeModal] = useState(false); const [showUnStakeModal, setShowUnStakeModal] = useState(false); const [showHarvestModal, setShowHarvestModal] = useState(false); + const [showLockModal, setShowLockModal] = useState(false); const { formatMessage } = useIntl(); const { setInfo } = useFarms(); @@ -495,6 +497,13 @@ export const StakingPoolInfoAndActions: FC = ({ currentIncentive={currentIncentive} /> )} + {showLockModal && ( + + )} ); }; From 8525a43a0cbab8e1a35eeddd4ba246aee971b288 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 14:07:24 +0330 Subject: [PATCH 064/163] move WhatIsStream modal to StakingPoolInfoAndActions --- .../BaseStakingCard/BaseStakingCard.tsx | 10 +--------- .../StakingPoolInfoAndActions.tsx | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index ed712b6e0f..b8e67b92f2 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -94,8 +94,7 @@ const BaseStakingCard: FC = ({ const [state, setState] = useState(StakeCardState.NORMAL); const [showUniV3APRModal, setShowUniV3APRModal] = useState(false); const [showGIVPowerExplain, setShowGIVPowerExplain] = useState(false); - const [showWhatIsGIVstreamModal, setShowWhatIsGIVstreamModal] = - useState(false); + const [showLockDetailModal, setShowLockDetailModal] = useState(false); const { chainId } = useWeb3React(); @@ -187,13 +186,6 @@ const BaseStakingCard: FC = ({ )} - {/* {showWhatIsGIVstreamModal && ( - - )} */} {/* {showLockDetailModal && ( = ({ const [showUnStakeModal, setShowUnStakeModal] = useState(false); const [showHarvestModal, setShowHarvestModal] = useState(false); const [showLockModal, setShowLockModal] = useState(false); + const [showWhatIsGIVstreamModal, setShowWhatIsGIVstreamModal] = + useState(false); const { formatMessage } = useIntl(); const { setInfo } = useFarms(); @@ -310,9 +314,9 @@ export const StakingPoolInfoAndActions: FC = ({ })} { - // setShowWhatIsGIVstreamModal(true); - // }} + onClick={() => { + setShowWhatIsGIVstreamModal(true); + }} > @@ -504,6 +508,13 @@ export const StakingPoolInfoAndActions: FC = ({ maxAmount={availableStakedToken} /> )} + {showWhatIsGIVstreamModal && ( + + )} ); }; From 38221e8f30f7e73efcbeb9e7977b57c94202851e Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 14:08:47 +0330 Subject: [PATCH 065/163] move LockupDetails modal to StakingPoolInfoAndActions --- .../StakingCards/BaseStakingCard/BaseStakingCard.tsx | 9 --------- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 8 ++++++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index b8e67b92f2..d392780f04 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -95,8 +95,6 @@ const BaseStakingCard: FC = ({ const [showUniV3APRModal, setShowUniV3APRModal] = useState(false); const [showGIVPowerExplain, setShowGIVPowerExplain] = useState(false); - const [showLockDetailModal, setShowLockDetailModal] = useState(false); - const { chainId } = useWeb3React(); const { regenStreamType } = poolStakingConfig as RegenPoolStakingConfig; @@ -185,13 +183,6 @@ const BaseStakingCard: FC = ({ {showGIVPowerExplain && ( )} - - {/* {showLockDetailModal && ( - - )} */} ); }; diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index 314046cb8c..04bcd101fd 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -57,6 +57,7 @@ import { HarvestAllModal } from '@/components/modals/HarvestAll'; import { LiquidityPosition } from '@/types/nfts'; import LockModal from '@/components/modals/StakeLock/Lock'; import { WhatIsStreamModal } from '@/components/modals/WhatIsStream'; +import { LockupDetailsModal } from '@/components/modals/LockupDetailsModal'; interface IStakingPoolInfoAndActionsProps { poolStakingConfig: PoolStakingConfig | RegenPoolStakingConfig; @@ -89,6 +90,7 @@ export const StakingPoolInfoAndActions: FC = ({ const [showUnStakeModal, setShowUnStakeModal] = useState(false); const [showHarvestModal, setShowHarvestModal] = useState(false); const [showLockModal, setShowLockModal] = useState(false); + const [showLockDetailModal, setShowLockDetailModal] = useState(false); const [showWhatIsGIVstreamModal, setShowWhatIsGIVstreamModal] = useState(false); @@ -515,6 +517,12 @@ export const StakingPoolInfoAndActions: FC = ({ regenStreamConfig={regenStreamConfig} /> )} + {showLockDetailModal && ( + + )} ); }; From 79b2305e4e80dea8e28eaeee30badb1902fad88d Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 14:14:02 +0330 Subject: [PATCH 066/163] enable functionalities --- .../StakingPoolInfoAndActions.tsx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index 04bcd101fd..f40972617f 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -113,6 +113,7 @@ export const StakingPoolInfoAndActions: FC = ({ farmStartTimeMS, exploited, network: poolNetwork, + provideLiquidityLink, } = poolStakingConfig; const { tokenDistroHelper, sdh } = useTokenDistroHelper( poolNetwork, @@ -362,7 +363,7 @@ export const StakingPoolInfoAndActions: FC = ({ {isGIVpower && ( setShowLockModal(true)} + onClick={() => setShowLockModal(true)} label={formatMessage({ id: 'label.increase_rewards', })} @@ -427,13 +428,13 @@ export const StakingPoolInfoAndActions: FC = ({ label={formatMessage({ id: 'label.provide_liquidity', })} - // onClick={() => { - // if (type === StakingType.UNISWAPV3_ETH_GIV) { - // setShowUniV3APRModal(true); - // } else { - // window.open(provideLiquidityLink); - // } - // }} + onClick={() => { + if (type === StakingType.UNISWAPV3_ETH_GIV) { + // setShowUniV3APRModal(true); + } else { + window.open(provideLiquidityLink); + } + }} buttonType='texty' icon={ = ({ id: 'label.locked_giv_details', })} disabled={!isLocked} - // onClick={() => { - // setShowLockDetailModal(true); - // }} + onClick={() => { + setShowLockDetailModal(true); + }} /> ))} {showAPRModal && ( @@ -471,8 +472,7 @@ export const StakingPoolInfoAndActions: FC = ({ poolStakingConfig={ poolStakingConfig as SimplePoolStakingConfig } - // showLockModal={() => setShowLockModal(true)} - showLockModal={() => console.log('TODO!')} + showLockModal={() => setShowLockModal(true)} /> ) : ( Date: Mon, 27 Feb 2023 14:31:37 +0330 Subject: [PATCH 067/163] update lock modal to cal in itself --- src/components/modals/StakeLock/Lock.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/modals/StakeLock/Lock.tsx b/src/components/modals/StakeLock/Lock.tsx index 98ef34856a..44c39a01bb 100644 --- a/src/components/modals/StakeLock/Lock.tsx +++ b/src/components/modals/StakeLock/Lock.tsx @@ -6,7 +6,6 @@ import { P, semanticColors, } from '@giveth/ui-design-system'; -import { BigNumber } from 'ethers'; import { FC, useState } from 'react'; import styled from 'styled-components'; import { captureException } from '@sentry/nextjs'; @@ -35,11 +34,13 @@ import { Flex } from '@/components/styled-components/Flex'; import links from '@/lib/constants/links'; import ExternalLink from '@/components/ExternalLink'; import Routes from '@/lib/constants/Routes'; +import { useStakingPool } from '@/hooks/useStakingPool'; +import { useTokenDistroHelper } from '@/hooks/useTokenDistroHelper'; import type { PoolStakingConfig } from '@/types/config'; interface ILockModalProps extends IModal { poolStakingConfig: PoolStakingConfig; - maxAmount: BigNumber; + isGIVpower: boolean; } export enum ELockState { @@ -52,7 +53,7 @@ export enum ELockState { const LockModal: FC = ({ poolStakingConfig, - maxAmount, + isGIVpower, setShowModal, }) => { const { formatMessage } = useIntl(); @@ -61,6 +62,17 @@ const LockModal: FC = ({ const [lockState, setLockState] = useState(ELockState.LOCK); const { library } = useWeb3React(); const { isAnimating, closeModal } = useModalAnimation(setShowModal); + const { stakedAmount: stakedLpAmount } = useStakingPool(poolStakingConfig); + + const { network: poolNetwork } = poolStakingConfig; + + const { sdh } = useTokenDistroHelper(poolNetwork); + + const userGIVLocked = sdh.getUserGIVLockedBalance(); + + const maxAmount = isGIVpower + ? stakedLpAmount.sub(userGIVLocked.balance) + : stakedLpAmount; const onLock = async () => { const contractAddress = config.XDAI_CONFIG.GIV.LM_ADDRESS; From 738cb9d3255ee6e2e50cd295420b52cbe4736c50 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 27 Feb 2023 14:32:04 +0330 Subject: [PATCH 068/163] update StakingPoolInfoAndActions performance --- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index f40972617f..d6e7f9e982 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -94,6 +94,12 @@ export const StakingPoolInfoAndActions: FC = ({ const [showWhatIsGIVstreamModal, setShowWhatIsGIVstreamModal] = useState(false); + const hold = + showAPRModal || + showStakeModal || + showUnStakeModal || + showHarvestModal || + showLockModal; const { formatMessage } = useIntl(); const { setInfo } = useFarms(); const router = useRouter(); @@ -102,7 +108,7 @@ export const StakingPoolInfoAndActions: FC = ({ notStakedAmount: userNotStakedAmount, stakedAmount: stakedLpAmount, earned, - } = useStakingPool(poolStakingConfig); + } = useStakingPool(poolStakingConfig, hold); const { chainId, account, active: isWalletActive } = useWeb3React(); const { regenStreamType } = poolStakingConfig as RegenPoolStakingConfig; @@ -119,6 +125,7 @@ export const StakingPoolInfoAndActions: FC = ({ poolNetwork, regenStreamType, regenStreamConfig, + hold, ); const userGIVLocked = sdh.getUserGIVLockedBalance(); @@ -507,7 +514,7 @@ export const StakingPoolInfoAndActions: FC = ({ )} {showWhatIsGIVstreamModal && ( From 7bd7e7993d74c78a8d20daba22e2e164303236f1 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Feb 2023 19:56:25 +0330 Subject: [PATCH 069/163] fix info part --- src/components/FarmCountDown.tsx | 3 +-- .../BaseStakingCard/BaseStakingCard.sc.tsx | 14 ++++---------- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 14 ++++++-------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/components/FarmCountDown.tsx b/src/components/FarmCountDown.tsx index 75bfdaf858..9184c392f3 100644 --- a/src/components/FarmCountDown.tsx +++ b/src/components/FarmCountDown.tsx @@ -38,12 +38,11 @@ const FarmCountDown: FC = ({ startTime, setStarted }) => { }; const FarmCountDownContainer = styled(Flex)` - height: 132px; + height: 104px; gap: 8px; `; const Timer = styled(Lead)` - /* width: 132px; */ & > span { width: 1ch; display: inline-block; diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx index 2642ab1ffa..9e4e94bd7c 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx @@ -35,7 +35,7 @@ export const StakingPoolExchange = styled(Overline)` export const SPTitle = styled(Flex)` margin-top: 2px; - margin-bottom: 24px; + margin-bottom: 36px; `; export const StakingPoolLabel = styled(H4)``; @@ -46,15 +46,9 @@ export const StakePoolInfoContainer = styled.div` padding: 0 24px; `; -export const Details = styled.div` - margin: 12px 0; -`; -export const FirstDetail = styled(Flex)` - margin-bottom: 28px; -`; - -export const Detail = styled(Flex)` - margin-bottom: 16px; +export const Details = styled(Flex)` + flex-direction: column; + gap: 16px; `; export const DetailLabel = styled(Caption)``; diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index d6e7f9e982..a3c35fb98b 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -25,12 +25,10 @@ import { } from '@/types/config'; import { Details, - FirstDetail, DetailLabel, AngelVaultTooltip, DetailValue, IconContainer, - Detail, IconHelpFilledWrapper, DetailUnit, StakePoolInfoContainer, @@ -190,7 +188,7 @@ export const StakingPoolInfoAndActions: FC = ({ {started ? (
- + APR {type === StakingType.ICHI_GIV_ONEGIV && ( @@ -295,8 +293,8 @@ export const StakingPoolInfoAndActions: FC = ({
)}
- - + + {formatMessage({ id: 'label.claimable', @@ -315,8 +313,8 @@ export const StakingPoolInfoAndActions: FC = ({ )} - - + + {formatMessage({ @@ -350,7 +348,7 @@ export const StakingPoolInfoAndActions: FC = ({ })} - + ) : ( Date: Tue, 28 Feb 2023 20:00:32 +0330 Subject: [PATCH 070/163] remove unused --- .../cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index d392780f04..f05c79f6d5 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -92,20 +92,15 @@ const BaseStakingCard: FC = ({ }) => { const { formatMessage } = useIntl(); const [state, setState] = useState(StakeCardState.NORMAL); - const [showUniV3APRModal, setShowUniV3APRModal] = useState(false); const [showGIVPowerExplain, setShowGIVPowerExplain] = useState(false); const { chainId } = useWeb3React(); - const { regenStreamType } = poolStakingConfig as RegenPoolStakingConfig; - const { type, title, icon, description, - provideLiquidityLink, - unit, farmEndTimeMS, exploited, network: poolNetwork, From 5ca212b3b7e05ed4ed2420ad0ce22a955be0d3be Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Feb 2023 20:00:43 +0330 Subject: [PATCH 071/163] fix HarvestButtonsWrapper --- .../StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx index 9e4e94bd7c..8f05aa3433 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx @@ -59,7 +59,6 @@ export const DetailUnit = styled(P)` export const ClaimButton = styled(Button)` width: 100%; - margin-top: 16px; `; export const StakeButtonsRow = styled(Flex)` @@ -182,5 +181,9 @@ export const GIVgardenTooltip = styled.div` `; export const HarvestButtonsWrapper = styled(Flex)` + margin-top: 32px; flex-direction: column; + height: 112px; + gap: 16px; + justify-content: center; `; From 22116d36795c9ff1c9bd7061d9d2c6ec32dd37c8 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Feb 2023 20:09:07 +0330 Subject: [PATCH 072/163] fix bottom styles --- .../BaseStakingCard/BaseStakingCard.sc.tsx | 4 ++-- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx index 8f05aa3433..68e12eb454 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx @@ -62,7 +62,7 @@ export const ClaimButton = styled(Button)` `; export const StakeButtonsRow = styled(Flex)` - margin: 16px 0; + margin-top: 16px; gap: 16px; `; @@ -79,8 +79,8 @@ export const StakeAmount = styled(Caption)` `; export const LiquidityButton = styled(Button)` + margin-top: 8px; width: 100%; - margin-bottom: 16px; `; export const IconContainer = styled.div` diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index a3c35fb98b..70b1b2d711 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -56,6 +56,7 @@ import { LiquidityPosition } from '@/types/nfts'; import LockModal from '@/components/modals/StakeLock/Lock'; import { WhatIsStreamModal } from '@/components/modals/WhatIsStream'; import { LockupDetailsModal } from '@/components/modals/LockupDetailsModal'; +import ExternalLink from '@/components/ExternalLink'; interface IStakingPoolInfoAndActionsProps { poolStakingConfig: PoolStakingConfig | RegenPoolStakingConfig; @@ -428,18 +429,12 @@ export const StakingPoolInfoAndActions: FC = ({ {!(exploited || isDiscontinued) && (!isGIVpower ? ( - + { - if (type === StakingType.UNISWAPV3_ETH_GIV) { - // setShowUniV3APRModal(true); - } else { - window.open(provideLiquidityLink); - } - }} buttonType='texty' icon={ = ({ /> } /> - + ) : ( - Date: Tue, 28 Feb 2023 20:29:47 +0330 Subject: [PATCH 073/163] fix intro card height --- src/components/cards/StakingCards/StakingCardIntro.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/cards/StakingCards/StakingCardIntro.tsx b/src/components/cards/StakingCards/StakingCardIntro.tsx index 313ec70c8f..aeec4c6a51 100644 --- a/src/components/cards/StakingCards/StakingCardIntro.tsx +++ b/src/components/cards/StakingCards/StakingCardIntro.tsx @@ -51,6 +51,7 @@ const StakingCardIntro: FC = ({ })} href={introCard?.link} linkType='texty' + size='small' target='_blank' icon={ Date: Wed, 1 Mar 2023 11:59:22 +0330 Subject: [PATCH 074/163] separate regenPools from regenStreams --- src/types/config.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/types/config.ts b/src/types/config.ts index 829e437468..03ef7a64c2 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -102,7 +102,7 @@ export interface GasPreference { maxPriorityFeePerGas?: string; } -export interface RegenFarmConfig { +export interface RegenStreamConfig { title: string; tokenDistroAddress: string; type: StreamType; @@ -110,7 +110,6 @@ export interface RegenFarmConfig { rewardTokenSymbol: string; // For price purpose tokenAddressOnUniswapV2: string; - pools: RegenPoolStakingConfig[]; introCard?: IntroCardConfig; } @@ -139,9 +138,9 @@ export interface BasicNetworkConfig { | UniswapV3PoolStakingConfig | ICHIPoolStakingConfig >; + regenPools: RegenPoolStakingConfig[]; uniswapV2Subgraph: string; - - regenFarms: RegenFarmConfig[]; + regenStreams: RegenStreamConfig[]; } interface MainnetNetworkConfig extends BasicNetworkConfig { From 557579d9b003d03c924af2db2cd880d00884816a Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 11:59:39 +0330 Subject: [PATCH 075/163] update development configs --- src/config/development.ts | 102 +++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/src/config/development.ts b/src/config/development.ts index 6dc02bb5de..ea520c2b78 100644 --- a/src/config/development.ts +++ b/src/config/development.ts @@ -112,9 +112,10 @@ const config: EnvConfig = { // }, // }, ], + regenPools: [], uniswapV2Subgraph: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2', - regenFarms: [ + regenStreams: [ // // TODO: GOERLI // { // tokenDistroAddress: @@ -234,10 +235,57 @@ const config: EnvConfig = { }, ], + regenPools: [ + { + network: XDAI_NETWORK_NUMBER, + POOL_ADDRESS: '0xD28C07F802212F04AF41834ec0CC81d2d283124B', + LM_ADDRESS: '0x06851400866e065972ff21e1ECdE035b4772736d', + type: StakingType.HONEYSWAP_FOX_HNY, + platform: StakingPlatform.HONEYSWAP, + title: 'FOX / HNY', + description: '50% FOX, 50% HNY', + provideLiquidityLink: + 'https://app.honeyswap.org/#/add/0x18cE354571ba71bC7b3d633b254954C5A9cfC195/0x69F79C9eA174d4659B18c7993c7EFbBbB58cF068', + unit: 'LP', + regenStreamType: StreamType.FOX, + regenFarmType: RegenFarmType.FOX_HNY, + + farmStartTimeMS: 1646306818206, + farmEndTimeMS: 1665932450000, + introCard: { + title: 'ShapeShift DAO', + description: + 'ShapeShift is the free and open-source one-stop-shop for cross-chain DeFi. Buy, sell, send, receive, trade, and earn yield on your crypto across a growing number of protocols and chains with no added fees ever. FOX is the governance token of the ShapeShift DAO.', + link: 'https://shapeshift.com/', + }, + }, + { + network: XDAI_NETWORK_NUMBER, + POOL_ADDRESS: '0x0714A2fE9574F591a4ed3fD03b63714e8681fBb7', + LM_ADDRESS: '0x93c40bCA6a854B2190a054136a316C4Df7f89f10', + type: StakingType.HONEYSWAP_FOX_XDAI, + platform: StakingPlatform.HONEYSWAP, + title: 'FOX / xDAI', + description: '50% FOX, 50% xDAI', + provideLiquidityLink: + 'https://app.honeyswap.org/#/add/0x18cE354571ba71bC7b3d633b254954C5A9cfC195/0x97c4dD5cE204b8c1F2f3B8fBfBBDC771d867d18c', + unit: 'LP', + regenStreamType: StreamType.FOX, + regenFarmType: RegenFarmType.FOX_XDAI, + farmStartTimeMS: 1646306818206, + introCard: { + title: 'ShapeShift DAO', + description: + 'ShapeShift is the free and open-source one-stop-shop for cross-chain DeFi. Buy, sell, send, receive, trade, and earn yield on your crypto across a growing number of protocols and chains with no added fees ever. FOX is the governance token of the ShapeShift DAO.', + link: 'https://shapeshift.com/', + }, + }, + ], + uniswapV2Subgraph: 'https://api.thegraph.com/subgraphs/name/1hive/honeyswap-v2', - regenFarms: [ + regenStreams: [ { tokenDistroAddress: '0xCA29ec6F4218E230294993E0d77d5ece5a6573D8', @@ -248,56 +296,6 @@ const config: EnvConfig = { rewardTokenSymbol: 'FOX', tokenAddressOnUniswapV2: '0x21a42669643f45Bc0e086b8Fc2ed70c23D67509d', - pools: [ - { - network: XDAI_NETWORK_NUMBER, - POOL_ADDRESS: - '0xD28C07F802212F04AF41834ec0CC81d2d283124B', - LM_ADDRESS: - '0x06851400866e065972ff21e1ECdE035b4772736d', - type: StakingType.HONEYSWAP_FOX_HNY, - platform: StakingPlatform.HONEYSWAP, - title: 'FOX / HNY', - description: '50% FOX, 50% HNY', - provideLiquidityLink: - 'https://app.honeyswap.org/#/add/0x18cE354571ba71bC7b3d633b254954C5A9cfC195/0x69F79C9eA174d4659B18c7993c7EFbBbB58cF068', - unit: 'LP', - regenStreamType: StreamType.FOX, - regenFarmType: RegenFarmType.FOX_HNY, - - farmStartTimeMS: 1646306818206, - farmEndTimeMS: 1665932450000, - introCard: { - title: 'ShapeShift DAO', - description: - 'ShapeShift is the free and open-source one-stop-shop for cross-chain DeFi. Buy, sell, send, receive, trade, and earn yield on your crypto across a growing number of protocols and chains with no added fees ever. FOX is the governance token of the ShapeShift DAO.', - link: 'https://shapeshift.com/', - }, - }, - { - network: XDAI_NETWORK_NUMBER, - POOL_ADDRESS: - '0x0714A2fE9574F591a4ed3fD03b63714e8681fBb7', - LM_ADDRESS: - '0x93c40bCA6a854B2190a054136a316C4Df7f89f10', - type: StakingType.HONEYSWAP_FOX_XDAI, - platform: StakingPlatform.HONEYSWAP, - title: 'FOX / xDAI', - description: '50% FOX, 50% xDAI', - provideLiquidityLink: - 'https://app.honeyswap.org/#/add/0x18cE354571ba71bC7b3d633b254954C5A9cfC195/0x97c4dD5cE204b8c1F2f3B8fBfBBDC771d867d18c', - unit: 'LP', - regenStreamType: StreamType.FOX, - regenFarmType: RegenFarmType.FOX_XDAI, - farmStartTimeMS: 1646306818206, - introCard: { - title: 'ShapeShift DAO', - description: - 'ShapeShift is the free and open-source one-stop-shop for cross-chain DeFi. Buy, sell, send, receive, trade, and earn yield on your crypto across a growing number of protocols and chains with no added fees ever. FOX is the governance token of the ShapeShift DAO.', - link: 'https://shapeshift.com/', - }, - }, - ], }, ], }, From 6e8695356cfe5d7179651ff96e1c21786409e912 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 12:00:25 +0330 Subject: [PATCH 076/163] remove RegenFarmConfig from staking card --- .../BaseStakingCard/BaseStakingCard.tsx | 4 ---- .../cards/StakingCards/StakingPoolCard.tsx | 14 ++------------ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index f05c79f6d5..24ba459441 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -4,7 +4,6 @@ import { useIntl } from 'react-intl'; import { useWeb3React } from '@web3-react/core'; import { PoolStakingConfig, - RegenFarmConfig, RegenPoolStakingConfig, StakingPlatform, StakingType, @@ -74,7 +73,6 @@ export const getPoolIconWithName = ( interface IBaseStakingCardProps { poolStakingConfig: PoolStakingConfig | RegenPoolStakingConfig; notif?: ReactNode; - regenStreamConfig?: RegenFarmConfig; stakedPositions?: LiquidityPosition[]; unstakedPositions?: LiquidityPosition[]; currentIncentive?: { @@ -85,7 +83,6 @@ interface IBaseStakingCardProps { const BaseStakingCard: FC = ({ poolStakingConfig, notif, - regenStreamConfig, stakedPositions, unstakedPositions, currentIncentive, @@ -157,7 +154,6 @@ const BaseStakingCard: FC = ({ = ({ - poolStakingConfig, - regenStreamConfig, -}) => { - return ( - - ); +const StakingPoolCard: FC = ({ poolStakingConfig }) => { + return ; }; export default StakingPoolCard; From b772347a1f5659cd7186b408ea8c9f9a95cf9a50 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 12:00:45 +0330 Subject: [PATCH 077/163] get regenStreamConfig by regenStreamType --- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index 70b1b2d711..4e29b8d2bc 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -18,7 +18,6 @@ import { avgAPR } from '@/helpers/givpower'; import { BN, formatEthHelper, formatWeiHelper } from '@/helpers/number'; import { PoolStakingConfig, - RegenFarmConfig, RegenPoolStakingConfig, SimplePoolStakingConfig, StakingType, @@ -60,7 +59,6 @@ import ExternalLink from '@/components/ExternalLink'; interface IStakingPoolInfoAndActionsProps { poolStakingConfig: PoolStakingConfig | RegenPoolStakingConfig; - regenStreamConfig?: RegenFarmConfig; isDiscontinued: boolean; isGIVpower: boolean; stakedPositions?: LiquidityPosition[]; @@ -72,7 +70,6 @@ interface IStakingPoolInfoAndActionsProps { export const StakingPoolInfoAndActions: FC = ({ poolStakingConfig, - regenStreamConfig, isDiscontinued, isGIVpower, stakedPositions, @@ -111,7 +108,6 @@ export const StakingPoolInfoAndActions: FC = ({ const { chainId, account, active: isWalletActive } = useWeb3React(); const { regenStreamType } = poolStakingConfig as RegenPoolStakingConfig; - const { type, unit, @@ -120,6 +116,12 @@ export const StakingPoolInfoAndActions: FC = ({ network: poolNetwork, provideLiquidityLink, } = poolStakingConfig; + const regenStreamConfig = regenStreamType + ? config.NETWORKS_CONFIG[poolNetwork].regenStreams.find( + regenStream => regenStream.type === regenStreamType, + ) + : undefined; + const { tokenDistroHelper, sdh } = useTokenDistroHelper( poolNetwork, regenStreamType, From a6b97aecee08fb7e2e979dc08f45d3865b335c69 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 12:01:14 +0330 Subject: [PATCH 078/163] temp comment unused parts --- src/components/givfarm/GIVfrens.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/givfarm/GIVfrens.tsx b/src/components/givfarm/GIVfrens.tsx index 410f444cc6..0d2b9bb67e 100644 --- a/src/components/givfarm/GIVfrens.tsx +++ b/src/components/givfarm/GIVfrens.tsx @@ -2,9 +2,7 @@ import React, { FC } from 'react'; import { H3 } from '@giveth/ui-design-system'; import { useWeb3React } from '@web3-react/core'; import { useIntl } from 'react-intl'; -import config from '@/configuration'; import { Col } from '../Grid'; -import { RegenFarm } from '../RegenFarm'; import { Subtitle, GIVfrensLink } from './GIVfrens.sc'; interface IGIVfrensProps { @@ -14,10 +12,10 @@ interface IGIVfrensProps { export const GIVfrens: FC = ({ showArchivedPools }) => { const { chainId } = useWeb3React(); const { formatMessage } = useIntl(); - const regenFarms = - chainId === config.XDAI_NETWORK_NUMBER - ? config.XDAI_CONFIG.regenFarms - : config.MAINNET_CONFIG.regenFarms; + // const regenFarms = + // chainId === config.XDAI_NETWORK_NUMBER + // ? config.XDAI_CONFIG.regenFarms + // : config.MAINNET_CONFIG.regenFarms; return ( <> @@ -40,13 +38,13 @@ export const GIVfrens: FC = ({ showArchivedPools }) => { . - {regenFarms.map((regenFarm, index) => ( + {/* {regenFarms.map((regenFarm, index) => ( - ))} + ))} */} ); }; From e7eb7ed60f524384d2e759d7399a42583d672b68 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 12:02:01 +0330 Subject: [PATCH 079/163] temp comment unused parts --- src/components/RegenFarm.tsx | 41 ++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/components/RegenFarm.tsx b/src/components/RegenFarm.tsx index 5736001a78..b1cfc8aa6d 100644 --- a/src/components/RegenFarm.tsx +++ b/src/components/RegenFarm.tsx @@ -2,23 +2,18 @@ import React, { FC } from 'react'; import { useWeb3React } from '@web3-react/core'; import { H4 } from '@giveth/ui-design-system'; import styled from 'styled-components'; -import { - givEconomySupportedNetworks, - regenFarmStreamCardCol, - TWO_WEEK, -} from '@/lib/constants/constants'; +import { givEconomySupportedNetworks } from '@/lib/constants/constants'; import { Row, Col } from './Grid'; import { PoolRow } from './homeTabs/GIVfarm.sc'; import config from '@/configuration'; -import { RegenFarmConfig } from '@/types/config'; import { DAOChangeNetworkModal } from './DAOChangeNetworkModal'; import { DAOContainer, DAOChangeNetwork } from './givfarm/GIVfrens.sc'; import { RegenStreamCard } from './givfarm/RegenStreamCard'; import { getNowUnixMS } from '@/helpers/time'; -import StakingPoolCard from './cards/StakingCards/StakingPoolCard'; +import { RegenStreamConfig } from '@/types/config'; interface IRegenFarmProps { - regenFarm: RegenFarmConfig; + regenFarm: RegenStreamConfig; showArchivedPools: boolean; } @@ -27,39 +22,39 @@ export const RegenFarm: FC = ({ showArchivedPools, }) => { const { chainId } = useWeb3React(); - const { pools } = regenFarm; + // const { pools } = regenFarm; const now = getNowUnixMS(); - const filteredPools = showArchivedPools - ? pools - : pools.filter( - pool => - !( - pool.farmEndTimeMS && - now > pool.farmEndTimeMS + TWO_WEEK - ) || pool.dontArchive, - ); + // const filteredPools = showArchivedPools + // ? pools + // : pools.filter( + // pool => + // !( + // pool.farmEndTimeMS && + // now > pool.farmEndTimeMS + TWO_WEEK + // ) || pool.dontArchive, + // ); - if (filteredPools.length === 0) return null; + // if (filteredPools.length === 0) return null; return ( {regenFarm.title} - {filteredPools.map((poolStakingConfig, idx) => ( + {/* {filteredPools.map((poolStakingConfig, idx) => ( - ))} + ))} */} {regenFarm && ( Date: Wed, 1 Mar 2023 12:02:31 +0330 Subject: [PATCH 080/163] show regen pools with other pools --- src/components/homeTabs/GIVfarm.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/homeTabs/GIVfarm.tsx b/src/components/homeTabs/GIVfarm.tsx index fb03583de8..3e63012a8d 100644 --- a/src/components/homeTabs/GIVfarm.tsx +++ b/src/components/homeTabs/GIVfarm.tsx @@ -57,8 +57,18 @@ const renderPool = ( const renderPools = (chainId?: number, showArchivedPools?: boolean) => { const pools = chainId === config.XDAI_NETWORK_NUMBER - ? [...config.XDAI_CONFIG.pools, ...config.MAINNET_CONFIG.pools] - : [...config.MAINNET_CONFIG.pools, ...config.XDAI_CONFIG.pools]; + ? [ + ...config.XDAI_CONFIG.pools, + ...config.XDAI_CONFIG.regenPools, + ...config.MAINNET_CONFIG.pools, + ...config.MAINNET_CONFIG.regenPools, + ] + : [ + ...config.MAINNET_CONFIG.pools, + ...config.MAINNET_CONFIG.regenPools, + ...config.XDAI_CONFIG.pools, + ...config.XDAI_CONFIG.regenPools, + ]; const now = getNowUnixMS(); const filteredPools = []; From 3ea42e7aee146c1cbc3f43326f0fa07cd0a28863 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 12:03:44 +0330 Subject: [PATCH 081/163] update production configs --- src/config/production.ts | 194 +++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 101 deletions(-) diff --git a/src/config/production.ts b/src/config/production.ts index bdd04dd90c..2f8b5baf41 100644 --- a/src/config/production.ts +++ b/src/config/production.ts @@ -141,9 +141,55 @@ const config: EnvConfig = { farmEndTimeMS: 1660946400000, }, ], + regenPools: [ + { + network: MAINNET_NETWORK_NUMBER, + POOL_ADDRESS: '0x5281E311734869C64ca60eF047fd87759397EFe6', + LM_ADDRESS: '0xa479103c2618aD514653B53F064Bc6c9dC35a30b', + type: StakingType.UNISWAPV2_CULT_ETH, + platform: StakingPlatform.UNISWAP, + title: 'CULT / ETH', + description: '50% CULT, 50% ETH', + provideLiquidityLink: + 'https://app.uniswap.org/#/add/v2/0xf0f9D895aCa5c8678f706FB8216fa22957685A13/ETH?chain=mainnet', + unit: 'LP', + regenStreamType: StreamType.CULT, + regenFarmType: RegenFarmType.CULT_ETH, + farmStartTimeMS: 1655218800000, + introCard: { + title: 'CULT', + description: `The purpose of CULT is to empower those building and contributing to our decentralized future. Our society makes it as difficult as possible to break away from societal, economic and other norms, and CULT serves to fund and support those who are working to take back our future. CULT is a reminder that the power in people is stronger than the people in power.\n\n CULT is the governance token of the Cult DAO. Every transaction of the CULT token allows you to contribute & fast-forward economic & societal change by contributing a 0.4% tax to the treasury. Fight from within until you get out, or change the system in doing so.`, + link: 'https://cultdao.io/', + }, + exploited: true, + farmEndTimeMS: 1664922291000, + }, + { + network: MAINNET_NETWORK_NUMBER, + POOL_ADDRESS: '0x5281E311734869C64ca60eF047fd87759397EFe6', + LM_ADDRESS: '0xcA128517053e8c459E12E3aCB615bb421d768219', + type: StakingType.UNISWAPV2_CULT_ETH, + platform: StakingPlatform.UNISWAP, + title: 'CULT / ETH', + description: '50% CULT, 50% ETH - V2', + provideLiquidityLink: + 'https://app.uniswap.org/#/add/v2/0xf0f9D895aCa5c8678f706FB8216fa22957685A13/ETH?chain=mainnet', + unit: 'LP', + regenStreamType: StreamType.CULT, + regenFarmType: RegenFarmType.CULT_ETH, + farmStartTimeMS: 1668691800000, + farmEndTimeMS: 1669901843000, + dontArchive: true, + introCard: { + title: 'CULT', + description: `The purpose of CULT is to empower those building and contributing to our decentralized future. Our society makes it as difficult as possible to break away from societal, economic and other norms, and CULT serves to fund and support those who are working to take back our future. CULT is a reminder that the power in people is stronger than the people in power.\n\n CULT is the governance token of the Cult DAO. Every transaction of the CULT token allows you to contribute & fast-forward economic & societal change by contributing a 0.4% tax to the treasury. Fight from within until you get out, or change the system in doing so.`, + link: 'https://cultdao.io/', + }, + }, + ], uniswapV2Subgraph: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2', - regenFarms: [ + regenStreams: [ { tokenDistroAddress: '0x73f2D115C2cBAa3b5F477A78F7A7CD348D8b70a2', @@ -154,56 +200,6 @@ const config: EnvConfig = { rewardTokenSymbol: 'CULT', tokenAddressOnUniswapV2: '0xf0f9D895aCa5c8678f706FB8216fa22957685A13', - pools: [ - { - network: MAINNET_NETWORK_NUMBER, - POOL_ADDRESS: - '0x5281E311734869C64ca60eF047fd87759397EFe6', - LM_ADDRESS: - '0xa479103c2618aD514653B53F064Bc6c9dC35a30b', - type: StakingType.UNISWAPV2_CULT_ETH, - platform: StakingPlatform.UNISWAP, - title: 'CULT / ETH', - description: '50% CULT, 50% ETH', - provideLiquidityLink: - 'https://app.uniswap.org/#/add/v2/0xf0f9D895aCa5c8678f706FB8216fa22957685A13/ETH?chain=mainnet', - unit: 'LP', - regenStreamType: StreamType.CULT, - regenFarmType: RegenFarmType.CULT_ETH, - farmStartTimeMS: 1655218800000, - introCard: { - title: 'CULT', - description: `The purpose of CULT is to empower those building and contributing to our decentralized future. Our society makes it as difficult as possible to break away from societal, economic and other norms, and CULT serves to fund and support those who are working to take back our future. CULT is a reminder that the power in people is stronger than the people in power.\n\n CULT is the governance token of the Cult DAO. Every transaction of the CULT token allows you to contribute & fast-forward economic & societal change by contributing a 0.4% tax to the treasury. Fight from within until you get out, or change the system in doing so.`, - link: 'https://cultdao.io/', - }, - exploited: true, - farmEndTimeMS: 1664922291000, - }, - { - network: MAINNET_NETWORK_NUMBER, - POOL_ADDRESS: - '0x5281E311734869C64ca60eF047fd87759397EFe6', - LM_ADDRESS: - '0xcA128517053e8c459E12E3aCB615bb421d768219', - type: StakingType.UNISWAPV2_CULT_ETH, - platform: StakingPlatform.UNISWAP, - title: 'CULT / ETH', - description: '50% CULT, 50% ETH - V2', - provideLiquidityLink: - 'https://app.uniswap.org/#/add/v2/0xf0f9D895aCa5c8678f706FB8216fa22957685A13/ETH?chain=mainnet', - unit: 'LP', - regenStreamType: StreamType.CULT, - regenFarmType: RegenFarmType.CULT_ETH, - farmStartTimeMS: 1668691800000, - farmEndTimeMS: 1669901843000, - dontArchive: true, - introCard: { - title: 'CULT', - description: `The purpose of CULT is to empower those building and contributing to our decentralized future. Our society makes it as difficult as possible to break away from societal, economic and other norms, and CULT serves to fund and support those who are working to take back our future. CULT is a reminder that the power in people is stronger than the people in power.\n\n CULT is the governance token of the Cult DAO. Every transaction of the CULT token allows you to contribute & fast-forward economic & societal change by contributing a 0.4% tax to the treasury. Fight from within until you get out, or change the system in doing so.`, - link: 'https://cultdao.io/', - }, - }, - ], }, ], }, @@ -285,11 +281,56 @@ const config: EnvConfig = { farmStartTimeMS: 1656086400000, }, ], + regenPools: [ + { + network: XDAI_NETWORK_NUMBER, + POOL_ADDRESS: '0x8a0bee989c591142414ad67fb604539d917889df', + LM_ADDRESS: '0x502EC7a040F486EE6Cb7d634D94764874B29dE68', + type: StakingType.HONEYSWAP_FOX_HNY, + platform: StakingPlatform.HONEYSWAP, + title: 'FOX / HNY', + description: '50% FOX, 50% HNY', + provideLiquidityLink: + 'https://app.honeyswap.org/#/add/0x21a42669643f45bc0e086b8fc2ed70c23d67509d/0x71850b7e9ee3f13ab46d67167341e4bdc905eef9?chainId=100', + unit: 'LP', + regenStreamType: StreamType.FOX, + regenFarmType: RegenFarmType.FOX_HNY, + farmStartTimeMS: 1649001600000, + farmEndTimeMS: 1665932450000, + introCard: { + title: 'ShapeShift DAO', + description: + 'ShapeShift is the free and open-source one-stop-shop for cross-chain DeFi. Buy, sell, send, receive, trade, and earn yield on your crypto across a growing number of protocols and chains with no added fees ever. FOX is the governance token of the ShapeShift DAO.', + link: 'https://shapeshift.com/', + }, + }, + { + network: XDAI_NETWORK_NUMBER, + POOL_ADDRESS: '0xc22313fd39f7d4d73a89558f9e8e444c86464bac', + LM_ADDRESS: '0x9A333AD00868472c0314F76DB8dA305B83890129', + type: StakingType.HONEYSWAP_FOX_XDAI, + platform: StakingPlatform.HONEYSWAP, + title: 'FOX / xDAI', + description: '50% FOX, 50% xDAI', + provideLiquidityLink: + 'https://app.honeyswap.org/#/add/0x21a42669643f45bc0e086b8fc2ed70c23d67509d/XDAI?chainId=100', + unit: 'LP', + regenStreamType: StreamType.FOX, + regenFarmType: RegenFarmType.FOX_XDAI, + farmStartTimeMS: 1666026660000, + introCard: { + title: 'ShapeShift DAO', + description: + 'ShapeShift is the free and open-source one-stop-shop for cross-chain DeFi. Buy, sell, send, receive, trade, and earn yield on your crypto across a growing number of protocols and chains with no added fees ever. FOX is the governance token of the ShapeShift DAO.', + link: 'https://shapeshift.com/', + }, + }, + ], uniswapV2Subgraph: 'https://api.thegraph.com/subgraphs/name/1hive/honeyswap-v2', - regenFarms: [ + regenStreams: [ { tokenDistroAddress: '0xA9a37a14E562D0E1d335B4714E3455483ede7A9a', @@ -300,55 +341,6 @@ const config: EnvConfig = { rewardTokenSymbol: 'FOX', tokenAddressOnUniswapV2: '0x21a42669643f45bc0e086b8fc2ed70c23d67509d', - pools: [ - { - network: XDAI_NETWORK_NUMBER, - POOL_ADDRESS: - '0x8a0bee989c591142414ad67fb604539d917889df', - LM_ADDRESS: - '0x502EC7a040F486EE6Cb7d634D94764874B29dE68', - type: StakingType.HONEYSWAP_FOX_HNY, - platform: StakingPlatform.HONEYSWAP, - title: 'FOX / HNY', - description: '50% FOX, 50% HNY', - provideLiquidityLink: - 'https://app.honeyswap.org/#/add/0x21a42669643f45bc0e086b8fc2ed70c23d67509d/0x71850b7e9ee3f13ab46d67167341e4bdc905eef9?chainId=100', - unit: 'LP', - regenStreamType: StreamType.FOX, - regenFarmType: RegenFarmType.FOX_HNY, - farmStartTimeMS: 1649001600000, - farmEndTimeMS: 1665932450000, - introCard: { - title: 'ShapeShift DAO', - description: - 'ShapeShift is the free and open-source one-stop-shop for cross-chain DeFi. Buy, sell, send, receive, trade, and earn yield on your crypto across a growing number of protocols and chains with no added fees ever. FOX is the governance token of the ShapeShift DAO.', - link: 'https://shapeshift.com/', - }, - }, - { - network: XDAI_NETWORK_NUMBER, - POOL_ADDRESS: - '0xc22313fd39f7d4d73a89558f9e8e444c86464bac', - LM_ADDRESS: - '0x9A333AD00868472c0314F76DB8dA305B83890129', - type: StakingType.HONEYSWAP_FOX_XDAI, - platform: StakingPlatform.HONEYSWAP, - title: 'FOX / xDAI', - description: '50% FOX, 50% xDAI', - provideLiquidityLink: - 'https://app.honeyswap.org/#/add/0x21a42669643f45bc0e086b8fc2ed70c23d67509d/XDAI?chainId=100', - unit: 'LP', - regenStreamType: StreamType.FOX, - regenFarmType: RegenFarmType.FOX_XDAI, - farmStartTimeMS: 1666026660000, - introCard: { - title: 'ShapeShift DAO', - description: - 'ShapeShift is the free and open-source one-stop-shop for cross-chain DeFi. Buy, sell, send, receive, trade, and earn yield on your crypto across a growing number of protocols and chains with no added fees ever. FOX is the governance token of the ShapeShift DAO.', - link: 'https://shapeshift.com/', - }, - }, - ], }, ], }, From ac2fb9e58a716e991dd59ed150823da232db64e6 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 12:12:41 +0330 Subject: [PATCH 082/163] update SubgraphQueryBuilder --- src/lib/subgraph/subgraphQueryBuilder.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/lib/subgraph/subgraphQueryBuilder.ts b/src/lib/subgraph/subgraphQueryBuilder.ts index d70f1474e0..c20fb62766 100644 --- a/src/lib/subgraph/subgraphQueryBuilder.ts +++ b/src/lib/subgraph/subgraphQueryBuilder.ts @@ -82,7 +82,7 @@ export class SubgraphQueryBuilder { ): string => { return [ networkConfig.TOKEN_DISTRO_ADDRESS, - ...networkConfig.regenFarms.map(c => { + ...networkConfig.regenStreams.map(c => { return c.tokenDistroAddress; }), ] @@ -275,9 +275,7 @@ export class SubgraphQueryBuilder { ...(config.MAINNET_CONFIG.pools.filter( c => c.type !== StakingType.UNISWAPV3_ETH_GIV, ) as Array), - ...config.MAINNET_CONFIG.regenFarms - .map(regenFarm => regenFarm.pools) - .flat(), + ...config.MAINNET_CONFIG.regenPools, ], userAddress, )} @@ -300,9 +298,7 @@ export class SubgraphQueryBuilder { getGivStakingConfig(config.XDAI_CONFIG), ...(config.XDAI_CONFIG .pools as Array), - ...config.XDAI_CONFIG.regenFarms - .map(regenFarm => regenFarm.pools) - .flat(), + ...config.XDAI_CONFIG.regenPools, ], userAddress, )} From 998d4260e6d4c70c56ef1260d81b8d0ade2c8974 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 12:12:50 +0330 Subject: [PATCH 083/163] remove RegenFarmType --- src/config/development.ts | 4 ---- src/config/production.ts | 5 ----- src/types/config.ts | 7 ------- 3 files changed, 16 deletions(-) diff --git a/src/config/development.ts b/src/config/development.ts index ea520c2b78..ccad161223 100644 --- a/src/config/development.ts +++ b/src/config/development.ts @@ -1,6 +1,5 @@ import { EnvConfig, - RegenFarmType, StakingPlatform, StakingType, StreamType, @@ -143,7 +142,6 @@ const config: EnvConfig = { // 'https://app.uniswap.org/#/add/v2/0x3e4d3FadEE2338D420bb5E5cB26aAd96c165476c/ETH?chain=kovan', // unit: 'LP', // regenStreamType: StreamType.CULT, - // regenFarmType: RegenFarmType.CULT_ETH, // introCard: { // title: 'CULT', // description: `The purpose of CULT is to empower those building and contributing to our decentralized future. Our society makes it as difficult as possible to break away from societal, economic and other norms, and CULT serves to fund and support those who are working to take back our future. CULT is a reminder that the power in people is stronger than the people in power.\n\n CULT is the governance token of the Cult DAO. Every transaction of the CULT token allows you to contribute & fast-forward economic & societal change by contributing a 0.4% tax to the treasury. Fight from within until you get out, or change the system in doing so.`, @@ -248,7 +246,6 @@ const config: EnvConfig = { 'https://app.honeyswap.org/#/add/0x18cE354571ba71bC7b3d633b254954C5A9cfC195/0x69F79C9eA174d4659B18c7993c7EFbBbB58cF068', unit: 'LP', regenStreamType: StreamType.FOX, - regenFarmType: RegenFarmType.FOX_HNY, farmStartTimeMS: 1646306818206, farmEndTimeMS: 1665932450000, @@ -271,7 +268,6 @@ const config: EnvConfig = { 'https://app.honeyswap.org/#/add/0x18cE354571ba71bC7b3d633b254954C5A9cfC195/0x97c4dD5cE204b8c1F2f3B8fBfBBDC771d867d18c', unit: 'LP', regenStreamType: StreamType.FOX, - regenFarmType: RegenFarmType.FOX_XDAI, farmStartTimeMS: 1646306818206, introCard: { title: 'ShapeShift DAO', diff --git a/src/config/production.ts b/src/config/production.ts index 2f8b5baf41..d29ab5dfd9 100644 --- a/src/config/production.ts +++ b/src/config/production.ts @@ -1,6 +1,5 @@ import { EnvConfig, - RegenFarmType, StakingPlatform, StakingType, StreamType, @@ -154,7 +153,6 @@ const config: EnvConfig = { 'https://app.uniswap.org/#/add/v2/0xf0f9D895aCa5c8678f706FB8216fa22957685A13/ETH?chain=mainnet', unit: 'LP', regenStreamType: StreamType.CULT, - regenFarmType: RegenFarmType.CULT_ETH, farmStartTimeMS: 1655218800000, introCard: { title: 'CULT', @@ -176,7 +174,6 @@ const config: EnvConfig = { 'https://app.uniswap.org/#/add/v2/0xf0f9D895aCa5c8678f706FB8216fa22957685A13/ETH?chain=mainnet', unit: 'LP', regenStreamType: StreamType.CULT, - regenFarmType: RegenFarmType.CULT_ETH, farmStartTimeMS: 1668691800000, farmEndTimeMS: 1669901843000, dontArchive: true, @@ -294,7 +291,6 @@ const config: EnvConfig = { 'https://app.honeyswap.org/#/add/0x21a42669643f45bc0e086b8fc2ed70c23d67509d/0x71850b7e9ee3f13ab46d67167341e4bdc905eef9?chainId=100', unit: 'LP', regenStreamType: StreamType.FOX, - regenFarmType: RegenFarmType.FOX_HNY, farmStartTimeMS: 1649001600000, farmEndTimeMS: 1665932450000, introCard: { @@ -316,7 +312,6 @@ const config: EnvConfig = { 'https://app.honeyswap.org/#/add/0x21a42669643f45bc0e086b8fc2ed70c23d67509d/XDAI?chainId=100', unit: 'LP', regenStreamType: StreamType.FOX, - regenFarmType: RegenFarmType.FOX_XDAI, farmStartTimeMS: 1666026660000, introCard: { title: 'ShapeShift DAO', diff --git a/src/types/config.ts b/src/types/config.ts index 03ef7a64c2..394be700f7 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -31,12 +31,6 @@ export enum StakingType { UNISWAPV2_CULT_ETH = 'UniswapV2_CULT_ETH', } -export enum RegenFarmType { - FOX_HNY = 'FOX_HNY_FARM', - FOX_XDAI = 'FOX_XDAI_FARM', - CULT_ETH = 'CULT_ETH_FARM', -} - export enum StreamType { FOX = 'FOX_STREAM', CULT = 'CULT_STREAM', @@ -93,7 +87,6 @@ export interface IntroCardConfig { export interface RegenPoolStakingConfig extends SimplePoolStakingConfig { regenStreamType: StreamType; - regenFarmType: RegenFarmType; dontArchive?: boolean; } From 7e9ac22f31a400d2d3daec72f56add55d74e36df Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 12:42:05 +0330 Subject: [PATCH 084/163] rename giveconomy views --- pages/givbacks.tsx | 4 ++-- pages/giveconomy.tsx | 4 ++-- pages/givfarm.tsx | 2 +- pages/givgarden.tsx | 2 +- pages/givpower.tsx | 2 +- pages/givstream.tsx | 2 +- .../homeTabs/{Overview.tsx => GIVeconomy.tsx} | 0 .../views/{Back.view.tsx => GIVbacks.view.tsx} | 4 ++-- src/components/views/GIVeconomy.view.tsx | 11 +++++++++++ .../views/{Farm.view.tsx => GIVfarm.view.tsx} | 0 .../views/{Garden.view.tsx => GIVgarden.view.tsx} | 0 .../views/{Power.view.tsx => GIVpower.view.tsx} | 0 .../views/{Stream.view.tsx => GIVstream.view.tsx} | 0 src/components/views/Home.view.tsx | 11 ----------- src/config/development.ts | 1 - 15 files changed, 21 insertions(+), 22 deletions(-) rename src/components/homeTabs/{Overview.tsx => GIVeconomy.tsx} (100%) rename src/components/views/{Back.view.tsx => GIVbacks.view.tsx} (73%) create mode 100644 src/components/views/GIVeconomy.view.tsx rename src/components/views/{Farm.view.tsx => GIVfarm.view.tsx} (100%) rename src/components/views/{Garden.view.tsx => GIVgarden.view.tsx} (100%) rename src/components/views/{Power.view.tsx => GIVpower.view.tsx} (100%) rename src/components/views/{Stream.view.tsx => GIVstream.view.tsx} (100%) delete mode 100644 src/components/views/Home.view.tsx diff --git a/pages/givbacks.tsx b/pages/givbacks.tsx index 603fb8a20b..8f0b3bdfb8 100644 --- a/pages/givbacks.tsx +++ b/pages/givbacks.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react'; -import GIVbackView from '@/components/views/Back.view'; +import GIVbacksView from '@/components/views/GIVbacks.view'; import { givbacksMetatags } from '@/content/metatags'; import { GeneralMetatags } from '@/components/Metatag'; import { useAppDispatch } from '@/features/hooks'; @@ -18,7 +18,7 @@ export default function GIVbacksRoute() { return ( <> - + ); } diff --git a/pages/giveconomy.tsx b/pages/giveconomy.tsx index 4ed30029c3..be249c35b8 100644 --- a/pages/giveconomy.tsx +++ b/pages/giveconomy.tsx @@ -1,10 +1,10 @@ import { useEffect } from 'react'; -import HomeView from '@/components/views/Home.view'; import { giveconomyMetatags } from '@/content/metatags'; import { GeneralMetatags } from '@/components/Metatag'; import { setDarkTheme, setLightTheme } from '@/features/general/general.slice'; import { useAppDispatch } from '@/features/hooks'; +import GIVeconomyView from '@/components/views/GIVeconomy.view'; export default function GIVeconomyRoute() { const dispatch = useAppDispatch(); @@ -19,7 +19,7 @@ export default function GIVeconomyRoute() { return ( <> - + ); } diff --git a/pages/givfarm.tsx b/pages/givfarm.tsx index d05a969742..d3e95b4cd9 100644 --- a/pages/givfarm.tsx +++ b/pages/givfarm.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react'; -import GIVfarmView from '@/components/views/Farm.view'; +import GIVfarmView from '@/components/views/GIVfarm.view'; import { givfarmMetatags } from '@/content/metatags'; import { GeneralMetatags } from '@/components/Metatag'; import { setDarkTheme, setLightTheme } from '@/features/general/general.slice'; diff --git a/pages/givgarden.tsx b/pages/givgarden.tsx index 1e59a7b5fc..188294b5d9 100644 --- a/pages/givgarden.tsx +++ b/pages/givgarden.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react'; -import GIVgardenView from '@/components/views/Garden.view'; +import GIVgardenView from '@/components/views/GIVgarden.view'; import { givgardenMetatags } from '@/content/metatags'; import { GeneralMetatags } from '@/components/Metatag'; import { setDarkTheme, setLightTheme } from '@/features/general/general.slice'; diff --git a/pages/givpower.tsx b/pages/givpower.tsx index cf2453fdfb..eae215ec2f 100644 --- a/pages/givpower.tsx +++ b/pages/givpower.tsx @@ -1,5 +1,5 @@ import { useEffect } from 'react'; -import GIVpowerView from '@/components/views/Power.view'; +import GIVpowerView from '@/components/views/GIVpower.view'; import { GeneralMetatags } from '@/components/Metatag'; import { setDarkTheme, setLightTheme } from '@/features/general/general.slice'; import { useAppDispatch } from '@/features/hooks'; diff --git a/pages/givstream.tsx b/pages/givstream.tsx index 60913aafa4..f754bb5239 100644 --- a/pages/givstream.tsx +++ b/pages/givstream.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react'; -import GIVstreamView from '@/components/views/Stream.view'; +import GIVstreamView from '@/components/views/GIVstream.view'; import { givstreamMetatags } from '@/content/metatags'; import { GeneralMetatags } from '@/components/Metatag'; import { setDarkTheme, setLightTheme } from '@/features/general/general.slice'; diff --git a/src/components/homeTabs/Overview.tsx b/src/components/homeTabs/GIVeconomy.tsx similarity index 100% rename from src/components/homeTabs/Overview.tsx rename to src/components/homeTabs/GIVeconomy.tsx diff --git a/src/components/views/Back.view.tsx b/src/components/views/GIVbacks.view.tsx similarity index 73% rename from src/components/views/Back.view.tsx rename to src/components/views/GIVbacks.view.tsx index c3c3584d54..b416f66d98 100644 --- a/src/components/views/Back.view.tsx +++ b/src/components/views/GIVbacks.view.tsx @@ -1,6 +1,6 @@ import { TabGIVbacksTop, TabGIVbacksBottom } from '../homeTabs/GIVbacks'; -function GIVbackView() { +function GIVbacksView() { return ( <> @@ -9,4 +9,4 @@ function GIVbackView() { ); } -export default GIVbackView; +export default GIVbacksView; diff --git a/src/components/views/GIVeconomy.view.tsx b/src/components/views/GIVeconomy.view.tsx new file mode 100644 index 0000000000..7cca3d5f8a --- /dev/null +++ b/src/components/views/GIVeconomy.view.tsx @@ -0,0 +1,11 @@ +import { TabOverview } from '../homeTabs/GIVeconomy'; + +function GIVeconomyView() { + return ( + <> + + + ); +} + +export default GIVeconomyView; diff --git a/src/components/views/Farm.view.tsx b/src/components/views/GIVfarm.view.tsx similarity index 100% rename from src/components/views/Farm.view.tsx rename to src/components/views/GIVfarm.view.tsx diff --git a/src/components/views/Garden.view.tsx b/src/components/views/GIVgarden.view.tsx similarity index 100% rename from src/components/views/Garden.view.tsx rename to src/components/views/GIVgarden.view.tsx diff --git a/src/components/views/Power.view.tsx b/src/components/views/GIVpower.view.tsx similarity index 100% rename from src/components/views/Power.view.tsx rename to src/components/views/GIVpower.view.tsx diff --git a/src/components/views/Stream.view.tsx b/src/components/views/GIVstream.view.tsx similarity index 100% rename from src/components/views/Stream.view.tsx rename to src/components/views/GIVstream.view.tsx diff --git a/src/components/views/Home.view.tsx b/src/components/views/Home.view.tsx deleted file mode 100644 index 2f2ad3dbf3..0000000000 --- a/src/components/views/Home.view.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { TabOverview } from '../homeTabs/Overview'; - -function HomeView() { - return ( - <> - - - ); -} - -export default HomeView; diff --git a/src/config/development.ts b/src/config/development.ts index ccad161223..27243bf9b2 100644 --- a/src/config/development.ts +++ b/src/config/development.ts @@ -246,7 +246,6 @@ const config: EnvConfig = { 'https://app.honeyswap.org/#/add/0x18cE354571ba71bC7b3d633b254954C5A9cfC195/0x69F79C9eA174d4659B18c7993c7EFbBbB58cF068', unit: 'LP', regenStreamType: StreamType.FOX, - farmStartTimeMS: 1646306818206, farmEndTimeMS: 1665932450000, introCard: { From 149942ac6aa023a7e6d9827b1bf7f6cd06dc847e Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 12:47:57 +0330 Subject: [PATCH 085/163] rename homeTab to GIVeconomyPages --- pages/test1.tsx | 2 +- src/components/{homeTabs => GIVeconomyPages}/GIVbacks.sc.tsx | 0 src/components/{homeTabs => GIVeconomyPages}/GIVbacks.tsx | 0 src/components/{homeTabs => GIVeconomyPages}/GIVeconomy.tsx | 0 src/components/{homeTabs => GIVeconomyPages}/GIVfarm.sc.tsx | 0 src/components/{homeTabs => GIVeconomyPages}/GIVfarm.tsx | 0 .../{homeTabs => GIVeconomyPages}/GIVgarden.sc.tsx | 0 src/components/{homeTabs => GIVeconomyPages}/GIVgarden.tsx | 0 src/components/{homeTabs => GIVeconomyPages}/GIVpower.sc.tsx | 0 src/components/{homeTabs => GIVeconomyPages}/GIVpower.tsx | 0 .../{homeTabs => GIVeconomyPages}/GIVpowerVideo.tsx | 0 .../{homeTabs => GIVeconomyPages}/GIVstream.sc.tsx | 0 src/components/{homeTabs => GIVeconomyPages}/GIVstream.tsx | 0 src/components/{homeTabs => GIVeconomyPages}/Overview.sc.tsx | 0 src/components/{homeTabs => GIVeconomyPages}/commons.tsx | 0 src/components/RegenFarm.tsx | 2 +- src/components/cards/GivEconomyProjectCards.tsx | 5 ++++- src/components/givfarm/RegenStreamCard.tsx | 2 +- src/components/views/GIVbacks.view.tsx | 2 +- src/components/views/GIVeconomy.view.tsx | 2 +- src/components/views/GIVfarm.view.tsx | 2 +- src/components/views/GIVgarden.view.tsx | 2 +- src/components/views/GIVpower.view.tsx | 4 ++-- src/components/views/GIVstream.view.tsx | 5 ++++- src/components/views/homepage/videoBlock/index.tsx | 2 +- 25 files changed, 18 insertions(+), 12 deletions(-) rename src/components/{homeTabs => GIVeconomyPages}/GIVbacks.sc.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVbacks.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVeconomy.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVfarm.sc.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVfarm.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVgarden.sc.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVgarden.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVpower.sc.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVpower.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVpowerVideo.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVstream.sc.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/GIVstream.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/Overview.sc.tsx (100%) rename src/components/{homeTabs => GIVeconomyPages}/commons.tsx (100%) diff --git a/pages/test1.tsx b/pages/test1.tsx index 2f4118c2b8..4102e0bf33 100644 --- a/pages/test1.tsx +++ b/pages/test1.tsx @@ -8,7 +8,7 @@ import { useRouter } from 'next/router'; import { gToast, ToastType } from '@/components/toasts'; import { useAppDispatch } from '@/features/hooks'; import { fetchXDaiInfoAsync } from '@/features/subgraph/subgraph.thunks'; -import { FlowRateTooltip } from '@/components/homeTabs/GIVstream.sc'; +import { FlowRateTooltip } from '@/components/GIVeconomyPages/GIVstream.sc'; import { IconWithTooltip } from '@/components/IconWithToolTip'; import { Container } from '@/components/Grid'; import { removeQueryParamAndRedirect } from '@/helpers/url'; diff --git a/src/components/homeTabs/GIVbacks.sc.tsx b/src/components/GIVeconomyPages/GIVbacks.sc.tsx similarity index 100% rename from src/components/homeTabs/GIVbacks.sc.tsx rename to src/components/GIVeconomyPages/GIVbacks.sc.tsx diff --git a/src/components/homeTabs/GIVbacks.tsx b/src/components/GIVeconomyPages/GIVbacks.tsx similarity index 100% rename from src/components/homeTabs/GIVbacks.tsx rename to src/components/GIVeconomyPages/GIVbacks.tsx diff --git a/src/components/homeTabs/GIVeconomy.tsx b/src/components/GIVeconomyPages/GIVeconomy.tsx similarity index 100% rename from src/components/homeTabs/GIVeconomy.tsx rename to src/components/GIVeconomyPages/GIVeconomy.tsx diff --git a/src/components/homeTabs/GIVfarm.sc.tsx b/src/components/GIVeconomyPages/GIVfarm.sc.tsx similarity index 100% rename from src/components/homeTabs/GIVfarm.sc.tsx rename to src/components/GIVeconomyPages/GIVfarm.sc.tsx diff --git a/src/components/homeTabs/GIVfarm.tsx b/src/components/GIVeconomyPages/GIVfarm.tsx similarity index 100% rename from src/components/homeTabs/GIVfarm.tsx rename to src/components/GIVeconomyPages/GIVfarm.tsx diff --git a/src/components/homeTabs/GIVgarden.sc.tsx b/src/components/GIVeconomyPages/GIVgarden.sc.tsx similarity index 100% rename from src/components/homeTabs/GIVgarden.sc.tsx rename to src/components/GIVeconomyPages/GIVgarden.sc.tsx diff --git a/src/components/homeTabs/GIVgarden.tsx b/src/components/GIVeconomyPages/GIVgarden.tsx similarity index 100% rename from src/components/homeTabs/GIVgarden.tsx rename to src/components/GIVeconomyPages/GIVgarden.tsx diff --git a/src/components/homeTabs/GIVpower.sc.tsx b/src/components/GIVeconomyPages/GIVpower.sc.tsx similarity index 100% rename from src/components/homeTabs/GIVpower.sc.tsx rename to src/components/GIVeconomyPages/GIVpower.sc.tsx diff --git a/src/components/homeTabs/GIVpower.tsx b/src/components/GIVeconomyPages/GIVpower.tsx similarity index 100% rename from src/components/homeTabs/GIVpower.tsx rename to src/components/GIVeconomyPages/GIVpower.tsx diff --git a/src/components/homeTabs/GIVpowerVideo.tsx b/src/components/GIVeconomyPages/GIVpowerVideo.tsx similarity index 100% rename from src/components/homeTabs/GIVpowerVideo.tsx rename to src/components/GIVeconomyPages/GIVpowerVideo.tsx diff --git a/src/components/homeTabs/GIVstream.sc.tsx b/src/components/GIVeconomyPages/GIVstream.sc.tsx similarity index 100% rename from src/components/homeTabs/GIVstream.sc.tsx rename to src/components/GIVeconomyPages/GIVstream.sc.tsx diff --git a/src/components/homeTabs/GIVstream.tsx b/src/components/GIVeconomyPages/GIVstream.tsx similarity index 100% rename from src/components/homeTabs/GIVstream.tsx rename to src/components/GIVeconomyPages/GIVstream.tsx diff --git a/src/components/homeTabs/Overview.sc.tsx b/src/components/GIVeconomyPages/Overview.sc.tsx similarity index 100% rename from src/components/homeTabs/Overview.sc.tsx rename to src/components/GIVeconomyPages/Overview.sc.tsx diff --git a/src/components/homeTabs/commons.tsx b/src/components/GIVeconomyPages/commons.tsx similarity index 100% rename from src/components/homeTabs/commons.tsx rename to src/components/GIVeconomyPages/commons.tsx diff --git a/src/components/RegenFarm.tsx b/src/components/RegenFarm.tsx index b1cfc8aa6d..eabc9d79d6 100644 --- a/src/components/RegenFarm.tsx +++ b/src/components/RegenFarm.tsx @@ -4,7 +4,7 @@ import { H4 } from '@giveth/ui-design-system'; import styled from 'styled-components'; import { givEconomySupportedNetworks } from '@/lib/constants/constants'; import { Row, Col } from './Grid'; -import { PoolRow } from './homeTabs/GIVfarm.sc'; +import { PoolRow } from './GIVeconomyPages/GIVfarm.sc'; import config from '@/configuration'; import { DAOChangeNetworkModal } from './DAOChangeNetworkModal'; import { DAOContainer, DAOChangeNetwork } from './givfarm/GIVfrens.sc'; diff --git a/src/components/cards/GivEconomyProjectCards.tsx b/src/components/cards/GivEconomyProjectCards.tsx index 8e04d87ef3..267c940d79 100644 --- a/src/components/cards/GivEconomyProjectCards.tsx +++ b/src/components/cards/GivEconomyProjectCards.tsx @@ -3,7 +3,10 @@ import { useIntl } from 'react-intl'; import { Row, Col } from '@/components/Grid'; import Routes from '@/lib/constants/Routes'; import config from '@/configuration'; -import { IGsDataBox, GsButton } from '@/components/homeTabs/GIVstream.sc'; +import { + IGsDataBox, + GsButton, +} from '@/components/GIVeconomyPages/GIVstream.sc'; const GivEconomyProjectCards = () => { const { formatMessage } = useIntl(); diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 37d4a996c1..ba00bdbfe9 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -23,7 +23,7 @@ import { Bar, GsPTooltip, PercentageRow, -} from '@/components/homeTabs/GIVstream.sc'; +} from '@/components/GIVeconomyPages/GIVstream.sc'; import { IconWithTooltip } from '@/components/IconWithToolTip'; import { RegenFarmConfig, StreamType } from '@/types/config'; import { BN, formatWeiHelper } from '@/helpers/number'; diff --git a/src/components/views/GIVbacks.view.tsx b/src/components/views/GIVbacks.view.tsx index b416f66d98..1609684186 100644 --- a/src/components/views/GIVbacks.view.tsx +++ b/src/components/views/GIVbacks.view.tsx @@ -1,4 +1,4 @@ -import { TabGIVbacksTop, TabGIVbacksBottom } from '../homeTabs/GIVbacks'; +import { TabGIVbacksTop, TabGIVbacksBottom } from '../GIVeconomyPages/GIVbacks'; function GIVbacksView() { return ( diff --git a/src/components/views/GIVeconomy.view.tsx b/src/components/views/GIVeconomy.view.tsx index 7cca3d5f8a..4858e34d7f 100644 --- a/src/components/views/GIVeconomy.view.tsx +++ b/src/components/views/GIVeconomy.view.tsx @@ -1,4 +1,4 @@ -import { TabOverview } from '../homeTabs/GIVeconomy'; +import { TabOverview } from '../GIVeconomyPages/GIVeconomy'; function GIVeconomyView() { return ( diff --git a/src/components/views/GIVfarm.view.tsx b/src/components/views/GIVfarm.view.tsx index 634dee1598..d9abca7673 100644 --- a/src/components/views/GIVfarm.view.tsx +++ b/src/components/views/GIVfarm.view.tsx @@ -1,4 +1,4 @@ -import { TabGIVfarmTop, TabGIVfarmBottom } from '../homeTabs/GIVfarm'; +import { TabGIVfarmTop, TabGIVfarmBottom } from '../GIVeconomyPages/GIVfarm'; import { FarmProvider } from '@/context/farm.context'; diff --git a/src/components/views/GIVgarden.view.tsx b/src/components/views/GIVgarden.view.tsx index 9e5b9af14b..d22830d893 100644 --- a/src/components/views/GIVgarden.view.tsx +++ b/src/components/views/GIVgarden.view.tsx @@ -1,4 +1,4 @@ -import { TabGardenTop, TabGardenBottom } from '../homeTabs/GIVgarden'; +import { TabGardenTop, TabGardenBottom } from '../GIVeconomyPages/GIVgarden'; function GIVgardenView() { return ( diff --git a/src/components/views/GIVpower.view.tsx b/src/components/views/GIVpower.view.tsx index 33e0ec0314..48af3bedde 100644 --- a/src/components/views/GIVpower.view.tsx +++ b/src/components/views/GIVpower.view.tsx @@ -1,5 +1,5 @@ -import { TabPowerTop, TabPowerBottom } from '../homeTabs/GIVpower'; -import GIVpowerVideo from '@/components/homeTabs/GIVpowerVideo'; +import { TabPowerTop, TabPowerBottom } from '../GIVeconomyPages/GIVpower'; +import GIVpowerVideo from '@/components/GIVeconomyPages/GIVpowerVideo'; export default function GIVpowerView() { return ( diff --git a/src/components/views/GIVstream.view.tsx b/src/components/views/GIVstream.view.tsx index 1b66cc9723..e1accc1952 100644 --- a/src/components/views/GIVstream.view.tsx +++ b/src/components/views/GIVstream.view.tsx @@ -1,4 +1,7 @@ -import { TabGIVstreamTop, TabGIVstreamBottom } from '../homeTabs/GIVstream'; +import { + TabGIVstreamTop, + TabGIVstreamBottom, +} from '../GIVeconomyPages/GIVstream'; function GIVstreamView() { return ( diff --git a/src/components/views/homepage/videoBlock/index.tsx b/src/components/views/homepage/videoBlock/index.tsx index d90395ccda..eea9f07097 100644 --- a/src/components/views/homepage/videoBlock/index.tsx +++ b/src/components/views/homepage/videoBlock/index.tsx @@ -16,7 +16,7 @@ import { Container } from '@/components/Grid'; import { VideoContainer, VideoOverlay, -} from '@/components/homeTabs/Overview.sc'; +} from '@/components/GIVeconomyPages/Overview.sc'; import { mediaQueries } from '@/lib/constants/constants'; import Wave from '@/components/particles/Wave'; import SemiCircle from '@/components/particles/SemiCircle'; From 08b11480f9de6301bd62d4ee89f5b89693d7ecf7 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 12:52:30 +0330 Subject: [PATCH 086/163] change RegenFarmConfig type to RegenStreamConfig --- src/components/givfarm/RegenStreamCard.tsx | 4 ++-- src/components/modals/APR.tsx | 4 ++-- src/components/modals/HarvestAll.tsx | 8 ++++---- src/components/modals/StakeLock/Stake.tsx | 4 ++-- src/components/modals/Unstake/UnStake.tsx | 4 ++-- src/components/modals/WhatIsStream.tsx | 4 ++-- src/hooks/useTokenDistroHelper.tsx | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index ba00bdbfe9..9fce7ace75 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -25,7 +25,7 @@ import { PercentageRow, } from '@/components/GIVeconomyPages/GIVstream.sc'; import { IconWithTooltip } from '@/components/IconWithToolTip'; -import { RegenFarmConfig, StreamType } from '@/types/config'; +import { RegenStreamConfig, StreamType } from '@/types/config'; import { BN, formatWeiHelper } from '@/helpers/number'; import { IconFox } from '@/components/Icons/Fox'; import { IconCult } from '@/components/Icons/Cult'; @@ -40,7 +40,7 @@ import { StakeCardState } from '../cards/StakingCards/BaseStakingCard/BaseStakin interface RegenStreamProps { network: number; - streamConfig: RegenFarmConfig; + streamConfig: RegenStreamConfig; } export const getStreamIconWithType = (type: StreamType, size?: number) => { diff --git a/src/components/modals/APR.tsx b/src/components/modals/APR.tsx index 9a45711511..d728385218 100644 --- a/src/components/modals/APR.tsx +++ b/src/components/modals/APR.tsx @@ -12,13 +12,13 @@ import { Modal } from './Modal'; import { Flex } from '../styled-components/Flex'; import { IModal } from '@/types/common'; import { mediaQueries } from '@/lib/constants/constants'; -import { RegenFarmConfig, StreamType } from '@/types/config'; +import { RegenStreamConfig, StreamType } from '@/types/config'; import { useTokenDistroHelper } from '@/hooks/useTokenDistroHelper'; import { useModalAnimation } from '@/hooks/useModalAnimation'; interface IAPRInnerModalProps { poolNetwork: number; - regenStreamConfig?: RegenFarmConfig; + regenStreamConfig?: RegenStreamConfig; regenStreamType?: StreamType; } diff --git a/src/components/modals/HarvestAll.tsx b/src/components/modals/HarvestAll.tsx index ab19348eab..77c5e1ccf9 100644 --- a/src/components/modals/HarvestAll.tsx +++ b/src/components/modals/HarvestAll.tsx @@ -25,7 +25,7 @@ import { Modal } from './Modal'; import LoadingAnimation from '@/animations/loading.json'; import { PoolStakingConfig, - RegenFarmConfig, + RegenStreamConfig, SimplePoolStakingConfig, StreamType, } from '@/types/config'; @@ -81,7 +81,7 @@ interface IHarvestAllInnerModalProps { title: string; poolStakingConfig?: PoolStakingConfig; network: number; - regenStreamConfig?: RegenFarmConfig; + regenStreamConfig?: RegenStreamConfig; regenStreamType?: StreamType; stakedPositions?: LiquidityPosition[]; currentIncentive?: { @@ -93,7 +93,7 @@ interface IHarvestAllModalProps extends IModal, IHarvestAllInnerModalProps { title: string; poolStakingConfig?: PoolStakingConfig; network: number; - regenStreamConfig?: RegenFarmConfig; + regenStreamConfig?: RegenStreamConfig; regenStreamType?: StreamType; stakedPositions?: LiquidityPosition[]; currentIncentive?: { @@ -634,7 +634,7 @@ interface IEarnedBreakDownProps { tokenDistroHelper: TokenDistroHelper; setRewardLiquidPart: Dispatch>; setEarnedStream: Dispatch>; - regenStreamConfig?: RegenFarmConfig; + regenStreamConfig?: RegenStreamConfig; rewardLiquidPart: EthBigNumber; tokenSymbol: string; earnedStream: BigNumber; diff --git a/src/components/modals/StakeLock/Stake.tsx b/src/components/modals/StakeLock/Stake.tsx index 8f532a0708..37267f08fb 100644 --- a/src/components/modals/StakeLock/Stake.tsx +++ b/src/components/modals/StakeLock/Stake.tsx @@ -34,7 +34,7 @@ import { import { useModalAnimation } from '@/hooks/useModalAnimation'; import { PoolStakingConfig, - RegenFarmConfig, + RegenStreamConfig, SimplePoolStakingConfig, StakingPlatform, } from '@/types/config'; @@ -43,7 +43,7 @@ import { useStakingPool } from '@/hooks/useStakingPool'; interface IStakeInnerModalProps { poolStakingConfig: PoolStakingConfig; - regenStreamConfig?: RegenFarmConfig; + regenStreamConfig?: RegenStreamConfig; } interface IStakeModalProps extends IModal, IStakeInnerModalProps {} diff --git a/src/components/modals/Unstake/UnStake.tsx b/src/components/modals/Unstake/UnStake.tsx index 14a0bc09b1..1a8656dabe 100644 --- a/src/components/modals/Unstake/UnStake.tsx +++ b/src/components/modals/Unstake/UnStake.tsx @@ -23,7 +23,7 @@ import { StakeState } from '@/lib/staking'; import { IModal } from '@/types/common'; import { PoolStakingConfig, - RegenFarmConfig, + RegenStreamConfig, SimplePoolStakingConfig, StakingType, } from '@/types/config'; @@ -37,7 +37,7 @@ import { useStakingPool } from '@/hooks/useStakingPool'; interface IUnStakeInnerModalProps { poolStakingConfig: PoolStakingConfig; - regenStreamConfig?: RegenFarmConfig; + regenStreamConfig?: RegenStreamConfig; } interface IUnStakeModalProps extends IModal, IUnStakeInnerModalProps {} diff --git a/src/components/modals/WhatIsStream.tsx b/src/components/modals/WhatIsStream.tsx index 640c963dba..0c8e15e4da 100644 --- a/src/components/modals/WhatIsStream.tsx +++ b/src/components/modals/WhatIsStream.tsx @@ -19,12 +19,12 @@ import { IModal } from '@/types/common'; import { useAppSelector } from '@/features/hooks'; import { ETheme } from '@/features/general/general.slice'; import { useModalAnimation } from '@/hooks/useModalAnimation'; -import { RegenFarmConfig } from '@/types/config'; +import { RegenStreamConfig } from '@/types/config'; import type { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; interface IWhatIsStreamModal extends IModal { tokenDistroHelper?: TokenDistroHelper; - regenStreamConfig?: RegenFarmConfig; + regenStreamConfig?: RegenStreamConfig; cb?: any; } diff --git a/src/hooks/useTokenDistroHelper.tsx b/src/hooks/useTokenDistroHelper.tsx index 2ac7e8565c..56a5eaa582 100644 --- a/src/hooks/useTokenDistroHelper.tsx +++ b/src/hooks/useTokenDistroHelper.tsx @@ -2,13 +2,13 @@ import { useState, useEffect } from 'react'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; import config from '@/configuration'; -import { StreamType, RegenFarmConfig } from '@/types/config'; +import { StreamType, RegenStreamConfig } from '@/types/config'; import { useAppSelector } from '@/features/hooks'; export const useTokenDistroHelper = ( poolNetwork: number, regenStreamType?: StreamType, - regenStreamConfig?: RegenFarmConfig, + regenStreamConfig?: RegenStreamConfig, hold: boolean = false, ) => { const [tokenDistroHelper, setTokenDistroHelper] = From 49ab93c4f73d49f4618801317d438f3fcc70d3c8 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 13:04:50 +0330 Subject: [PATCH 087/163] collect givfarm page to a folder --- pages/givfarm.tsx | 2 +- .../views/{ => givfarm}/GIVfarm.view.tsx | 8 +- .../givfarm/GIVfarmBottom.tsx} | 82 ++----------------- src/components/views/givfarm/GIVfarmTop.tsx | 72 ++++++++++++++++ 4 files changed, 85 insertions(+), 79 deletions(-) rename src/components/views/{ => givfarm}/GIVfarm.view.tsx (56%) rename src/components/{GIVeconomyPages/GIVfarm.tsx => views/givfarm/GIVfarmBottom.tsx} (68%) create mode 100644 src/components/views/givfarm/GIVfarmTop.tsx diff --git a/pages/givfarm.tsx b/pages/givfarm.tsx index d3e95b4cd9..2eceb89d0e 100644 --- a/pages/givfarm.tsx +++ b/pages/givfarm.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react'; -import GIVfarmView from '@/components/views/GIVfarm.view'; +import GIVfarmView from '@/components/views/givfarm/GIVfarm.view'; import { givfarmMetatags } from '@/content/metatags'; import { GeneralMetatags } from '@/components/Metatag'; import { setDarkTheme, setLightTheme } from '@/features/general/general.slice'; diff --git a/src/components/views/GIVfarm.view.tsx b/src/components/views/givfarm/GIVfarm.view.tsx similarity index 56% rename from src/components/views/GIVfarm.view.tsx rename to src/components/views/givfarm/GIVfarm.view.tsx index d9abca7673..86a17e947a 100644 --- a/src/components/views/GIVfarm.view.tsx +++ b/src/components/views/givfarm/GIVfarm.view.tsx @@ -1,13 +1,13 @@ -import { TabGIVfarmTop, TabGIVfarmBottom } from '../GIVeconomyPages/GIVfarm'; - import { FarmProvider } from '@/context/farm.context'; +import { GIVfarmBottom } from './GIVfarmBottom'; +import { GIVfarmTop } from './GIVfarmTop'; function GIVfarmView() { return ( <> - - + + ); diff --git a/src/components/GIVeconomyPages/GIVfarm.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx similarity index 68% rename from src/components/GIVeconomyPages/GIVfarm.tsx rename to src/components/views/givfarm/GIVfarmBottom.tsx index 3e63012a8d..3592244e35 100644 --- a/src/components/GIVeconomyPages/GIVfarm.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -1,13 +1,6 @@ -import React, { useEffect, useState } from 'react'; -import { - IconGIVFarm, - IconExternalLink, - GLink, - IconCopy, -} from '@giveth/ui-design-system'; +import React, { useState } from 'react'; +import { IconExternalLink, GLink, IconCopy } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; -import { BigNumber } from 'bignumber.js'; -import { constants } from 'ethers'; import { useWeb3React } from '@web3-react/core'; import { Flex } from '@/components/styled-components/Flex'; import config from '@/configuration'; @@ -16,30 +9,24 @@ import { UniswapV3PoolStakingConfig, } from '@/types/config'; import { - GIVfarmTopContainer, - Subtitle, - Title, - GIVfarmRewardCard, PoolRow, ContractRow, CopyWrapper, GIVfarmBottomContainer, ArchivedPoolsToggle, -} from './GIVfarm.sc'; +} from '../../GIVeconomyPages/GIVfarm.sc'; import RadioButton from '@/components/RadioButton'; import { NetworkSelector } from '@/components/NetworkSelector'; import { getGivStakingConfig } from '@/helpers/networkProvider'; -import useGIVTokenDistroHelper from '@/hooks/useGIVTokenDistroHelper'; -import { useFarms } from '@/context/farm.context'; -import { TopInnerContainer, ExtLinkRow } from './commons'; +import { ExtLinkRow } from '../../GIVeconomyPages/commons'; import { shortenAddress } from '@/lib/helpers'; -import { Col, Container, Row } from '@/components/Grid'; +import { Col, Container } from '@/components/Grid'; import { GIVfrens } from '@/components/givfarm/GIVfrens'; -import { DaoCard } from '../givfarm/DaoCard'; +import { DaoCard } from '../../givfarm/DaoCard'; import { getNowUnixMS } from '@/helpers/time'; import { TWO_WEEK } from '@/lib/constants/constants'; -import StakingPoolCard from '../cards/StakingCards/StakingPoolCard'; +import StakingPoolCard from '../../cards/StakingCards/StakingPoolCard'; const renderPool = ( pool: SimplePoolStakingConfig | UniswapV3PoolStakingConfig, @@ -87,60 +74,7 @@ const renderPools = (chainId?: number, showArchivedPools?: boolean) => { return [...filteredPools, ...discontinuedPools]; }; -export const TabGIVfarmTop = () => { - const { formatMessage } = useIntl(); - const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); - const [rewardStream, setRewardStream] = useState(0); - const { givTokenDistroHelper } = useGIVTokenDistroHelper(); - const { totalEarned } = useFarms(); - const { chainId } = useWeb3React(); - - useEffect(() => { - setRewardLiquidPart(givTokenDistroHelper.getLiquidPart(totalEarned)); - setRewardStream( - givTokenDistroHelper.getStreamPartTokenPerWeek(totalEarned), - ); - }, [totalEarned, givTokenDistroHelper]); - - return ( - - - - - - GIVfarm - - - - {formatMessage({ - id: 'label.stake_tokens_in_the_givfarm', - })} - - - - - - - - - ); -}; - -export const TabGIVfarmBottom = () => { +export const GIVfarmBottom = () => { const { formatMessage } = useIntl(); const { chainId } = useWeb3React(); const [showArchivedPools, setArchivedPools] = useState(false); diff --git a/src/components/views/givfarm/GIVfarmTop.tsx b/src/components/views/givfarm/GIVfarmTop.tsx new file mode 100644 index 0000000000..7a6b6edf3d --- /dev/null +++ b/src/components/views/givfarm/GIVfarmTop.tsx @@ -0,0 +1,72 @@ +import { useEffect, useState } from 'react'; +import { IconGIVFarm } from '@giveth/ui-design-system'; +import { useIntl } from 'react-intl'; +import { BigNumber } from 'bignumber.js'; +import { constants } from 'ethers'; +import { useWeb3React } from '@web3-react/core'; +import { Flex } from '@/components/styled-components/Flex'; +import config from '@/configuration'; + +import { + GIVfarmTopContainer, + Subtitle, + Title, + GIVfarmRewardCard, +} from '../../GIVeconomyPages/GIVfarm.sc'; +import useGIVTokenDistroHelper from '@/hooks/useGIVTokenDistroHelper'; +import { useFarms } from '@/context/farm.context'; +import { TopInnerContainer } from '../../GIVeconomyPages/commons'; +import { Col, Row } from '@/components/Grid'; + +export const GIVfarmTop = () => { + const { formatMessage } = useIntl(); + const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); + const [rewardStream, setRewardStream] = useState(0); + const { givTokenDistroHelper } = useGIVTokenDistroHelper(); + const { totalEarned } = useFarms(); + const { chainId } = useWeb3React(); + + useEffect(() => { + setRewardLiquidPart(givTokenDistroHelper.getLiquidPart(totalEarned)); + setRewardStream( + givTokenDistroHelper.getStreamPartTokenPerWeek(totalEarned), + ); + }, [totalEarned, givTokenDistroHelper]); + + return ( + + + + + + GIVfarm + + + + {formatMessage({ + id: 'label.stake_tokens_in_the_givfarm', + })} + + + + + + + + + ); +}; From 28c2827b31bb74ea0376bbce77ebe62eeefa819d Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 13:06:41 +0330 Subject: [PATCH 088/163] rename overview.sc to giveconomy.sc --- .../GIVeconomyPages/{Overview.sc.tsx => GIVeconomy.sc.tsx} | 0 src/components/GIVeconomyPages/GIVeconomy.tsx | 2 +- src/components/views/homepage/videoBlock/index.tsx | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/components/GIVeconomyPages/{Overview.sc.tsx => GIVeconomy.sc.tsx} (100%) diff --git a/src/components/GIVeconomyPages/Overview.sc.tsx b/src/components/GIVeconomyPages/GIVeconomy.sc.tsx similarity index 100% rename from src/components/GIVeconomyPages/Overview.sc.tsx rename to src/components/GIVeconomyPages/GIVeconomy.sc.tsx diff --git a/src/components/GIVeconomyPages/GIVeconomy.tsx b/src/components/GIVeconomyPages/GIVeconomy.tsx index f79f38b3cd..f31967aff4 100644 --- a/src/components/GIVeconomyPages/GIVeconomy.tsx +++ b/src/components/GIVeconomyPages/GIVeconomy.tsx @@ -11,7 +11,7 @@ import { VoteCardQuote, DataBlockButton, TopSpacer, -} from './Overview.sc'; +} from './GIVeconomy.sc'; import { IconGIV } from '../Icons/GIV'; import config from '@/configuration'; import Routes from '@/lib/constants/Routes'; diff --git a/src/components/views/homepage/videoBlock/index.tsx b/src/components/views/homepage/videoBlock/index.tsx index eea9f07097..ce2b25b431 100644 --- a/src/components/views/homepage/videoBlock/index.tsx +++ b/src/components/views/homepage/videoBlock/index.tsx @@ -16,7 +16,7 @@ import { Container } from '@/components/Grid'; import { VideoContainer, VideoOverlay, -} from '@/components/GIVeconomyPages/Overview.sc'; +} from '@/components/GIVeconomyPages/GIVeconomy.sc'; import { mediaQueries } from '@/lib/constants/constants'; import Wave from '@/components/particles/Wave'; import SemiCircle from '@/components/particles/SemiCircle'; From 079d75dc96917e090fb42bd400d5f711d38ce8a5 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 1 Mar 2023 16:20:01 +0330 Subject: [PATCH 089/163] change title --- src/components/givfarm/GIVfrens.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/givfarm/GIVfrens.tsx b/src/components/givfarm/GIVfrens.tsx index 0d2b9bb67e..9018fd5103 100644 --- a/src/components/givfarm/GIVfrens.tsx +++ b/src/components/givfarm/GIVfrens.tsx @@ -19,7 +19,7 @@ export const GIVfrens: FC = ({ showArchivedPools }) => { return ( <> -

RegenFarms

+

RegenStreams

{formatMessage({ From 970fe7cce0b7e566089962fed0cc3ab420afc0da Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 19:20:03 +0330 Subject: [PATCH 090/163] rename givfrens to RegenStreamSection --- src/components/RegenFarm.tsx | 5 ++++- .../{GIVfrens.sc.tsx => RegenStreamSection.sc.tsx} | 0 .../givfarm/{GIVfrens.tsx => RegenStreamSection.tsx} | 8 +++++--- src/components/views/givfarm/GIVfarmBottom.tsx | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) rename src/components/givfarm/{GIVfrens.sc.tsx => RegenStreamSection.sc.tsx} (100%) rename src/components/givfarm/{GIVfrens.tsx => RegenStreamSection.tsx} (84%) diff --git a/src/components/RegenFarm.tsx b/src/components/RegenFarm.tsx index eabc9d79d6..8dedaef439 100644 --- a/src/components/RegenFarm.tsx +++ b/src/components/RegenFarm.tsx @@ -7,7 +7,10 @@ import { Row, Col } from './Grid'; import { PoolRow } from './GIVeconomyPages/GIVfarm.sc'; import config from '@/configuration'; import { DAOChangeNetworkModal } from './DAOChangeNetworkModal'; -import { DAOContainer, DAOChangeNetwork } from './givfarm/GIVfrens.sc'; +import { + DAOContainer, + DAOChangeNetwork, +} from './givfarm/RegenStreamSection.sc'; import { RegenStreamCard } from './givfarm/RegenStreamCard'; import { getNowUnixMS } from '@/helpers/time'; import { RegenStreamConfig } from '@/types/config'; diff --git a/src/components/givfarm/GIVfrens.sc.tsx b/src/components/givfarm/RegenStreamSection.sc.tsx similarity index 100% rename from src/components/givfarm/GIVfrens.sc.tsx rename to src/components/givfarm/RegenStreamSection.sc.tsx diff --git a/src/components/givfarm/GIVfrens.tsx b/src/components/givfarm/RegenStreamSection.tsx similarity index 84% rename from src/components/givfarm/GIVfrens.tsx rename to src/components/givfarm/RegenStreamSection.tsx index 9018fd5103..1cad77b230 100644 --- a/src/components/givfarm/GIVfrens.tsx +++ b/src/components/givfarm/RegenStreamSection.tsx @@ -3,13 +3,15 @@ import { H3 } from '@giveth/ui-design-system'; import { useWeb3React } from '@web3-react/core'; import { useIntl } from 'react-intl'; import { Col } from '../Grid'; -import { Subtitle, GIVfrensLink } from './GIVfrens.sc'; +import { Subtitle, GIVfrensLink } from './RegenStreamSection.sc'; -interface IGIVfrensProps { +interface IRegenStreamSectionProps { showArchivedPools: boolean; } -export const GIVfrens: FC = ({ showArchivedPools }) => { +export const RegenStreamSection: FC = ({ + showArchivedPools, +}) => { const { chainId } = useWeb3React(); const { formatMessage } = useIntl(); // const regenFarms = diff --git a/src/components/views/givfarm/GIVfarmBottom.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx index 3592244e35..447e87052b 100644 --- a/src/components/views/givfarm/GIVfarmBottom.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -22,7 +22,7 @@ import { ExtLinkRow } from '../../GIVeconomyPages/commons'; import { shortenAddress } from '@/lib/helpers'; import { Col, Container } from '@/components/Grid'; -import { GIVfrens } from '@/components/givfarm/GIVfrens'; +import { GIVStreamSection } from '@/components/givfarm/RegenStreamSection'; import { DaoCard } from '../../givfarm/DaoCard'; import { getNowUnixMS } from '@/helpers/time'; import { TWO_WEEK } from '@/lib/constants/constants'; @@ -176,7 +176,7 @@ export const GIVfarmBottom = () => { )} {renderPools(chainId, showArchivedPools)}
- + From 7853e2134fe9953be6d6581b3dec9e30b9e2a0a1 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 19:22:27 +0330 Subject: [PATCH 091/163] fix import --- src/components/views/givfarm/GIVfarmBottom.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/givfarm/GIVfarmBottom.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx index 447e87052b..117f55fdbd 100644 --- a/src/components/views/givfarm/GIVfarmBottom.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -22,11 +22,11 @@ import { ExtLinkRow } from '../../GIVeconomyPages/commons'; import { shortenAddress } from '@/lib/helpers'; import { Col, Container } from '@/components/Grid'; -import { GIVStreamSection } from '@/components/givfarm/RegenStreamSection'; import { DaoCard } from '../../givfarm/DaoCard'; import { getNowUnixMS } from '@/helpers/time'; import { TWO_WEEK } from '@/lib/constants/constants'; import StakingPoolCard from '../../cards/StakingCards/StakingPoolCard'; +import { RegenStreamSection } from '@/components/givfarm/RegenStreamSection'; const renderPool = ( pool: SimplePoolStakingConfig | UniswapV3PoolStakingConfig, @@ -176,7 +176,7 @@ export const GIVfarmBottom = () => { )} {renderPools(chainId, showArchivedPools)} - + From 0162334edbd92adeeaf3ae29ac10c1814bc2ed75 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 19:33:49 +0330 Subject: [PATCH 092/163] remove unused col --- src/components/views/givfarm/GIVfarmBottom.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/views/givfarm/GIVfarmBottom.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx index 117f55fdbd..e60db94855 100644 --- a/src/components/views/givfarm/GIVfarmBottom.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -177,9 +177,7 @@ export const GIVfarmBottom = () => { {renderPools(chainId, showArchivedPools)} - - - + ); From d2329f428f044e17ab0dc72e44472c7d5677af5b Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 19:34:05 +0330 Subject: [PATCH 093/163] init showing stream cards --- src/components/givfarm/RegenStreamSection.tsx | 63 ++++++++++++------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/src/components/givfarm/RegenStreamSection.tsx b/src/components/givfarm/RegenStreamSection.tsx index 1cad77b230..7b89df5d93 100644 --- a/src/components/givfarm/RegenStreamSection.tsx +++ b/src/components/givfarm/RegenStreamSection.tsx @@ -2,8 +2,10 @@ import React, { FC } from 'react'; import { H3 } from '@giveth/ui-design-system'; import { useWeb3React } from '@web3-react/core'; import { useIntl } from 'react-intl'; -import { Col } from '../Grid'; +import { Col, Row } from '../Grid'; import { Subtitle, GIVfrensLink } from './RegenStreamSection.sc'; +import config from '@/configuration'; +import { RegenStreamCard } from './RegenStreamCard'; interface IRegenStreamSectionProps { showArchivedPools: boolean; @@ -14,32 +16,47 @@ export const RegenStreamSection: FC = ({ }) => { const { chainId } = useWeb3React(); const { formatMessage } = useIntl(); - // const regenFarms = - // chainId === config.XDAI_NETWORK_NUMBER - // ? config.XDAI_CONFIG.regenFarms - // : config.MAINNET_CONFIG.regenFarms; + const regenStreams = + chainId === config.XDAI_NETWORK_NUMBER + ? [ + ...config.XDAI_CONFIG.regenStreams, + ...config.MAINNET_CONFIG.regenStreams, + ] + : [ + ...config.MAINNET_CONFIG.regenStreams, + ...config.XDAI_CONFIG.regenStreams, + ]; return ( <>

RegenStreams

- - - {formatMessage({ - id: 'label.explore_a_multiverse_of_projects', - })} -   - - {formatMessage({ id: 'label.learn_more' })} - - . - - + + + + {formatMessage({ + id: 'label.explore_a_multiverse_of_projects', + })} +   + + {formatMessage({ id: 'label.learn_more' })} + + . + + + + {regenStreams.map(regenStream => ( + + ))} {/* {regenFarms.map((regenFarm, index) => ( Date: Sun, 5 Mar 2023 19:46:50 +0330 Subject: [PATCH 094/163] remove introCard from regen stream --- src/components/givfarm/RegenStreamCard.tsx | 168 +++++++++------------ src/types/config.ts | 1 - 2 files changed, 72 insertions(+), 97 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 9fce7ace75..2ab1d90fd3 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -35,8 +35,6 @@ import { useAppSelector } from '@/features/hooks'; import config from '@/configuration'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; -import StakingCardIntro from '../cards/StakingCards/StakingCardIntro'; -import { StakeCardState } from '../cards/StakingCards/BaseStakingCard/BaseStakingCard'; interface RegenStreamProps { network: number; @@ -59,7 +57,6 @@ export const RegenStreamCard: FC = ({ streamConfig, }) => { const { formatMessage } = useIntl(); - const [state, setState] = useState(StakeCardState.NORMAL); const [showModal, setShowModal] = useState(false); const [usdAmount, setUSDAmount] = useState('0'); const [rewardLiquidPart, setRewardLiquidPart] = useState(constants.Zero); @@ -133,106 +130,85 @@ export const RegenStreamCard: FC = ({ return ( - {state === StakeCardState.NORMAL ? ( - - - - {icon} -
{streamConfig.title}
- {streamConfig.introCard && ( - - setState(StakeCardState.INTRO) - } - > - - - )} -
- - - - {formatWeiHelper(rewardStream)} - - - {streamConfig.rewardTokenSymbol} - {formatMessage({ id: 'label./week' })} - - -
-
- - -
+ + + + {icon} +
{streamConfig.title}
{' '} +
+ + + {formatWeiHelper(rewardStream)} + + {streamConfig.rewardTokenSymbol} + {formatMessage({ id: 'label./week' })} + + +
+
+ + +
+ {formatMessage( + { + id: 'label.stream_progress', + }, + { + token: streamConfig.rewardTokenSymbol, + }, + )} +
+ + } + direction={'bottom'} + > + {formatMessage( { - id: 'label.stream_progress', + id: 'label.liquid_reward_token_that_has_flowed', }, { - token: streamConfig.rewardTokenSymbol, + rewardTokenSymbol: + streamConfig.rewardTokenSymbol, }, )} -
- - } - direction={'bottom'} - > - - {formatMessage( - { - id: 'label.liquid_reward_token_that_has_flowed', - }, - { - rewardTokenSymbol: - streamConfig.rewardTokenSymbol, - }, - )} - - -
-
- - - {percentage?.toFixed(2)}% - 100% - + + + + + + + {percentage?.toFixed(2)}% + 100% + +
+ + {`${formatMessage({ id: 'label.time_remaining' })}: ` + + remainTime} + + +
+ + {getStreamIconWithType(streamConfig.type, 24)} + {formatWeiHelper(rewardLiquidPart)} + + {streamConfig.rewardTokenSymbol} + + + ~${usdAmount}
- - {`${formatMessage({ id: 'label.time_remaining' })}: ` + - remainTime} - - -
- - {getStreamIconWithType(streamConfig.type, 24)} - - {formatWeiHelper(rewardLiquidPart)} - - - {streamConfig.rewardTokenSymbol} - - - ~${usdAmount} -
- setShowModal(true)} - buttonType='primary' - disabled={rewardLiquidPart.isZero()} - size='large' - /> -
-
- ) : ( - - )} + setShowModal(true)} + buttonType='primary' + disabled={rewardLiquidPart.isZero()} + size='large' + /> + + {showModal && ( Date: Sun, 5 Mar 2023 20:01:40 +0330 Subject: [PATCH 095/163] add title --- src/components/givfarm/RegenStreamCard.tsx | 49 ++++++++++++---------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 2ab1d90fd3..97d30607da 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -129,8 +129,9 @@ export const RegenStreamCard: FC = ({ const icon = getStreamIconWithType(streamConfig.type, 40); return ( - - + + {streamConfig.title} + {icon} @@ -208,37 +209,41 @@ export const RegenStreamCard: FC = ({ size='large' /> - - {showModal && ( - - )} - + {showModal && ( + + )} +
+ ); }; -const RegenStreamContainer = styled.div` +const Wrapper = styled.div``; + +const Title = styled(H4)` + margin-bottom: 16px; +`; + +const RegenStreamContainer = styled(Flex)` height: 488px; + padding: 32px 24px; background-color: ${brandColors.giv[700]}; border-radius: 8px; position: relative; flex-direction: column; justify-content: space-between; overflow: hidden; -`; - -const RegenStreamInnerContainer = styled(Flex)` - height: 488px; - padding: 24px; flex-direction: column; - justify-content: space-between; `; const HeaderRow = styled(Flex)` From e8509bc6b984a499d88db210f57a3f03c4f9aa33 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 20:31:48 +0330 Subject: [PATCH 096/163] init new regen stream card --- src/components/givfarm/RegenStreamCard.tsx | 130 ++++++++++----------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 97d30607da..36553d00c5 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -9,8 +9,8 @@ import { H6, IconGIVStream, IconHelpFilled16, + IconInfoOutline16, Lead, - neutralColors, P, Subline, } from '@giveth/ui-design-system'; @@ -19,11 +19,7 @@ import BigNumber from 'bignumber.js'; import styled from 'styled-components'; import { useIntl } from 'react-intl'; import { durationToString } from '@/lib/helpers'; -import { - Bar, - GsPTooltip, - PercentageRow, -} from '@/components/GIVeconomyPages/GIVstream.sc'; +import { Bar, GsPTooltip } from '@/components/GIVeconomyPages/GIVstream.sc'; import { IconWithTooltip } from '@/components/IconWithToolTip'; import { RegenStreamConfig, StreamType } from '@/types/config'; import { BN, formatWeiHelper } from '@/helpers/number'; @@ -132,21 +128,25 @@ export const RegenStreamCard: FC = ({ {streamConfig.title} - - - {icon} -
{streamConfig.title}
{' '} -
- - - {formatWeiHelper(rewardStream)} - - {streamConfig.rewardTokenSymbol} - {formatMessage({ id: 'label./week' })} - - -
-
+ + + + {icon} +
+ {streamConfig.rewardTokenSymbol} Flowrate +
{' '} +
+ + + + {formatWeiHelper(rewardStream)} + + + {streamConfig.rewardTokenSymbol} + {formatMessage({ id: 'label./week' })} + + +
@@ -179,15 +179,16 @@ export const RegenStreamCard: FC = ({ - + {percentage?.toFixed(2)}% 100% - -
- - {`${formatMessage({ id: 'label.time_remaining' })}: ` + - remainTime} - + + + {`${formatMessage({ id: 'label.time_remaining' })}: ` + + remainTime} + + +
@@ -199,15 +200,24 @@ export const RegenStreamCard: FC = ({ ~${usdAmount}
- setShowModal(true)} - buttonType='primary' - disabled={rewardLiquidPart.isZero()} - size='large' - /> + + setShowModal(true)} + buttonType='primary' + disabled={rewardLiquidPart.isZero()} + size='large' + /> + + + + Use the Harvest button harvest this liquid + stream alone. + + +
{showModal && ( = ({ ); }; -const Wrapper = styled.div``; +const Wrapper = styled.div` + margin-bottom: 74px; +`; const Title = styled(H4)` margin-bottom: 16px; `; const RegenStreamContainer = styled(Flex)` - height: 488px; padding: 32px 24px; background-color: ${brandColors.giv[700]}; border-radius: 8px; position: relative; - flex-direction: column; - justify-content: space-between; + /* flex-direction: column; */ + justify-content: stretch; overflow: hidden; - flex-direction: column; + gap: 32px; `; -const HeaderRow = styled(Flex)` - margin-bottom: 24px; +const InfoContainer = styled(Flex)` + flex: 1; `; -export const IntroIcon = styled.div` - position: absolute; - top: 4px; - right: -24px; - cursor: pointer; - color: ${brandColors.deep[100]}; - transition: color 0.3s ease; - :hover { - color: ${neutralColors.gray[100]}; - } +const HeaderRow = styled(Flex)` + margin-bottom: 20px; `; const RateRow = styled(Flex)` @@ -281,16 +284,15 @@ const RegenStreamInfoRow = styled(Flex)` margin-bottom: 24px; `; -const Remaining = styled(P)` - /* margin-top: 24px; */ +const Remaining = styled(P)``; + +const Separator = styled.div` + width: 1px; + background-color: ${brandColors.giv[500]}; `; const HarvestContainer = styled(Flex)` - /* margin-top: 90px; */ - padding-top: 24px; - border-top: 1px solid ${brandColors.giv[500]}; - justify-content: space-between; - align-items: center; + flex: 1; `; const AmountInfo = styled(Flex)` @@ -312,8 +314,4 @@ const Converted = styled(Caption)` padding-left: 32px; `; -const HarvestButton = styled(Button)` - width: auto; - flex: 1; - max-width: 264px; -`; +const HarvestButton = styled(Button)``; From d0b240e9b0456f8c7cc25b2f1ae499fffcca3302 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 21:38:42 +0330 Subject: [PATCH 097/163] update harvest side styles --- src/components/givfarm/RegenStreamCard.tsx | 39 ++++++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 36553d00c5..0dff7d3b67 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -11,6 +11,7 @@ import { IconHelpFilled16, IconInfoOutline16, Lead, + mediaQueries, P, Subline, } from '@giveth/ui-design-system'; @@ -31,6 +32,7 @@ import { useAppSelector } from '@/features/hooks'; import config from '@/configuration'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; +import { Relative } from '../styled-components/Position'; interface RegenStreamProps { network: number; @@ -189,7 +191,7 @@ export const RegenStreamCard: FC = ({ - +
{getStreamIconWithType(streamConfig.type, 24)} @@ -200,7 +202,7 @@ export const RegenStreamCard: FC = ({ ~${usdAmount}
- + = ({ disabled={rewardLiquidPart.isZero()} size='large' /> - + Use the Harvest button harvest this liquid stream alone. - - + +
{showModal && ( span { + text-overflow: ellipsis; + } +`; + +const HarvestButtonDesc = styled(Flex)` + position: absolute; +`; From e3cc79650d2dc6b92fb3f0ce8811e3c4af87b572 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 21:39:59 +0330 Subject: [PATCH 098/163] add space between harvest button and desc --- src/components/givfarm/RegenStreamCard.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 0dff7d3b67..d14bd8d15f 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -327,6 +327,7 @@ const HarvestButton = styled(Button)` & > span { text-overflow: ellipsis; } + margin-bottom: 40px; `; const HarvestButtonDesc = styled(Flex)` From f93e8e6cbd0c10dac8938d79f4adc7ebfc665238 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 21:50:29 +0330 Subject: [PATCH 099/163] fix stream rate size --- src/components/givfarm/RegenStreamCard.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index d14bd8d15f..46f38b877f 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -139,7 +139,7 @@ export const RegenStreamCard: FC = ({ {' '} - + {formatWeiHelper(rewardStream)} @@ -274,15 +274,13 @@ const HeaderRow = styled(Flex)` const RateRow = styled(Flex)` gap: 8px; - align-items: flex-end; + align-items: center; overflow: hidden; `; -const StreamRate = styled(H4)` - line-height: 2.4rem; -`; +const StreamRate = styled(B)``; -const StreamRateUnit = styled(H6)` +const StreamRateUnit = styled(P)` color: ${brandColors.giv[200]}; `; From 4bd5a1f9243d7c91075816cfa7d81367a6518a1a Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 23:01:09 +0330 Subject: [PATCH 100/163] change wrap to boolean --- src/components/Footer/Footer.tsx | 2 +- src/components/GIVeconomyPages/GIVbacks.tsx | 6 +++--- src/components/GIVeconomyPages/GIVstream.tsx | 2 +- src/components/modals/HarvestAll.tsx | 2 +- src/components/styled-components/Flex.tsx | 4 ++-- src/components/views/givfarm/GIVfarmBottom.tsx | 4 ++-- src/components/views/userProfile/boostedTab/BoostsTable.tsx | 2 +- .../views/userProfile/boostedTab/GetMoreGIVpowerBanner.tsx | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/Footer/Footer.tsx b/src/components/Footer/Footer.tsx index 5f04b3745a..6951507d15 100644 --- a/src/components/Footer/Footer.tsx +++ b/src/components/Footer/Footer.tsx @@ -30,7 +30,7 @@ const Footer = () => { return ( - + diff --git a/src/components/GIVeconomyPages/GIVbacks.tsx b/src/components/GIVeconomyPages/GIVbacks.tsx index 7d67e542f7..61244c4d8f 100644 --- a/src/components/GIVeconomyPages/GIVbacks.tsx +++ b/src/components/GIVeconomyPages/GIVbacks.tsx @@ -227,7 +227,7 @@ export const TabGIVbacksBottom = () => { {' '}

@@ -251,7 +251,7 @@ export const TabGIVbacksBottom = () => {

@@ -274,7 +274,7 @@ export const TabGIVbacksBottom = () => {

diff --git a/src/components/GIVeconomyPages/GIVstream.tsx b/src/components/GIVeconomyPages/GIVstream.tsx index 36548c324c..5bfff80d78 100644 --- a/src/components/GIVeconomyPages/GIVstream.tsx +++ b/src/components/GIVeconomyPages/GIVstream.tsx @@ -194,7 +194,7 @@ export const TabGIVstreamBottom = () => {

- +

{formatMessage({ id: 'label.your_flowrate' })}:

diff --git a/src/components/modals/HarvestAll.tsx b/src/components/modals/HarvestAll.tsx index 77c5e1ccf9..48ff1b0bca 100644 --- a/src/components/modals/HarvestAll.tsx +++ b/src/components/modals/HarvestAll.tsx @@ -349,7 +349,7 @@ export const HarvestAllModal: FC = ({ regenStreamConfig?.rewardTokenSymbol } /> - + {formatMessage({ id: 'label.your_new', diff --git a/src/components/styled-components/Flex.tsx b/src/components/styled-components/Flex.tsx index 514e0dc526..90d00bb81a 100644 --- a/src/components/styled-components/Flex.tsx +++ b/src/components/styled-components/Flex.tsx @@ -1,7 +1,7 @@ import styled from 'styled-components'; interface IFlexProps { - wrap?: number; + flexWrap?: boolean; alignItems?: 'stretch' | 'center' | 'flex-start' | 'flex-end' | 'baseline'; justifyContent?: | 'flex-start' @@ -18,7 +18,7 @@ export const Flex = styled.div` display: flex; flex-direction: ${props => props.flexDirection ? props.flexDirection : 'initial'}; - flex-wrap: ${props => (props.wrap ? 'wrap' : 'nowrap')}; + flex-wrap: ${props => (props.flexWrap ? 'wrap' : 'nowrap')}; align-items: ${props => (props.alignItems ? props.alignItems : 'initial')}; justify-content: ${props => props.justifyContent ? props.justifyContent : 'initial'}; diff --git a/src/components/views/givfarm/GIVfarmBottom.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx index e60db94855..94d70af5e6 100644 --- a/src/components/views/givfarm/GIVfarmBottom.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -85,11 +85,11 @@ export const GIVfarmBottom = () => { - + = ({ return ( <> -
+
GIVpower Summary
{myAccount && ( diff --git a/src/components/views/userProfile/boostedTab/GetMoreGIVpowerBanner.tsx b/src/components/views/userProfile/boostedTab/GetMoreGIVpowerBanner.tsx index c9ae10c3b5..14a8046e1a 100644 --- a/src/components/views/userProfile/boostedTab/GetMoreGIVpowerBanner.tsx +++ b/src/components/views/userProfile/boostedTab/GetMoreGIVpowerBanner.tsx @@ -21,7 +21,7 @@ const GetMoreGIVpowerBanner = () => { Stake & lock GIV to get GIVpower to boost projects. - + From b18eaa37c78c5f9390828a95af9d0df67f73b761 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 23:02:05 +0330 Subject: [PATCH 101/163] make RegenStreamCard responsive --- src/components/givfarm/RegenStreamCard.tsx | 44 ++++++++++++++++------ 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 46f38b877f..d21e614de7 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -131,7 +131,7 @@ export const RegenStreamCard: FC = ({ {streamConfig.title} - + {icon}
@@ -191,7 +191,11 @@ export const RegenStreamCard: FC = ({ - +
{getStreamIconWithType(streamConfig.type, 24)} @@ -248,28 +252,41 @@ const Title = styled(H4)` margin-bottom: 16px; `; +const ResponsiveFlex = styled(Flex)` + flex-direction: column; + align-items: center; + ${mediaQueries.tablet} { + flex-direction: row; + } +`; + const RegenStreamContainer = styled(Flex)` padding: 32px 24px; background-color: ${brandColors.giv[700]}; border-radius: 8px; position: relative; - /* flex-direction: column; */ justify-content: stretch; overflow: hidden; gap: 32px; + flex-direction: column; + ${mediaQueries.laptopS} { + flex-direction: row; + } `; -const SideContainer = styled(Flex)` +const InfoContainer = styled(Flex)` ${mediaQueries.tablet} { width: calc(100% - 33px); overflow: hidden; } `; -const InfoContainer = styled(SideContainer)``; - -const HeaderRow = styled(Flex)` +const HeaderRow = styled(ResponsiveFlex)` margin-bottom: 20px; + ${mediaQueries.tablet} { + width: calc(100% - 33px); + overflow: hidden; + } `; const RateRow = styled(Flex)` @@ -292,11 +309,15 @@ const RegenStreamInfoRow = styled(Flex)` const Remaining = styled(P)``; const Separator = styled.div` - width: 1px; - background-color: ${brandColors.giv[500]}; + display: none; + ${mediaQueries.laptopS} { + display: block; + width: 1px; + background-color: ${brandColors.giv[500]}; + } `; -const HarvestContainer = styled(SideContainer)``; +const HarvestContainer = styled(ResponsiveFlex)``; const AmountInfo = styled(Flex)` align-items: center; @@ -325,9 +346,10 @@ const HarvestButton = styled(Button)` & > span { text-overflow: ellipsis; } - margin-bottom: 40px; + margin-bottom: 64px; `; const HarvestButtonDesc = styled(Flex)` position: absolute; + bottom: 0px; `; From ca96be632b67bf45d3e2663f79f2559f998312c6 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 23:09:19 +0330 Subject: [PATCH 102/163] make bar title center in mobile size --- src/components/GIVeconomyPages/GIVstream.sc.tsx | 1 + src/components/givfarm/RegenStreamCard.tsx | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/GIVeconomyPages/GIVstream.sc.tsx b/src/components/GIVeconomyPages/GIVstream.sc.tsx index 2b8e029b62..5ff764f181 100644 --- a/src/components/GIVeconomyPages/GIVstream.sc.tsx +++ b/src/components/GIVeconomyPages/GIVstream.sc.tsx @@ -105,6 +105,7 @@ interface IBarProps { } export const Bar = styled.div` height: 12px; + width: 100%; background: ${brandColors.giv[800]}; border-radius: 12px; diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index d21e614de7..19f6deddf5 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -181,10 +181,10 @@ export const RegenStreamCard: FC = ({ - + {percentage?.toFixed(2)}% 100% - + {`${formatMessage({ id: 'label.time_remaining' })}: ` + remainTime} @@ -275,9 +275,11 @@ const RegenStreamContainer = styled(Flex)` `; const InfoContainer = styled(Flex)` + align-items: center; ${mediaQueries.tablet} { width: calc(100% - 33px); overflow: hidden; + align-items: unset; } `; @@ -289,6 +291,10 @@ const HeaderRow = styled(ResponsiveFlex)` } `; +const PercentageRow = styled(Flex)` + width: 100%; +`; + const RateRow = styled(Flex)` gap: 8px; align-items: center; From 000cdddd30f25379b4744351a6e4831bd2c62ebb Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 23:13:08 +0330 Subject: [PATCH 103/163] fix width of HarvestContainer --- src/components/givfarm/RegenStreamCard.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 19f6deddf5..4e6f3d5322 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -285,10 +285,6 @@ const InfoContainer = styled(Flex)` const HeaderRow = styled(ResponsiveFlex)` margin-bottom: 20px; - ${mediaQueries.tablet} { - width: calc(100% - 33px); - overflow: hidden; - } `; const PercentageRow = styled(Flex)` @@ -309,7 +305,6 @@ const StreamRateUnit = styled(P)` const RegenStreamInfoRow = styled(Flex)` justify-content: space-between; - margin-bottom: 24px; `; const Remaining = styled(P)``; @@ -323,7 +318,12 @@ const Separator = styled.div` } `; -const HarvestContainer = styled(ResponsiveFlex)``; +const HarvestContainer = styled(ResponsiveFlex)` + ${mediaQueries.tablet} { + width: calc(100% - 33px); + overflow: hidden; + } +`; const AmountInfo = styled(Flex)` align-items: center; From 25de1e1c805f5bcec6d423ee1da137fec49b7945 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 23:16:51 +0330 Subject: [PATCH 104/163] fix align --- src/components/givfarm/RegenStreamCard.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 4e6f3d5322..202b113899 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -256,6 +256,7 @@ const ResponsiveFlex = styled(Flex)` flex-direction: column; align-items: center; ${mediaQueries.tablet} { + align-items: unset; flex-direction: row; } `; From 83620a94e335ed5c451cee76b7950b7f45c81516 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 23:24:42 +0330 Subject: [PATCH 105/163] remove transform for mobile size --- src/components/Tooltip.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/Tooltip.tsx b/src/components/Tooltip.tsx index 006b8c478b..80d06e1872 100644 --- a/src/components/Tooltip.tsx +++ b/src/components/Tooltip.tsx @@ -126,14 +126,12 @@ const tooltipStyleCalc = ( style = { top: parentRect.top - ARROW_SIZE - 50, left: 10, - transform: `translate(${translateX}, -100%)`, width: '95vw', }; } else if (isMobile && direction === 'bottom') { style = { top: parentRect.bottom + ARROW_SIZE, left: 10, - transform: `translate(${translateX}, 0)`, width: '95vw', }; } else { From 6cc257aac64f0e49c2ee73d0f9cb5bc3981d3d40 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 23:32:59 +0330 Subject: [PATCH 106/163] fix tooltip width --- src/components/GIVeconomyPages/GIVstream.sc.tsx | 4 +++- src/components/modals/HarvestAll.sc.tsx | 4 +++- src/components/modals/StakeLock/LockInfo.tsx | 5 ++++- src/components/views/claim/cards/Donate.tsx | 5 ++++- src/components/views/donate/DonateToGiveth.tsx | 5 ++++- .../views/project/projectDonateCard/ProjectDonateCard.tsx | 4 +++- src/components/views/userProfile/boostedTab/BoostsTable.tsx | 5 ++++- 7 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/components/GIVeconomyPages/GIVstream.sc.tsx b/src/components/GIVeconomyPages/GIVstream.sc.tsx index 5ff764f181..2e9166f151 100644 --- a/src/components/GIVeconomyPages/GIVstream.sc.tsx +++ b/src/components/GIVeconomyPages/GIVstream.sc.tsx @@ -77,7 +77,9 @@ export const FlowRateRow = styled(Flex)` export const FlowRateTooltip = styled(Subline)` color: ${neutralColors.gray[100]}; - width: 260px; + ${mediaQueries.tablet} { + width: 260px; + } `; export const FlowRateUnit = styled(H4)` diff --git a/src/components/modals/HarvestAll.sc.tsx b/src/components/modals/HarvestAll.sc.tsx index 83e03a935f..6e2f02d427 100644 --- a/src/components/modals/HarvestAll.sc.tsx +++ b/src/components/modals/HarvestAll.sc.tsx @@ -88,7 +88,9 @@ export const HarvestAllPending = styled(Pending)` `; export const TooltipContent = styled(Subline)` - width: 200px; + ${mediaQueries.tablet} { + width: 200px; + } `; export const HarvestBoxes = styled.div` diff --git a/src/components/modals/StakeLock/LockInfo.tsx b/src/components/modals/StakeLock/LockInfo.tsx index 05f5685929..e49ec90a51 100644 --- a/src/components/modals/StakeLock/LockInfo.tsx +++ b/src/components/modals/StakeLock/LockInfo.tsx @@ -6,6 +6,7 @@ import { H6, IconHelpFilled16, IconSpark, + mediaQueries, neutralColors, Subline, } from '@giveth/ui-design-system'; @@ -159,7 +160,9 @@ const LockInfoRowSpark = styled.div` export const LockInfoTooltip = styled(Subline)` color: ${neutralColors.gray[100]}; - width: 160px; + ${mediaQueries.tablet} { + width: 160px; + } `; export default LockInfo; diff --git a/src/components/views/claim/cards/Donate.tsx b/src/components/views/claim/cards/Donate.tsx index fc55b208b6..92a517a19c 100644 --- a/src/components/views/claim/cards/Donate.tsx +++ b/src/components/views/claim/cards/Donate.tsx @@ -9,6 +9,7 @@ import { H5, Lead, IconHelpFilled16, + mediaQueries, } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; @@ -73,7 +74,9 @@ const DonateCardContainer = styled(Card)` const GdropDonateTooltip = styled(Subline)` color: ${neutralColors.gray[100]}; - width: 260px; + ${mediaQueries.tablet} { + width: 260px; + } `; const DonateHeader = styled.div` diff --git a/src/components/views/donate/DonateToGiveth.tsx b/src/components/views/donate/DonateToGiveth.tsx index c0191933b2..db4104d92d 100644 --- a/src/components/views/donate/DonateToGiveth.tsx +++ b/src/components/views/donate/DonateToGiveth.tsx @@ -3,6 +3,7 @@ import { Caption, GLink, IconHelpFilled16, + mediaQueries, neutralColors, Subline, } from '@giveth/ui-design-system'; @@ -85,7 +86,9 @@ const DonateToGiveth: FC = props => { }; const TooltipContainer = styled(Subline)` - width: 274px; + ${mediaQueries.tablet} { + width: 274px; + } padding: 0 10px; `; diff --git a/src/components/views/project/projectDonateCard/ProjectDonateCard.tsx b/src/components/views/project/projectDonateCard/ProjectDonateCard.tsx index 216d166a7a..8de3b46975 100644 --- a/src/components/views/project/projectDonateCard/ProjectDonateCard.tsx +++ b/src/components/views/project/projectDonateCard/ProjectDonateCard.tsx @@ -640,7 +640,9 @@ const ArchiveButton = styled(Button)` export const BoostTooltip = styled(Subline)` color: ${neutralColors.gray[100]}; - width: 260px; + ${mediaQueries.tablet} { + width: 260px; + } `; export default ProjectDonateCard; diff --git a/src/components/views/userProfile/boostedTab/BoostsTable.tsx b/src/components/views/userProfile/boostedTab/BoostsTable.tsx index c56f539318..302c1342cb 100644 --- a/src/components/views/userProfile/boostedTab/BoostsTable.tsx +++ b/src/components/views/userProfile/boostedTab/BoostsTable.tsx @@ -35,6 +35,7 @@ import { DeletePowerBoostModal } from '@/components/modals/Boost/DeletePowerBoos import { slugToProjectView } from '@/lib/routeCreators'; import { ApprovePowerBoostModal } from '@/components/modals/Boost/ApprovePowerBoostModal'; import { IconWithTooltip } from '@/components/IconWithToolTip'; +import { mediaQueries } from '@/lib/constants/constants'; interface IBoostsTable { boosts: IPowerBoosting[]; @@ -515,7 +516,9 @@ const Percentage = styled(InputSuffix)` const BoostTooltip = styled(Subline)` color: ${neutralColors.gray[100]}; - width: 240px; + ${mediaQueries.tablet} { + width: 240px; + } `; export default BoostsTable; From 7006691145d220d5c3c7c6dfc58d191f68494ad6 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 5 Mar 2023 23:35:52 +0330 Subject: [PATCH 107/163] fix build issues --- src/features/price/price.thunks.ts | 8 ++++---- src/lib/stakingPool.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/features/price/price.thunks.ts b/src/features/price/price.thunks.ts index 6ae9520227..ccac546f8f 100644 --- a/src/features/price/price.thunks.ts +++ b/src/features/price/price.thunks.ts @@ -23,14 +23,14 @@ export const fetchMainnetThirdPartyTokensPriceAsync = createAsyncThunk( 'price/fetchMainnetThirdPartyTokensPrice', async () => { const promises: Promise[] = []; - config.MAINNET_CONFIG.regenFarms.forEach(streamConfig => { + config.MAINNET_CONFIG.regenStreams.forEach(streamConfig => { const tokenAddress = streamConfig.tokenAddressOnUniswapV2.toLowerCase(); promises.push(fetchMainnetTokenPrice(tokenAddress)); }); return Promise.all(promises).then(prices => { let res: { [x: string]: string } = {}; - config.MAINNET_CONFIG.regenFarms.forEach((streamConfig, idx) => { + config.MAINNET_CONFIG.regenStreams.forEach((streamConfig, idx) => { const tokenAddress = streamConfig.tokenAddressOnUniswapV2.toLowerCase(); res[tokenAddress] = prices[idx]; @@ -44,14 +44,14 @@ export const fetchGnosisThirdPartyTokensPriceAsync = createAsyncThunk( 'price/fetchGnosisThirdPartyTokensPric', async () => { const promises: Promise[] = []; - config.XDAI_CONFIG.regenFarms.forEach(streamConfig => { + config.XDAI_CONFIG.regenStreams.forEach(streamConfig => { const tokenAddress = streamConfig.tokenAddressOnUniswapV2.toLowerCase(); promises.push(fetchGnosisTokenPrice(tokenAddress)); }); return Promise.all(promises).then(prices => { let res: { [x: string]: string } = {}; - config.XDAI_CONFIG.regenFarms.forEach((streamConfig, idx) => { + config.XDAI_CONFIG.regenStreams.forEach((streamConfig, idx) => { const tokenAddress = streamConfig.tokenAddressOnUniswapV2.toLowerCase(); res[tokenAddress] = prices[idx]; diff --git a/src/lib/stakingPool.ts b/src/lib/stakingPool.ts index a06bd6a2d7..58e8cdbad9 100644 --- a/src/lib/stakingPool.ts +++ b/src/lib/stakingPool.ts @@ -271,7 +271,7 @@ const getSimplePoolStakingAPR = async ( const { regenStreamType } = poolStakingConfig as RegenPoolStakingConfig; const streamConfig = regenStreamType && - config.NETWORKS_CONFIG[network].regenFarms.find( + config.NETWORKS_CONFIG[network].regenStreams.find( s => s.type === regenStreamType, ); const tokenAddress = streamConfig From fbda5b521a4229057948dbc354f4ac3d7ffcb789 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 11:05:01 +0330 Subject: [PATCH 108/163] remove RegenFarm component --- src/components/RegenFarm.tsx | 93 ------------------------------------ 1 file changed, 93 deletions(-) delete mode 100644 src/components/RegenFarm.tsx diff --git a/src/components/RegenFarm.tsx b/src/components/RegenFarm.tsx deleted file mode 100644 index 8dedaef439..0000000000 --- a/src/components/RegenFarm.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import React, { FC } from 'react'; -import { useWeb3React } from '@web3-react/core'; -import { H4 } from '@giveth/ui-design-system'; -import styled from 'styled-components'; -import { givEconomySupportedNetworks } from '@/lib/constants/constants'; -import { Row, Col } from './Grid'; -import { PoolRow } from './GIVeconomyPages/GIVfarm.sc'; -import config from '@/configuration'; -import { DAOChangeNetworkModal } from './DAOChangeNetworkModal'; -import { - DAOContainer, - DAOChangeNetwork, -} from './givfarm/RegenStreamSection.sc'; -import { RegenStreamCard } from './givfarm/RegenStreamCard'; -import { getNowUnixMS } from '@/helpers/time'; -import { RegenStreamConfig } from '@/types/config'; - -interface IRegenFarmProps { - regenFarm: RegenStreamConfig; - showArchivedPools: boolean; -} - -export const RegenFarm: FC = ({ - regenFarm, - showArchivedPools, -}) => { - const { chainId } = useWeb3React(); - // const { pools } = regenFarm; - - const now = getNowUnixMS(); - - // const filteredPools = showArchivedPools - // ? pools - // : pools.filter( - // pool => - // !( - // pool.farmEndTimeMS && - // now > pool.farmEndTimeMS + TWO_WEEK - // ) || pool.dontArchive, - // ); - - // if (filteredPools.length === 0) return null; - - return ( - - - {regenFarm.title} - - {/* {filteredPools.map((poolStakingConfig, idx) => ( - - - - ))} */} - - {regenFarm && ( - - )} - - - {chainId !== config.MAINNET_NETWORK_NUMBER && - chainId !== config.XDAI_NETWORK_NUMBER && ( - <> - - - - )} - - - ); -}; - -const DaoTitle = styled(H4)` - margin-top: 32px; - margin-bottom: 24px; -`; From 2397a665ff8e30d8359552ed0a8fee6b2f9362b2 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 11:05:11 +0330 Subject: [PATCH 109/163] remove comment --- src/components/givfarm/RegenStreamSection.tsx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/components/givfarm/RegenStreamSection.tsx b/src/components/givfarm/RegenStreamSection.tsx index 7b89df5d93..869c1bc626 100644 --- a/src/components/givfarm/RegenStreamSection.tsx +++ b/src/components/givfarm/RegenStreamSection.tsx @@ -57,13 +57,6 @@ export const RegenStreamSection: FC = ({ network={chainId || 1} /> ))} - {/* {regenFarms.map((regenFarm, index) => ( - - ))} */} ); }; From 67f27b696a324fe97c95824465aa5bba5768298e Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 11:17:36 +0330 Subject: [PATCH 110/163] remove passing network to inner modals --- src/components/modals/ConfirmSubmit.tsx | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/modals/ConfirmSubmit.tsx b/src/components/modals/ConfirmSubmit.tsx index c451ce848d..64bfb168b6 100644 --- a/src/components/modals/ConfirmSubmit.tsx +++ b/src/components/modals/ConfirmSubmit.tsx @@ -26,7 +26,6 @@ const AddTokenRow = styled(Flex)` interface IConfirmSubmitProps { title: string; - walletNetwork: number; txHash?: string; rewardTokenSymbol?: string; rewardTokenAddress?: string; @@ -34,12 +33,11 @@ interface IConfirmSubmitProps { export const SubmittedInnerModal: FC = ({ title, - walletNetwork, txHash, rewardTokenSymbol, rewardTokenAddress, }) => { - const { library } = useWeb3React(); + const { chainId, library } = useWeb3React(); return ( <> {title} @@ -55,13 +53,15 @@ export const SubmittedInnerModal: FC = ({ {txHash && ( View on{' '} - {config.NETWORKS_CONFIG[walletNetwork]?.blockExplorerName} + {config.NETWORKS_CONFIG[chainId!]?.blockExplorerName}   @@ -72,13 +72,11 @@ export const SubmittedInnerModal: FC = ({ export const ConfirmedInnerModal: FC = ({ title, - walletNetwork, txHash, rewardTokenSymbol, rewardTokenAddress, }) => { - const { library } = useWeb3React(); - + const { chainId, library } = useWeb3React(); return ( <> {title} @@ -98,13 +96,12 @@ export const ConfirmedInnerModal: FC = ({ - View on{' '} - {config.NETWORKS_CONFIG[walletNetwork]?.blockExplorerName} + View on {config.NETWORKS_CONFIG[chainId!]?.blockExplorerName}   @@ -118,10 +115,11 @@ interface IErrorProps extends IConfirmSubmitProps { export const ErrorInnerModal: FC = ({ title, - walletNetwork, txHash, message, }) => { + const { chainId } = useWeb3React(); + return ( <> {title} @@ -135,13 +133,15 @@ export const ErrorInnerModal: FC = ({ {txHash && ( View on{' '} - {config.NETWORKS_CONFIG[walletNetwork]?.blockExplorerName} + {config.NETWORKS_CONFIG[chainId!]?.blockExplorerName}   From 5c6c2c289a9dcf58f7e0ce2ecd7836cc379ef664 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 11:18:02 +0330 Subject: [PATCH 111/163] remove passing network to harvest modal --- src/components/modals/HarvestAll.tsx | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/components/modals/HarvestAll.tsx b/src/components/modals/HarvestAll.tsx index 48ff1b0bca..6597c994b7 100644 --- a/src/components/modals/HarvestAll.tsx +++ b/src/components/modals/HarvestAll.tsx @@ -80,7 +80,6 @@ import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; interface IHarvestAllInnerModalProps { title: string; poolStakingConfig?: PoolStakingConfig; - network: number; regenStreamConfig?: RegenStreamConfig; regenStreamType?: StreamType; stakedPositions?: LiquidityPosition[]; @@ -89,17 +88,7 @@ interface IHarvestAllInnerModalProps { }; } -interface IHarvestAllModalProps extends IModal, IHarvestAllInnerModalProps { - title: string; - poolStakingConfig?: PoolStakingConfig; - network: number; - regenStreamConfig?: RegenStreamConfig; - regenStreamType?: StreamType; - stakedPositions?: LiquidityPosition[]; - currentIncentive?: { - key?: (string | number)[] | null | undefined; - }; -} +interface IHarvestAllModalProps extends IModal, IHarvestAllInnerModalProps {} enum HarvestStates { HARVEST, @@ -113,7 +102,6 @@ export const HarvestAllModal: FC = ({ title, setShowModal, poolStakingConfig, - network, regenStreamConfig, regenStreamType, stakedPositions, @@ -145,8 +133,9 @@ export const HarvestAllModal: FC = ({ const [sumStream, setSumStream] = useState(Zero); const { isAnimating, closeModal } = useModalAnimation(setShowModal); + const { chainId } = useWeb3React(); const { tokenDistroHelper, sdh } = useTokenDistroHelper( - network, + chainId!, regenStreamType, regenStreamConfig, ); @@ -165,14 +154,14 @@ export const HarvestAllModal: FC = ({ const tokenPrice = useMemo(() => { const currentPrice = - network === config.MAINNET_NETWORK_NUMBER + chainId === config.MAINNET_NETWORK_NUMBER ? mainnetThirdPartyTokensPrice : xDaiThirdPartyTokensPrice; const price = regenStreamConfig ? currentPrice[regenStreamConfig.tokenAddressOnUniswapV2] : givPrice; return new BigNumber(price); - }, [givPrice, network, regenStreamConfig]); + }, [givPrice, chainId, regenStreamConfig]); useEffect(() => { if (!tokenDistroHelper) return; @@ -202,7 +191,7 @@ export const HarvestAllModal: FC = ({ if (!tokenDistroHelper) return; if ( !regenStreamConfig && - network === config.XDAI_NETWORK_NUMBER && + chainId === config.XDAI_NETWORK_NUMBER && !tokenDistroBalance.givDropClaimed && account ) { @@ -218,7 +207,7 @@ export const HarvestAllModal: FC = ({ } }, [ account, - network, + chainId, tokenDistroBalance?.givDropClaimed, tokenDistroHelper, regenStreamConfig, @@ -596,7 +585,6 @@ export const HarvestAllModal: FC = ({ {state === HarvestStates.SUBMITTED && ( = ({ {state === HarvestStates.CONFIRMED && ( = ({ title={formatMessage({ id: 'label.something_went_wrong', })} - walletNetwork={network} txHash={txHash} /> )} From 60e164723a08f731397e3a9b7d4fafc6caf01689 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 11:18:57 +0330 Subject: [PATCH 112/163] remove passing network --- src/components/GIVeconomyPages/GIVbacks.tsx | 1 - src/components/GIVeconomyPages/GIVgarden.tsx | 1 - src/components/GIVeconomyPages/GIVstream.tsx | 1 - src/components/givfarm/RegenStreamCard.tsx | 13 +++++-------- src/components/givfarm/RegenStreamSection.tsx | 1 - 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/components/GIVeconomyPages/GIVbacks.tsx b/src/components/GIVeconomyPages/GIVbacks.tsx index 61244c4d8f..13cc104b4a 100644 --- a/src/components/GIVeconomyPages/GIVbacks.tsx +++ b/src/components/GIVeconomyPages/GIVbacks.tsx @@ -123,7 +123,6 @@ export const TabGIVbacksTop = () => { )} {showGivBackExplain && ( diff --git a/src/components/GIVeconomyPages/GIVgarden.tsx b/src/components/GIVeconomyPages/GIVgarden.tsx index 48aa7141fc..2f6aa9b690 100644 --- a/src/components/GIVeconomyPages/GIVgarden.tsx +++ b/src/components/GIVeconomyPages/GIVgarden.tsx @@ -95,7 +95,6 @@ export const TabGardenTop = () => { title={formatMessage({ id: 'label.givgarden_rewards' })} setShowModal={setShowModal} poolStakingConfig={poolStakingConfig} - network={config.XDAI_NETWORK_NUMBER} /> )} diff --git a/src/components/GIVeconomyPages/GIVstream.tsx b/src/components/GIVeconomyPages/GIVstream.tsx index 5bfff80d78..0630c129e4 100644 --- a/src/components/GIVeconomyPages/GIVstream.tsx +++ b/src/components/GIVeconomyPages/GIVstream.tsx @@ -145,7 +145,6 @@ export const TabGIVstreamTop = () => { )} diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 202b113899..b4ca36d2a8 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -19,6 +19,7 @@ import { constants, BigNumber as EthBignumber } from 'ethers'; import BigNumber from 'bignumber.js'; import styled from 'styled-components'; import { useIntl } from 'react-intl'; +import { useWeb3React } from '@web3-react/core'; import { durationToString } from '@/lib/helpers'; import { Bar, GsPTooltip } from '@/components/GIVeconomyPages/GIVstream.sc'; import { IconWithTooltip } from '@/components/IconWithToolTip'; @@ -35,7 +36,6 @@ import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; import { Relative } from '../styled-components/Position'; interface RegenStreamProps { - network: number; streamConfig: RegenStreamConfig; } @@ -50,10 +50,7 @@ export const getStreamIconWithType = (type: StreamType, size?: number) => { } }; -export const RegenStreamCard: FC = ({ - network, - streamConfig, -}) => { +export const RegenStreamCard: FC = ({ streamConfig }) => { const { formatMessage } = useIntl(); const [showModal, setShowModal] = useState(false); const [usdAmount, setUSDAmount] = useState('0'); @@ -65,6 +62,7 @@ export const RegenStreamCard: FC = ({ const [claimedAmount, setClaimedAmount] = useState( constants.Zero, ); + const { chainId } = useWeb3React(); const currentValues = useAppSelector( state => state.subgraph.currentValues, @@ -86,7 +84,7 @@ export const RegenStreamCard: FC = ({ useEffect(() => { const currentPrice = - network === config.MAINNET_NETWORK_NUMBER + chainId === config.MAINNET_NETWORK_NUMBER ? mainnetThirdPartyTokensPrice : xDaiThirdPartyTokensPrice; const price = new BigNumber( @@ -101,7 +99,7 @@ export const RegenStreamCard: FC = ({ setUSDAmount(usd); }, [ rewardLiquidPart, - network, + chainId, streamConfig.tokenAddressOnUniswapV2, mainnetThirdPartyTokensPrice, xDaiThirdPartyTokensPrice, @@ -235,7 +233,6 @@ export const RegenStreamCard: FC = ({ }, )} setShowModal={setShowModal} - network={network} regenStreamConfig={streamConfig} /> )} diff --git a/src/components/givfarm/RegenStreamSection.tsx b/src/components/givfarm/RegenStreamSection.tsx index 869c1bc626..9c53e2e597 100644 --- a/src/components/givfarm/RegenStreamSection.tsx +++ b/src/components/givfarm/RegenStreamSection.tsx @@ -54,7 +54,6 @@ export const RegenStreamSection: FC = ({ ))} From 0ea0ab0164ce8182a398373ad9251545e466d950 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 11:27:46 +0330 Subject: [PATCH 113/163] remove passing network --- .../StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index 4e29b8d2bc..49fb3c8efc 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -499,7 +499,6 @@ export const StakingPoolInfoAndActions: FC = ({ title={formatMessage({ id: 'label.givfarm_rewards' })} setShowModal={setShowHarvestModal} poolStakingConfig={poolStakingConfig} - network={chainId} regenStreamConfig={regenStreamConfig} stakedPositions={stakedPositions} currentIncentive={currentIncentive} From ae361ffea3a66f2b07a562634c1267d904e97634 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 11:32:11 +0330 Subject: [PATCH 114/163] fix build issues --- src/components/modals/ClaimModal.tsx | 4 ---- src/components/modals/GIVdropHarvestModal.tsx | 13 ++----------- src/components/modals/StakeLock/Stake.tsx | 3 --- src/components/modals/StakeLock/StakeGIV.tsx | 1 - src/components/modals/Unstake/UnStake.tsx | 4 ---- src/components/modals/V3Stake.tsx | 4 ---- 6 files changed, 2 insertions(+), 27 deletions(-) diff --git a/src/components/modals/ClaimModal.tsx b/src/components/modals/ClaimModal.tsx index c34a054733..20ebcfa7d2 100644 --- a/src/components/modals/ClaimModal.tsx +++ b/src/components/modals/ClaimModal.tsx @@ -35,28 +35,24 @@ export const ClaimModal: FC = ({ {claimState === ClaimState.WAITING && ( )} {claimState === ClaimState.SUBMITTING && ( )} {claimState === ClaimState.CLAIMED && ( )} {claimState === ClaimState.ERROR && ( )} diff --git a/src/components/modals/GIVdropHarvestModal.tsx b/src/components/modals/GIVdropHarvestModal.tsx index 874f85c144..5d180bd13b 100644 --- a/src/components/modals/GIVdropHarvestModal.tsx +++ b/src/components/modals/GIVdropHarvestModal.tsx @@ -349,24 +349,15 @@ export const GIVdropHarvestModal: FC = ({ )} {claimState === ClaimState.SUBMITTING && ( - + )} {claimState === ClaimState.CLAIMED && ( - + )} {claimState === ClaimState.ERROR && ( <> diff --git a/src/components/modals/StakeLock/Stake.tsx b/src/components/modals/StakeLock/Stake.tsx index 37267f08fb..aff559d1cb 100644 --- a/src/components/modals/StakeLock/Stake.tsx +++ b/src/components/modals/StakeLock/Stake.tsx @@ -285,7 +285,6 @@ const StakeInnerModal: FC = ({ {chainId && stakeState === StakeState.CONFIRMING && ( = ({ {chainId && stakeState === StakeState.CONFIRMED && ( = ({ {chainId && stakeState === StakeState.ERROR && ( = ({ {chainId && stakeState === StakeState.ERROR && ( )} diff --git a/src/components/modals/Unstake/UnStake.tsx b/src/components/modals/Unstake/UnStake.tsx index 1a8656dabe..e747cfde3c 100644 --- a/src/components/modals/Unstake/UnStake.tsx +++ b/src/components/modals/Unstake/UnStake.tsx @@ -185,14 +185,12 @@ const UnStakeInnerModal: FC = ({ {chainId && unStakeState === StakeState.REJECT && ( )} {chainId && unStakeState === StakeState.SUBMITTING && ( = ({ {chainId && unStakeState === StakeState.CONFIRMED && ( = ({ {chainId && unStakeState === StakeState.ERROR && ( = ({ {chainId && stakeStatus === StakeState.REJECT && ( )} {chainId && stakeStatus === StakeState.SUBMITTING && ( )} {chainId && stakeStatus === StakeState.CONFIRMED && ( )} {chainId && stakeStatus === StakeState.ERROR && ( )} From f8f0524cd102435746c80de31228c9f31d6d2eaa Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 11:42:17 +0330 Subject: [PATCH 115/163] add network to streams config --- src/config/development.ts | 63 ++------------------------------------- src/config/production.ts | 2 ++ src/types/config.ts | 1 + 3 files changed, 5 insertions(+), 61 deletions(-) diff --git a/src/config/development.ts b/src/config/development.ts index 27243bf9b2..eaac4766c9 100644 --- a/src/config/development.ts +++ b/src/config/development.ts @@ -88,71 +88,11 @@ const config: EnvConfig = { 'https://goerli.balancer.fi/#/pool/0xf8cba1c22b6515982bf43e71b7e8b546a3323ea80002000000000000000000df', unit: 'LP', }, - // { - // // TODO: GOERLI - // POOL_ADDRESS: '0xA0D500fd3479CBCb64a2238082b7a1Df9f87d98D', - // LM_ADDRESS: '0x7CD371D230338C74563A9A23AF72dd009a7D1b1C', - // type: StakingType.ICHI_GIV_ONEGIV, - // platform: StakingPlatform.ICHI, - // ichiApi: 'https://api.ichi.org/v1/farms/20009', - // platformTitle: 'Angel Vault', - // title: 'oneGIV / GIV', - // description: 'Angel Vault', - // provideLiquidityLink: - // 'https://3ea0967f.appichiorg.pages.dev/vault/?poolId=5004&back=vault', - // unit: 'LP', - // active: true, - // farmStartTimeMS: 1659366000000, - // introCard: { - // icon: 'angelVault', - // title: 'Angel Vault', - // description: `The Angel Vault is shared Univ3 position structured to protect GIV from downward volatility.\n\nProvide oneGIV as liquidity in our Angel Vault and stake the LP token to earn rewards proportional to the liquidity provided. When you remove liquidity, you will get oneGIV & GIV proportional to the holdings in the Angel Vault.`, - // link: 'https://docs.ichi.org/ichi-docs-v3/ichi-vaults/angel-vaults', - // }, - // }, ], regenPools: [], uniswapV2Subgraph: 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2', - regenStreams: [ - // // TODO: GOERLI - // { - // tokenDistroAddress: - // '0xBb974e08774544a361BCF496fE61DaB9Df29AFFc', - // type: StreamType.CULT, - // title: 'CULT DAO', - // rewardTokenAddress: - // '0x3e4d3FadEE2338D420bb5E5cB26aAd96c165476c', - // rewardTokenSymbol: 'CULT', - // tokenAddressOnUniswapV2: - // '0xf0f9d895aca5c8678f706fb8216fa22957685a13', - // pools: [ - // // TODO: GOERLI - // { - // network: MAINNET_NETWORK_NUMBER, - // POOL_ADDRESS: - // '0x6bb32725aa31b1a99e7c782e0605b0fb57e4b9e6', - // LM_ADDRESS: - // '0x9d23d449af3e2c07a286688c85ff5d3d4c219d79', - // type: StakingType.UNISWAPV2_CULT_ETH, - // platform: StakingPlatform.UNISWAP, - // title: 'CULT / ETH', - // description: '50% CULT, 50% ETH', - // provideLiquidityLink: - // 'https://app.uniswap.org/#/add/v2/0x3e4d3FadEE2338D420bb5E5cB26aAd96c165476c/ETH?chain=kovan', - // unit: 'LP', - // regenStreamType: StreamType.CULT, - // introCard: { - // title: 'CULT', - // description: `The purpose of CULT is to empower those building and contributing to our decentralized future. Our society makes it as difficult as possible to break away from societal, economic and other norms, and CULT serves to fund and support those who are working to take back our future. CULT is a reminder that the power in people is stronger than the people in power.\n\n CULT is the governance token of the Cult DAO. Every transaction of the CULT token allows you to contribute & fast-forward economic & societal change by contributing a 0.4% tax to the treasury. Fight from within until you get out, or change the system in doing so.`, - // link: 'https://cultdao.io/', - // }, - // farmStartTimeMS: 1646306818206, - // active: true, - // }, - // ], - // }, - ], + regenStreams: [], }, XDAI_CONFIG: { @@ -282,6 +222,7 @@ const config: EnvConfig = { regenStreams: [ { + network: XDAI_NETWORK_NUMBER, tokenDistroAddress: '0xCA29ec6F4218E230294993E0d77d5ece5a6573D8', type: StreamType.FOX, diff --git a/src/config/production.ts b/src/config/production.ts index d29ab5dfd9..58c0ca7b85 100644 --- a/src/config/production.ts +++ b/src/config/production.ts @@ -188,6 +188,7 @@ const config: EnvConfig = { 'https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v2', regenStreams: [ { + network: MAINNET_NETWORK_NUMBER, tokenDistroAddress: '0x73f2D115C2cBAa3b5F477A78F7A7CD348D8b70a2', type: StreamType.CULT, @@ -327,6 +328,7 @@ const config: EnvConfig = { regenStreams: [ { + network: XDAI_NETWORK_NUMBER, tokenDistroAddress: '0xA9a37a14E562D0E1d335B4714E3455483ede7A9a', type: StreamType.FOX, diff --git a/src/types/config.ts b/src/types/config.ts index 279bbde5c0..6bd1539255 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -96,6 +96,7 @@ export interface GasPreference { } export interface RegenStreamConfig { + network: number; title: string; tokenDistroAddress: string; type: StreamType; From a854c3bdec1157c23658996a87e5f5945ec66b8f Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 11:56:53 +0330 Subject: [PATCH 116/163] separate WrongNetworkCover --- src/components/WrongNetworkCover.tsx | 57 +++++++++++++++++++ .../BaseStakingCard/BaseStakingCard.sc.tsx | 16 ------ .../BaseStakingCard/BaseStakingCard.tsx | 21 +------ 3 files changed, 59 insertions(+), 35 deletions(-) create mode 100644 src/components/WrongNetworkCover.tsx diff --git a/src/components/WrongNetworkCover.tsx b/src/components/WrongNetworkCover.tsx new file mode 100644 index 0000000000..9385b6a99c --- /dev/null +++ b/src/components/WrongNetworkCover.tsx @@ -0,0 +1,57 @@ +import { FC } from 'react'; +import { + IconAlertCircle32, + Caption, + brandColors, +} from '@giveth/ui-design-system'; +import { useWeb3React } from '@web3-react/core'; +import { useIntl } from 'react-intl'; +import styled from 'styled-components'; +import { chainName } from '@/lib/constants/constants'; +import { Flex } from './styled-components/Flex'; + +interface IWrongNetworkCoverProps { + poolNetwork: number; +} + +export const WrongNetworkCover: FC = ({ + poolNetwork, +}) => { + const { formatMessage } = useIntl(); + const { chainId } = useWeb3React(); + + return poolNetwork !== chainId ? ( + + + + {formatMessage({ + id: 'label.you_are_currently_connected_to', + })}{' '} + {chainName(chainId || 0)}{' '} + {formatMessage({ id: 'label.switch_to' })}{' '} + {chainName(poolNetwork || 0)}{' '} + {formatMessage({ + id: 'label.to_interact_with_this_farm', + })} + + + ) : null; +}; + +const WrongNetworkContainer = styled(Flex)` + position: absolute; + width: 100%; + height: 100%; + top: 0; + bottom: 0; + left: 0; + right: 0; + padding: 24px; + flex-direction: row; + align-items: center; + background: ${brandColors.giv[900]}dd; + z-index: 2; + div { + padding: 0 0 0 17px; + } +`; diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx index 68e12eb454..370f0f7c54 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.sc.tsx @@ -157,22 +157,6 @@ export const LockInfoTooltip = styled(Subline)` width: 180px; `; -export const WrongNetworkContainer = styled(Flex)` - flex-direction: row; - position: absolute; - bottom: 0; - width: 100%; - height: 257px; - padding: 0 20px; - align-items: center; - background: linear-gradient(180deg, transparent 0%, #17096a 50%); - opacity: 0.9; - z-index: 2; - div { - padding: 0 0 0 17px; - } -`; - export const GIVgardenTooltip = styled.div` color: ${neutralColors.gray[100]}; text-align: center; diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 24ba459441..3d21dddf1a 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -1,5 +1,4 @@ import React, { FC, ReactNode, useState } from 'react'; -import { Caption, IconAlertCircle32 } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; import { useWeb3React } from '@web3-react/core'; import { @@ -13,10 +12,8 @@ import { StakingPoolContainer, StakingPoolLabel, StakingPoolSubtitle, - WrongNetworkContainer, } from './BaseStakingCard.sc'; -import { chainName } from '@/lib/constants/constants'; import config from '@/configuration'; import { IconAngelVault } from '@/components/Icons/AngelVault'; import { IconBalancer } from '@/components/Icons/Balancer'; @@ -34,6 +31,7 @@ import { ArchiveCover } from './ArchiveCover'; import { StakingCardHeader } from './StakingCardHeader'; import { getNowUnixMS } from '@/helpers/time'; import { StakingPoolInfoAndActions } from './StakingPoolInfoAndActions'; +import { WrongNetworkCover } from '@/components/WrongNetworkCover'; import type { LiquidityPosition } from '@/types/nfts'; export enum StakeCardState { @@ -114,22 +112,7 @@ const BaseStakingCard: FC = ({ return ( <> - {poolNetwork !== chainId && ( - - - - {formatMessage({ - id: 'label.you_are_currently_connected_to', - })}{' '} - {chainName(chainId || 0)}{' '} - {formatMessage({ id: 'label.switch_to' })}{' '} - {chainName(poolNetwork || 0)}{' '} - {formatMessage({ - id: 'label.to_interact_with_this_farm', - })} - - - )} + {(isDiscontinued || exploited) && ( )} From 6160572e844870840ab4bd276557b2cbe04ba033 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 12:02:15 +0330 Subject: [PATCH 117/163] change pool network to targetNetwork --- src/components/WrongNetworkCover.tsx | 8 ++++---- .../StakingCards/BaseStakingCard/BaseStakingCard.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/WrongNetworkCover.tsx b/src/components/WrongNetworkCover.tsx index 9385b6a99c..c89c5bf589 100644 --- a/src/components/WrongNetworkCover.tsx +++ b/src/components/WrongNetworkCover.tsx @@ -11,16 +11,16 @@ import { chainName } from '@/lib/constants/constants'; import { Flex } from './styled-components/Flex'; interface IWrongNetworkCoverProps { - poolNetwork: number; + targetNetwork: number; } export const WrongNetworkCover: FC = ({ - poolNetwork, + targetNetwork, }) => { const { formatMessage } = useIntl(); const { chainId } = useWeb3React(); - return poolNetwork !== chainId ? ( + return targetNetwork !== chainId ? ( @@ -29,7 +29,7 @@ export const WrongNetworkCover: FC = ({ })}{' '} {chainName(chainId || 0)}{' '} {formatMessage({ id: 'label.switch_to' })}{' '} - {chainName(poolNetwork || 0)}{' '} + {chainName(targetNetwork || 0)}{' '} {formatMessage({ id: 'label.to_interact_with_this_farm', })} diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 3d21dddf1a..249aae25ab 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -112,7 +112,6 @@ const BaseStakingCard: FC = ({ return ( <> - {(isDiscontinued || exploited) && ( )} @@ -153,6 +152,7 @@ const BaseStakingCard: FC = ({ setState={setState} /> )} + {showGIVPowerExplain && ( From c07192ff2b06357279a9fab0377d6ccdeee45bc3 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 12:02:44 +0330 Subject: [PATCH 118/163] add WrongNetworkCover to RegenStreamCard --- src/components/givfarm/RegenStreamCard.tsx | 54 ++++++++++++---------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index b4ca36d2a8..ce53304323 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -34,6 +34,7 @@ import config from '@/configuration'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; import { Relative } from '../styled-components/Position'; +import { WrongNetworkCover } from '../WrongNetworkCover'; interface RegenStreamProps { streamConfig: RegenStreamConfig; @@ -68,16 +69,25 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { state => state.subgraph.currentValues, () => (showModal ? true : false), ); + + const { + title, + tokenDistroAddress, + tokenAddressOnUniswapV2, + type, + rewardTokenSymbol, + network: streamNetwork, + } = streamConfig; + const { regenTokenDistroHelper, tokenDistroBalance } = useMemo(() => { const sdh = new SubgraphDataHelper(currentValues); - const tokenDistroBalance = sdh.getTokenDistroBalance( - streamConfig.tokenDistroAddress, - ); + const tokenDistroBalance = + sdh.getTokenDistroBalance(tokenDistroAddress); const regenTokenDistroHelper = new TokenDistroHelper( - sdh.getTokenDistro(streamConfig.tokenDistroAddress), + sdh.getTokenDistro(tokenDistroAddress), ); return { regenTokenDistroHelper, tokenDistroBalance }; - }, [currentValues, streamConfig.tokenDistroAddress]); + }, [currentValues, tokenDistroAddress]); const { mainnetThirdPartyTokensPrice, xDaiThirdPartyTokensPrice } = useAppSelector(state => state.price); @@ -88,7 +98,7 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { ? mainnetThirdPartyTokensPrice : xDaiThirdPartyTokensPrice; const price = new BigNumber( - currentPrice[streamConfig.tokenAddressOnUniswapV2.toLowerCase()], + currentPrice[tokenAddressOnUniswapV2.toLowerCase()], ); if (!price || price.isNaN()) return; @@ -100,7 +110,7 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { }, [ rewardLiquidPart, chainId, - streamConfig.tokenAddressOnUniswapV2, + tokenAddressOnUniswapV2, mainnetThirdPartyTokensPrice, xDaiThirdPartyTokensPrice, ]); @@ -122,19 +132,17 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { const percentage = regenTokenDistroHelper?.GlobalReleasePercentage || 0; const remainTime = durationToString(regenTokenDistroHelper?.remain || 0); - const icon = getStreamIconWithType(streamConfig.type, 40); + const icon = getStreamIconWithType(type, 40); return ( - {streamConfig.title} + {title} {icon} -
- {streamConfig.rewardTokenSymbol} Flowrate -
{' '} +
{rewardTokenSymbol} Flowrate
{' '}
@@ -142,7 +150,7 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { {formatWeiHelper(rewardStream)} - {streamConfig.rewardTokenSymbol} + {rewardTokenSymbol} {formatMessage({ id: 'label./week' })} @@ -155,7 +163,7 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { id: 'label.stream_progress', }, { - token: streamConfig.rewardTokenSymbol, + token: rewardTokenSymbol, }, )}
@@ -171,7 +179,7 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { }, { rewardTokenSymbol: - streamConfig.rewardTokenSymbol, + rewardTokenSymbol, }, )} @@ -196,19 +204,17 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { >
- {getStreamIconWithType(streamConfig.type, 24)} + {getStreamIconWithType(type, 24)} {formatWeiHelper(rewardLiquidPart)} - - {streamConfig.rewardTokenSymbol} - + {rewardTokenSymbol} ~${usdAmount}
setShowModal(true)} buttonType='primary' disabled={rewardLiquidPart.isZero()} @@ -228,14 +234,14 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { title={formatMessage( { id: 'label.token_stream_rewards' }, { - rewardTokenSymbol: - streamConfig.rewardTokenSymbol, + rewardTokenSymbol: rewardTokenSymbol, }, )} setShowModal={setShowModal} regenStreamConfig={streamConfig} /> )} +
); From 8f22b11cc7941a175f1be817534d3053e9fe739c Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 12:07:26 +0330 Subject: [PATCH 119/163] fix WrongNetworkCover styles --- src/components/WrongNetworkCover.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/components/WrongNetworkCover.tsx b/src/components/WrongNetworkCover.tsx index c89c5bf589..064768199d 100644 --- a/src/components/WrongNetworkCover.tsx +++ b/src/components/WrongNetworkCover.tsx @@ -1,14 +1,14 @@ import { FC } from 'react'; import { - IconAlertCircle32, Caption, brandColors, + IconAlertCircle16, } from '@giveth/ui-design-system'; import { useWeb3React } from '@web3-react/core'; import { useIntl } from 'react-intl'; import styled from 'styled-components'; import { chainName } from '@/lib/constants/constants'; -import { Flex } from './styled-components/Flex'; +import { FlexCenter } from './styled-components/Flex'; interface IWrongNetworkCoverProps { targetNetwork: number; @@ -22,8 +22,10 @@ export const WrongNetworkCover: FC = ({ return targetNetwork !== chainId ? ( - - + + + + {formatMessage({ id: 'label.you_are_currently_connected_to', })}{' '} @@ -38,7 +40,7 @@ export const WrongNetworkCover: FC = ({ ) : null; }; -const WrongNetworkContainer = styled(Flex)` +const WrongNetworkContainer = styled(FlexCenter)` position: absolute; width: 100%; height: 100%; @@ -47,11 +49,12 @@ const WrongNetworkContainer = styled(Flex)` left: 0; right: 0; padding: 24px; - flex-direction: row; - align-items: center; background: ${brandColors.giv[900]}dd; z-index: 2; - div { - padding: 0 0 0 17px; - } + gap: 16px; +`; + +const IconWrapper = styled.div` + width: 16px; + height: 16px; `; From 05eb230e7aeaea1d963843823a11ae5eb6c4d49c Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 12:08:54 +0330 Subject: [PATCH 120/163] limit content width --- src/components/WrongNetworkCover.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/WrongNetworkCover.tsx b/src/components/WrongNetworkCover.tsx index 064768199d..ce9c5f3b0d 100644 --- a/src/components/WrongNetworkCover.tsx +++ b/src/components/WrongNetworkCover.tsx @@ -25,7 +25,7 @@ export const WrongNetworkCover: FC = ({ - + {formatMessage({ id: 'label.you_are_currently_connected_to', })}{' '} @@ -35,7 +35,7 @@ export const WrongNetworkCover: FC = ({ {formatMessage({ id: 'label.to_interact_with_this_farm', })} - + ) : null; }; @@ -58,3 +58,7 @@ const IconWrapper = styled.div` width: 16px; height: 16px; `; + +const Content = styled(Caption)` + max-width: 320px; +`; From d267b8ce63bc734ff0f33ca31f83274e3b4b5ccd Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 12:18:17 +0330 Subject: [PATCH 121/163] move archive to components --- .../BaseStakingCard => }/ArchiveCover.tsx | 0 .../BaseStakingCard/BaseStakingCard.tsx | 13 ++++--------- 2 files changed, 4 insertions(+), 9 deletions(-) rename src/components/{cards/StakingCards/BaseStakingCard => }/ArchiveCover.tsx (100%) diff --git a/src/components/cards/StakingCards/BaseStakingCard/ArchiveCover.tsx b/src/components/ArchiveCover.tsx similarity index 100% rename from src/components/cards/StakingCards/BaseStakingCard/ArchiveCover.tsx rename to src/components/ArchiveCover.tsx diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 249aae25ab..aeab638d89 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -1,6 +1,4 @@ import React, { FC, ReactNode, useState } from 'react'; -import { useIntl } from 'react-intl'; -import { useWeb3React } from '@web3-react/core'; import { PoolStakingConfig, RegenPoolStakingConfig, @@ -27,11 +25,11 @@ import { GIVPowerExplainModal } from '@/components/modals/GIVPowerExplain'; import { StakingPoolImages } from '@/components/StakingPoolImages'; import GIVpowerCardIntro from '../GIVpowerCard/GIVpowerCardIntro'; import StakingCardIntro from '../StakingCardIntro'; -import { ArchiveCover } from './ArchiveCover'; import { StakingCardHeader } from './StakingCardHeader'; import { getNowUnixMS } from '@/helpers/time'; import { StakingPoolInfoAndActions } from './StakingPoolInfoAndActions'; import { WrongNetworkCover } from '@/components/WrongNetworkCover'; +import { ArchiveCover } from '@/components/ArchiveCover'; import type { LiquidityPosition } from '@/types/nfts'; export enum StakeCardState { @@ -85,12 +83,9 @@ const BaseStakingCard: FC = ({ unstakedPositions, currentIncentive, }) => { - const { formatMessage } = useIntl(); const [state, setState] = useState(StakeCardState.NORMAL); const [showGIVPowerExplain, setShowGIVPowerExplain] = useState(false); - const { chainId } = useWeb3React(); - const { type, title, @@ -112,9 +107,6 @@ const BaseStakingCard: FC = ({ return ( <> - {(isDiscontinued || exploited) && ( - - )} {state === StakeCardState.NORMAL ? ( <> = ({ /> )} + {(isDiscontinued || exploited) && ( + + )} {showGIVPowerExplain && ( From 36958617419cba597757ae5b3514b859f932ab4c Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 12:23:50 +0330 Subject: [PATCH 122/163] remove dontArchive --- src/config/production.ts | 1 - src/types/config.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/config/production.ts b/src/config/production.ts index 58c0ca7b85..79ead9afaf 100644 --- a/src/config/production.ts +++ b/src/config/production.ts @@ -176,7 +176,6 @@ const config: EnvConfig = { regenStreamType: StreamType.CULT, farmStartTimeMS: 1668691800000, farmEndTimeMS: 1669901843000, - dontArchive: true, introCard: { title: 'CULT', description: `The purpose of CULT is to empower those building and contributing to our decentralized future. Our society makes it as difficult as possible to break away from societal, economic and other norms, and CULT serves to fund and support those who are working to take back our future. CULT is a reminder that the power in people is stronger than the people in power.\n\n CULT is the governance token of the Cult DAO. Every transaction of the CULT token allows you to contribute & fast-forward economic & societal change by contributing a 0.4% tax to the treasury. Fight from within until you get out, or change the system in doing so.`, diff --git a/src/types/config.ts b/src/types/config.ts index 6bd1539255..9cd04b52e6 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -87,7 +87,6 @@ export interface IntroCardConfig { export interface RegenPoolStakingConfig extends SimplePoolStakingConfig { regenStreamType: StreamType; - dontArchive?: boolean; } export interface GasPreference { @@ -102,6 +101,7 @@ export interface RegenStreamConfig { type: StreamType; rewardTokenAddress: string; rewardTokenSymbol: string; + archived?: boolean; // For price purpose tokenAddressOnUniswapV2: string; } From 4340593d58f6b2fed834dfb31d80da3787087647 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 12:24:08 +0330 Subject: [PATCH 123/163] show archive cover on RegenStreamCard --- src/components/givfarm/RegenStreamCard.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index ce53304323..97b9acc16e 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -35,6 +35,7 @@ import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; import { Relative } from '../styled-components/Position'; import { WrongNetworkCover } from '../WrongNetworkCover'; +import { ArchiveCover } from '../ArchiveCover'; interface RegenStreamProps { streamConfig: RegenStreamConfig; @@ -77,6 +78,7 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { type, rewardTokenSymbol, network: streamNetwork, + archived, } = streamConfig; const { regenTokenDistroHelper, tokenDistroBalance } = useMemo(() => { @@ -241,6 +243,7 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { regenStreamConfig={streamConfig} /> )} + {archived && } From 678fcf473260c8e7186887e620ee2ce9774bcdc3 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 12:35:10 +0330 Subject: [PATCH 124/163] show one of the wrong and archive covers --- .../StakingCards/BaseStakingCard/BaseStakingCard.tsx | 10 +++++++--- src/components/givfarm/RegenStreamCard.tsx | 7 +++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index aeab638d89..b2ff916e4c 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -1,4 +1,5 @@ import React, { FC, ReactNode, useState } from 'react'; +import { useWeb3React } from '@web3-react/core'; import { PoolStakingConfig, RegenPoolStakingConfig, @@ -86,6 +87,8 @@ const BaseStakingCard: FC = ({ const [state, setState] = useState(StakeCardState.NORMAL); const [showGIVPowerExplain, setShowGIVPowerExplain] = useState(false); + const { chainId } = useWeb3React(); + const { type, title, @@ -144,10 +147,11 @@ const BaseStakingCard: FC = ({ setState={setState} /> )} - - {(isDiscontinued || exploited) && ( + {chainId !== poolNetwork ? ( + + ) : isDiscontinued || exploited ? ( - )} + ) : null} {showGIVPowerExplain && ( diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 97b9acc16e..11da4f7760 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -243,8 +243,11 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { regenStreamConfig={streamConfig} /> )} - {archived && } - + {chainId !== streamNetwork ? ( + + ) : archived ? ( + + ) : null} ); From cc0216db18ed0dabc560425af484eb4297648bd1 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 12:51:57 +0330 Subject: [PATCH 125/163] fix cover --- src/components/ArchiveCover.tsx | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/components/ArchiveCover.tsx b/src/components/ArchiveCover.tsx index a7c4018579..02072ede05 100644 --- a/src/components/ArchiveCover.tsx +++ b/src/components/ArchiveCover.tsx @@ -8,7 +8,7 @@ import { import { FC, useState } from 'react'; import { useIntl } from 'react-intl'; import styled from 'styled-components'; -import { Flex } from '@/components/styled-components/Flex'; +import { Flex, FlexCenter } from '@/components/styled-components/Flex'; import { Shadow } from '@/components/styled-components/Shadow'; interface IArchiveCoverProps { @@ -16,11 +16,11 @@ interface IArchiveCoverProps { } export const ArchiveCover: FC = ({ isExploited }) => { - const [disableModal, setDisableModal] = useState(true); + const [showModal, setShowModal] = useState(true); const { formatMessage } = useIntl(); - return disableModal ? ( - + return showModal ? ( + @@ -63,24 +63,23 @@ export const ArchiveCover: FC = ({ isExploited }) => { label={formatMessage({ id: 'label.got_it', })} - onClick={() => setDisableModal(false)} + onClick={() => setShowModal(false)} /> - + ) : null; }; -const DisableModal = styled.div` +const Cover = styled(FlexCenter)` position: absolute; width: 100%; height: 100%; - background: transparent; + top: 0; + right: 0; + left: 0; z-index: 10; - display: flex; - justify-content: center; - align-items: center; - background-color: #00000070; + background: ${brandColors.giv[900]}cc; `; const DisableModalContent = styled.div` From d0abbf43df08442fa68dffa3b2e440f304090262 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 13:06:51 +0330 Subject: [PATCH 126/163] fix archive modal styles --- src/components/ArchiveCover.tsx | 60 +++++++++++++++------------------ 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/src/components/ArchiveCover.tsx b/src/components/ArchiveCover.tsx index 02072ede05..b6e696ba49 100644 --- a/src/components/ArchiveCover.tsx +++ b/src/components/ArchiveCover.tsx @@ -1,7 +1,7 @@ import { brandColors, GLink, - IconInfoFilled24, + IconInfoFilled16, OutlineButton, P, } from '@giveth/ui-design-system'; @@ -9,7 +9,6 @@ import { FC, useState } from 'react'; import { useIntl } from 'react-intl'; import styled from 'styled-components'; import { Flex, FlexCenter } from '@/components/styled-components/Flex'; -import { Shadow } from '@/components/styled-components/Shadow'; interface IArchiveCoverProps { isExploited?: boolean; @@ -21,23 +20,23 @@ export const ArchiveCover: FC = ({ isExploited }) => { return showModal ? ( - - - - + + + + - + {formatMessage({ id: 'label.this_farm_has_ended', })} - - + + {isExploited ? ( <> {formatMessage({ id: 'label.an_exploit_has_removed_available_rewards', })} - = ({ isExploited }) => { id: 'label.this_forum_post', })}   - + {formatMessage({ id: 'label.for_details', })} @@ -58,15 +57,15 @@ export const ArchiveCover: FC = ({ isExploited }) => { id: 'label.harvest_your_rewards_and_remove_your_funds', }) )} - - + setShowModal(false)} /> - + ) : null; }; @@ -82,39 +81,34 @@ const Cover = styled(FlexCenter)` background: ${brandColors.giv[900]}cc; `; -const DisableModalContent = styled.div` +const ArchiveModal = styled.div` display: flex; - background: white; - gap: 12px; - border-radius: 12px; - box-shadow: ${Shadow.Neutral[400]}; - max-width: 80%; - height: 190px; - padding: 16px 12px; + background-color: ${brandColors.giv[400]}; + color: ${brandColors.giv['000']}; + gap: 10px; + border-radius: 8px; + width: 291px; + padding: 16px; `; -const DisableModalText = styled(P)<{ weight?: number }>` - color: ${brandColors.giv[500]}; +const ArchiveModalText = styled(P)<{ weight?: number }>` font-weight: ${props => (props.weight ? props.weight : 400)}; `; -const DisableModalLink = styled(GLink)` - color: ${brandColors.pinky[500]}; -`; +const ArchiveModalLink = styled(GLink)``; -const DisableModalCloseButton = styled(OutlineButton)` +const CloseButton = styled(OutlineButton)` border: none; - color: ${brandColors.giv[500]}; font-weight: 700; margin-left: auto; padding-right: 4px; - &:hover { background-color: transparent; } `; -const DisableModalImage = styled.div` - width: 36px; - color: ${brandColors.giv[500]}; +const ArchiveModalIcon = styled.div` + width: 16px; + height: 20px; + padding-top: 4px; `; From 3a675f525b58a529cdd7948d9f7ac16897af6748 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 13:14:12 +0330 Subject: [PATCH 127/163] fix copies --- lang/en.json | 4 +++- lang/es.json | 4 +++- src/components/ArchiveCover.tsx | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lang/en.json b/lang/en.json index c639ee5537..b516c0ae04 100644 --- a/lang/en.json +++ b/lang/en.json @@ -732,6 +732,7 @@ "label.switch_to": "switch to", "label.to_interact_with_this_farm": "to interact with this farm.", "label.this_farm_has_ended": "This farm has ended", + "label.this_stream_has_ended": "This farm has ended", "label.an_exploit_has_removed_available_rewards": "An exploit has removed available rewards from this pool. Please refer to", "label.this_forum_post": "this forum post", "label.for_details": "for details.", @@ -928,5 +929,6 @@ "label.an_evolution_in_community_fundrising": "An evolution in community fundraising.", "label.your_donations_and_participation_in_the_giveconomy": "Your donations, and participation in the GIVeconomy, enables us to build a new future where real world impact projects benefit from their own community-driven regenerative economies.", "label.discover_our_roadmap": "discover our roadmap", - "label.more_about_us": "More about us" + "label.more_about_us": "More about us", + "component.archive_cover.archived": "ARCHIVED!!" } diff --git a/lang/es.json b/lang/es.json index ddaad7cdd2..d6a476ceb2 100644 --- a/lang/es.json +++ b/lang/es.json @@ -729,6 +729,7 @@ "label.switch_to": "", "label.to_interact_with_this_farm": "", "label.this_farm_has_ended": "", + "label.this_stream_has_ended": "", "label.an_exploit_has_removed_available_rewards": "", "label.this_forum_post": "", "label.for_details": "", @@ -912,5 +913,6 @@ "label.an_evolution_in_community_fundrising": "", "label.your_donations_and_participation_in_the_giveconomy": "", "label.discover_our_roadmap": "", - "label.more_about_us": "" + "label.more_about_us": "", + "component.archive_cover.archived": "" } diff --git a/src/components/ArchiveCover.tsx b/src/components/ArchiveCover.tsx index b6e696ba49..18a958ce25 100644 --- a/src/components/ArchiveCover.tsx +++ b/src/components/ArchiveCover.tsx @@ -11,10 +11,14 @@ import styled from 'styled-components'; import { Flex, FlexCenter } from '@/components/styled-components/Flex'; interface IArchiveCoverProps { + isStream?: boolean; isExploited?: boolean; } -export const ArchiveCover: FC = ({ isExploited }) => { +export const ArchiveCover: FC = ({ + isStream, + isExploited, +}) => { const [showModal, setShowModal] = useState(true); const { formatMessage } = useIntl(); @@ -27,7 +31,7 @@ export const ArchiveCover: FC = ({ isExploited }) => { {formatMessage({ - id: 'label.this_farm_has_ended', + id: 'component.archive_cover.archived', })} @@ -53,6 +57,12 @@ export const ArchiveCover: FC = ({ isExploited }) => { })} ) : ( + formatMessage({ + id: isStream + ? 'label.this_stream_has_ended' + : 'label.this_farm_has_ended', + }) + + '. ' + formatMessage({ id: 'label.harvest_your_rewards_and_remove_your_funds', }) From a45577bf4240e34fb140b97f86e05964dc893dec Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 13:30:20 +0330 Subject: [PATCH 128/163] integrate covers --- lang/en.json | 2 +- .../ArchiveAndNetworkCover.tsx | 26 +++++++++++++++++++ .../ArchiveCover.tsx | 14 ++-------- .../WrongNetworkCover.tsx | 26 +++---------------- .../ArchiveAndNetworkCover/common.ts | 17 ++++++++++++ .../BaseStakingCard/BaseStakingCard.tsx | 13 +++++----- src/components/givfarm/RegenStreamCard.tsx | 13 +++++----- 7 files changed, 62 insertions(+), 49 deletions(-) create mode 100644 src/components/ArchiveAndNetworkCover/ArchiveAndNetworkCover.tsx rename src/components/{ => ArchiveAndNetworkCover}/ArchiveCover.tsx (91%) rename src/components/{ => ArchiveAndNetworkCover}/WrongNetworkCover.tsx (70%) create mode 100644 src/components/ArchiveAndNetworkCover/common.ts diff --git a/lang/en.json b/lang/en.json index b516c0ae04..650d40b663 100644 --- a/lang/en.json +++ b/lang/en.json @@ -732,7 +732,7 @@ "label.switch_to": "switch to", "label.to_interact_with_this_farm": "to interact with this farm.", "label.this_farm_has_ended": "This farm has ended", - "label.this_stream_has_ended": "This farm has ended", + "label.this_stream_has_ended": "This stream has ended", "label.an_exploit_has_removed_available_rewards": "An exploit has removed available rewards from this pool. Please refer to", "label.this_forum_post": "this forum post", "label.for_details": "for details.", diff --git a/src/components/ArchiveAndNetworkCover/ArchiveAndNetworkCover.tsx b/src/components/ArchiveAndNetworkCover/ArchiveAndNetworkCover.tsx new file mode 100644 index 0000000000..fca5045671 --- /dev/null +++ b/src/components/ArchiveAndNetworkCover/ArchiveAndNetworkCover.tsx @@ -0,0 +1,26 @@ +import { useWeb3React } from '@web3-react/core'; +import { FC } from 'react'; +import { ArchiveCover } from './ArchiveCover'; +import { WrongNetworkCover } from './WrongNetworkCover'; + +interface IArchiveAndNetworkCoverProps { + targetNetwork: number; + isStream?: boolean; + isArchived?: boolean; + isExploited?: boolean; +} + +export const ArchiveAndNetworkCover: FC = ({ + isStream, + targetNetwork, + isArchived, + isExploited, +}) => { + const { chainId } = useWeb3React(); + + return chainId !== targetNetwork ? ( + + ) : isArchived || isExploited ? ( + + ) : null; +}; diff --git a/src/components/ArchiveCover.tsx b/src/components/ArchiveAndNetworkCover/ArchiveCover.tsx similarity index 91% rename from src/components/ArchiveCover.tsx rename to src/components/ArchiveAndNetworkCover/ArchiveCover.tsx index 18a958ce25..c169a3b95a 100644 --- a/src/components/ArchiveCover.tsx +++ b/src/components/ArchiveAndNetworkCover/ArchiveCover.tsx @@ -8,7 +8,8 @@ import { import { FC, useState } from 'react'; import { useIntl } from 'react-intl'; import styled from 'styled-components'; -import { Flex, FlexCenter } from '@/components/styled-components/Flex'; +import { Flex } from '@/components/styled-components/Flex'; +import { Cover } from './common'; interface IArchiveCoverProps { isStream?: boolean; @@ -80,17 +81,6 @@ export const ArchiveCover: FC = ({ ) : null; }; -const Cover = styled(FlexCenter)` - position: absolute; - width: 100%; - height: 100%; - top: 0; - right: 0; - left: 0; - z-index: 10; - background: ${brandColors.giv[900]}cc; -`; - const ArchiveModal = styled.div` display: flex; background-color: ${brandColors.giv[400]}; diff --git a/src/components/WrongNetworkCover.tsx b/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx similarity index 70% rename from src/components/WrongNetworkCover.tsx rename to src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx index ce9c5f3b0d..34f4259ae1 100644 --- a/src/components/WrongNetworkCover.tsx +++ b/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx @@ -1,14 +1,10 @@ import { FC } from 'react'; -import { - Caption, - brandColors, - IconAlertCircle16, -} from '@giveth/ui-design-system'; +import { Caption, IconAlertCircle16 } from '@giveth/ui-design-system'; import { useWeb3React } from '@web3-react/core'; import { useIntl } from 'react-intl'; import styled from 'styled-components'; import { chainName } from '@/lib/constants/constants'; -import { FlexCenter } from './styled-components/Flex'; +import { Cover } from './common'; interface IWrongNetworkCoverProps { targetNetwork: number; @@ -21,7 +17,7 @@ export const WrongNetworkCover: FC = ({ const { chainId } = useWeb3React(); return targetNetwork !== chainId ? ( - + @@ -36,24 +32,10 @@ export const WrongNetworkCover: FC = ({ id: 'label.to_interact_with_this_farm', })} - + ) : null; }; -const WrongNetworkContainer = styled(FlexCenter)` - position: absolute; - width: 100%; - height: 100%; - top: 0; - bottom: 0; - left: 0; - right: 0; - padding: 24px; - background: ${brandColors.giv[900]}dd; - z-index: 2; - gap: 16px; -`; - const IconWrapper = styled.div` width: 16px; height: 16px; diff --git a/src/components/ArchiveAndNetworkCover/common.ts b/src/components/ArchiveAndNetworkCover/common.ts new file mode 100644 index 0000000000..8084c2eeb9 --- /dev/null +++ b/src/components/ArchiveAndNetworkCover/common.ts @@ -0,0 +1,17 @@ +import { brandColors } from '@giveth/ui-design-system'; +import styled from 'styled-components'; +import { FlexCenter } from '../styled-components/Flex'; + +export const Cover = styled(FlexCenter)` + position: absolute; + width: 100%; + height: 100%; + top: 0; + bottom: 0; + left: 0; + right: 0; + padding: 24px; + background: ${brandColors.giv[900]}dd; + z-index: 2; + gap: 16px; +`; diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index b2ff916e4c..83ab698f9d 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -29,8 +29,7 @@ import StakingCardIntro from '../StakingCardIntro'; import { StakingCardHeader } from './StakingCardHeader'; import { getNowUnixMS } from '@/helpers/time'; import { StakingPoolInfoAndActions } from './StakingPoolInfoAndActions'; -import { WrongNetworkCover } from '@/components/WrongNetworkCover'; -import { ArchiveCover } from '@/components/ArchiveCover'; +import { ArchiveAndNetworkCover } from '@/components/ArchiveAndNetworkCover/ArchiveAndNetworkCover'; import type { LiquidityPosition } from '@/types/nfts'; export enum StakeCardState { @@ -147,11 +146,11 @@ const BaseStakingCard: FC = ({ setState={setState} /> )} - {chainId !== poolNetwork ? ( - - ) : isDiscontinued || exploited ? ( - - ) : null} + {showGIVPowerExplain && ( diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 11da4f7760..495082c8a5 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -34,8 +34,7 @@ import config from '@/configuration'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; import { Relative } from '../styled-components/Position'; -import { WrongNetworkCover } from '../WrongNetworkCover'; -import { ArchiveCover } from '../ArchiveCover'; +import { ArchiveAndNetworkCover } from '../ArchiveAndNetworkCover/ArchiveAndNetworkCover'; interface RegenStreamProps { streamConfig: RegenStreamConfig; @@ -243,11 +242,11 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { regenStreamConfig={streamConfig} /> )} - {chainId !== streamNetwork ? ( - - ) : archived ? ( - - ) : null} + ); From cbc3d1c346d235270d5f589519e226b3a28551b2 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 13:41:46 +0330 Subject: [PATCH 129/163] handle showArchivedPools in RegenStreamSection --- src/components/givfarm/RegenStreamSection.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/givfarm/RegenStreamSection.tsx b/src/components/givfarm/RegenStreamSection.tsx index 9c53e2e597..94dd58809b 100644 --- a/src/components/givfarm/RegenStreamSection.tsx +++ b/src/components/givfarm/RegenStreamSection.tsx @@ -16,7 +16,7 @@ export const RegenStreamSection: FC = ({ }) => { const { chainId } = useWeb3React(); const { formatMessage } = useIntl(); - const regenStreams = + const _regenStreams = chainId === config.XDAI_NETWORK_NUMBER ? [ ...config.XDAI_CONFIG.regenStreams, @@ -26,6 +26,9 @@ export const RegenStreamSection: FC = ({ ...config.MAINNET_CONFIG.regenStreams, ...config.XDAI_CONFIG.regenStreams, ]; + const regenStreams = showArchivedPools + ? _regenStreams + : _regenStreams.filter(regenStream => !regenStream.archived); return ( <> From 62e66ce944ad025086d6d9fc7c3eb2cbb83d0293 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 13:43:30 +0330 Subject: [PATCH 130/163] add test regen stream --- src/config/development.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/config/development.ts b/src/config/development.ts index eaac4766c9..3aac8c99ed 100644 --- a/src/config/development.ts +++ b/src/config/development.ts @@ -233,6 +233,20 @@ const config: EnvConfig = { tokenAddressOnUniswapV2: '0x21a42669643f45Bc0e086b8Fc2ed70c23D67509d', }, + { + /// Just for testing + archived: true, + network: XDAI_NETWORK_NUMBER, + tokenDistroAddress: + '0xCA29ec6F4218E230294993E0d77d5ece5a6573D8', + type: StreamType.FOX, + title: 'ShapeShift DAO', + rewardTokenAddress: + '0x18cE354571ba71bC7b3d633b254954C5A9cfC195', + rewardTokenSymbol: 'FOX', + tokenAddressOnUniswapV2: + '0x21a42669643f45Bc0e086b8Fc2ed70c23D67509d', + }, ], }, }; From e5139da6aa0b93a000c4193a466a58ed03b36b2b Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 14:51:22 +0330 Subject: [PATCH 131/163] add label to switch --- src/components/styled-components/Switch.tsx | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/components/styled-components/Switch.tsx b/src/components/styled-components/Switch.tsx index d055f8bf56..fff128a1ed 100644 --- a/src/components/styled-components/Switch.tsx +++ b/src/components/styled-components/Switch.tsx @@ -1,14 +1,20 @@ import React, { ChangeEvent, Dispatch, SetStateAction } from 'react'; import styled from 'styled-components'; -import { brandColors, neutralColors } from '@giveth/ui-design-system'; +import { brandColors, GLink, neutralColors } from '@giveth/ui-design-system'; interface IToggleSwitch { checked: boolean; - disabled: boolean; + label?: string; + disabled?: boolean; setStateChange: Dispatch>; } -const ToggleSwitch = ({ checked, disabled, setStateChange }: IToggleSwitch) => { +const ToggleSwitch = ({ + checked, + label, + disabled = false, + setStateChange, +}: IToggleSwitch) => { const handleChange = (e: ChangeEvent) => setStateChange(e.target.checked); @@ -20,7 +26,7 @@ const ToggleSwitch = ({ checked, disabled, setStateChange }: IToggleSwitch) => { type='checkbox' onChange={handleChange} /> - + {label && {label}} ); @@ -49,7 +55,7 @@ const Switch = styled.div<{ checked: boolean; disabled: boolean }>` width: 11px; height: 11px; border-radius: 7px; - top: 50%; + top: 0; left: 1px; background: ${props => props.checked @@ -59,17 +65,13 @@ const Switch = styled.div<{ checked: boolean; disabled: boolean }>` : brandColors.pinky[200]}; border: 3px solid ${brandColors.giv['000']}; border-radius: 50%; - transform: translate(0, -50%); + transform: ${props => + props.checked ? 'translateX(100%)' : 'translateX(0)'}; } `; const Input = styled.input` display: none; - &:checked + ${Switch} { - &:before { - transform: translate(14px, -50%); - } - } `; export default ToggleSwitch; From b1484ead7d47d6ea406e34e2e0195d952090452b Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 6 Mar 2023 14:53:01 +0330 Subject: [PATCH 132/163] use ToggleSwitch for showing archive pools --- .../views/givfarm/GIVfarmBottom.tsx | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/components/views/givfarm/GIVfarmBottom.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx index 94d70af5e6..c2e90489a0 100644 --- a/src/components/views/givfarm/GIVfarmBottom.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -13,9 +13,7 @@ import { ContractRow, CopyWrapper, GIVfarmBottomContainer, - ArchivedPoolsToggle, } from '../../GIVeconomyPages/GIVfarm.sc'; -import RadioButton from '@/components/RadioButton'; import { NetworkSelector } from '@/components/NetworkSelector'; import { getGivStakingConfig } from '@/helpers/networkProvider'; import { ExtLinkRow } from '../../GIVeconomyPages/commons'; @@ -27,6 +25,7 @@ import { getNowUnixMS } from '@/helpers/time'; import { TWO_WEEK } from '@/lib/constants/constants'; import StakingPoolCard from '../../cards/StakingCards/StakingPoolCard'; import { RegenStreamSection } from '@/components/givfarm/RegenStreamSection'; +import ToggleSwitch from '@/components/styled-components/Switch'; const renderPool = ( pool: SimplePoolStakingConfig | UniswapV3PoolStakingConfig, @@ -77,7 +76,7 @@ const renderPools = (chainId?: number, showArchivedPools?: boolean) => { export const GIVfarmBottom = () => { const { formatMessage } = useIntl(); const { chainId } = useWeb3React(); - const [showArchivedPools, setArchivedPools] = useState(false); + const [showArchivedPools, setShowArchivedPools] = useState(false); return ( @@ -146,17 +145,15 @@ export const GIVfarmBottom = () => { + - - setArchivedPools(!showArchivedPools)} - isSelected={showArchivedPools} - /> - Date: Mon, 6 Mar 2023 14:56:48 +0330 Subject: [PATCH 133/163] fix copy --- lang/en.json | 2 +- lang/es.json | 2 +- src/components/views/givfarm/GIVfarmBottom.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lang/en.json b/lang/en.json index 650d40b663..d601ecd984 100644 --- a/lang/en.json +++ b/lang/en.json @@ -727,7 +727,7 @@ "label.your_givfarm_rewards": "Your GIVfarm rewards", "label.bridge_your_giv": "Bridge your GIV", "label.contract": "Contract", - "label.show_archived_pools": "Show archived pools", + "label.switch_to_archive_cards": "Switch to Archive Cards", "label.you_are_currently_connected_to": "You are currently connected to", "label.switch_to": "switch to", "label.to_interact_with_this_farm": "to interact with this farm.", diff --git a/lang/es.json b/lang/es.json index d6a476ceb2..552767ed6b 100644 --- a/lang/es.json +++ b/lang/es.json @@ -724,7 +724,7 @@ "label.your_givfarm_rewards": "", "label.bridge_your_giv": "", "label.contract": "Contrato", - "label.show_archived_pools": "Mostrar pools archivadas", + "label.switch_to_archive_cards": "", "label.you_are_currently_connected_to": "", "label.switch_to": "", "label.to_interact_with_this_farm": "", diff --git a/src/components/views/givfarm/GIVfarmBottom.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx index c2e90489a0..2641feaf93 100644 --- a/src/components/views/givfarm/GIVfarmBottom.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -147,7 +147,7 @@ export const GIVfarmBottom = () => { Date: Mon, 6 Mar 2023 15:07:40 +0330 Subject: [PATCH 134/163] only show archived pools --- src/components/givfarm/RegenStreamSection.tsx | 2 +- .../views/givfarm/GIVfarmBottom.tsx | 29 +++++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/components/givfarm/RegenStreamSection.tsx b/src/components/givfarm/RegenStreamSection.tsx index 94dd58809b..4325e96b33 100644 --- a/src/components/givfarm/RegenStreamSection.tsx +++ b/src/components/givfarm/RegenStreamSection.tsx @@ -27,7 +27,7 @@ export const RegenStreamSection: FC = ({ ...config.XDAI_CONFIG.regenStreams, ]; const regenStreams = showArchivedPools - ? _regenStreams + ? _regenStreams.filter(regenStream => regenStream.archived) : _regenStreams.filter(regenStream => !regenStream.archived); return ( diff --git a/src/components/views/givfarm/GIVfarmBottom.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx index 2641feaf93..04171f5239 100644 --- a/src/components/views/givfarm/GIVfarmBottom.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -32,10 +32,6 @@ const renderPool = ( id: number, ) => ( - {/* {pool.type === StakingType.UNISWAPV3_ETH_GIV ? ( - - ) : ( - )} */} ); @@ -58,19 +54,18 @@ const renderPools = (chainId?: number, showArchivedPools?: boolean) => { const now = getNowUnixMS(); const filteredPools = []; - const discontinuedPools = []; + const archivedPools = []; for (let i = 0; i < pools.length; i++) { const pool = pools[i]; const { farmEndTimeMS } = pool; const archived = farmEndTimeMS && now > farmEndTimeMS + TWO_WEEK; - if (!showArchivedPools && archived) continue; - if (farmEndTimeMS && now > farmEndTimeMS) { - discontinuedPools.push(renderPool(pool, i)); + if (archived) { + archivedPools.push(renderPool(pool, i)); } else { filteredPools.push(renderPool(pool, i)); } } - return [...filteredPools, ...discontinuedPools]; + return showArchivedPools ? archivedPools : filteredPools; }; export const GIVfarmBottom = () => { @@ -155,13 +150,15 @@ export const GIVfarmBottom = () => { - - - + {!showArchivedPools && ( + + + + )} {showArchivedPools && ( Date: Mon, 6 Mar 2023 15:19:22 +0330 Subject: [PATCH 135/163] make GIVfarmToolBoxRow responsive --- src/components/GIVeconomyPages/GIVfarm.sc.tsx | 16 +-- .../views/givfarm/GIVfarmBottom.tsx | 125 +++++++++--------- 2 files changed, 67 insertions(+), 74 deletions(-) diff --git a/src/components/GIVeconomyPages/GIVfarm.sc.tsx b/src/components/GIVeconomyPages/GIVfarm.sc.tsx index 01fd4f0938..1d18c6268b 100644 --- a/src/components/GIVeconomyPages/GIVfarm.sc.tsx +++ b/src/components/GIVeconomyPages/GIVfarm.sc.tsx @@ -36,21 +36,17 @@ export const GIVfarmRewardCard = styled(EnhancedRewardCard)` } `; -export const ArchivedPoolsToggle = styled.div` - margin-top: 25px; - display: inline-block; +export const GIVfarmToolBoxRow = styled(Flex)` + flex-direction: column; + ${mediaQueries.tablet} { + flex-direction: row; + } `; -interface PoolRowProps { - disabled?: boolean; -} - -export const PoolRow = styled(Row)` +export const PoolRow = styled(Row)` align-items: center; margin-top: 24px; margin-bottom: 24px; - opacity: ${props => (props.disabled ? '0.6' : '1')}; - pointer-events: ${props => (props.disabled ? 'none' : 'auto')}; `; export const ContractRow = styled(Flex)` diff --git a/src/components/views/givfarm/GIVfarmBottom.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx index 04171f5239..2c0f40c639 100644 --- a/src/components/views/givfarm/GIVfarmBottom.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -2,7 +2,6 @@ import React, { useState } from 'react'; import { IconExternalLink, GLink, IconCopy } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; import { useWeb3React } from '@web3-react/core'; -import { Flex } from '@/components/styled-components/Flex'; import config from '@/configuration'; import { SimplePoolStakingConfig, @@ -13,6 +12,7 @@ import { ContractRow, CopyWrapper, GIVfarmBottomContainer, + GIVfarmToolBoxRow, } from '../../GIVeconomyPages/GIVfarm.sc'; import { NetworkSelector } from '@/components/NetworkSelector'; import { getGivStakingConfig } from '@/helpers/networkProvider'; @@ -76,79 +76,76 @@ export const GIVfarmBottom = () => { return ( - - - - - {formatMessage({ id: 'label.bridge_your_giv' })} - - - - - - {formatMessage({ id: 'label.buy_giv_token' })} - - - - - {`${formatMessage({ - id: 'label.contract', - })} (${ + + + {formatMessage({ id: 'label.bridge_your_giv' })} + + + + + + {formatMessage({ id: 'label.buy_giv_token' })} + + + + + {`${formatMessage({ + id: 'label.contract', + })} (${ + chainId === config.XDAI_NETWORK_NUMBER + ? config.XDAI_CONFIG.chainName + : config.MAINNET_CONFIG.chainName + }):`} + + {shortenAddress( chainId === config.XDAI_NETWORK_NUMBER - ? config.XDAI_CONFIG.chainName - : config.MAINNET_CONFIG.chainName - }):`} - - {shortenAddress( + ? config.XDAI_CONFIG.TOKEN_ADDRESS + : config.MAINNET_CONFIG.TOKEN_ADDRESS, + )} + + { + navigator.clipboard.writeText( chainId === config.XDAI_NETWORK_NUMBER ? config.XDAI_CONFIG.TOKEN_ADDRESS : config.MAINNET_CONFIG.TOKEN_ADDRESS, - )} - - { - navigator.clipboard.writeText( - chainId === config.XDAI_NETWORK_NUMBER - ? config.XDAI_CONFIG.TOKEN_ADDRESS - : config.MAINNET_CONFIG - .TOKEN_ADDRESS, - ); - }} - > - - - - - - + ); + }} + > + + + + + {!showArchivedPools && ( From 0e1f3e6aa2e92af3010159379958567305ce1fc8 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 8 Mar 2023 17:25:38 +0330 Subject: [PATCH 136/163] redeploy --- pages/test1.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/pages/test1.tsx b/pages/test1.tsx index 4102e0bf33..0c8d3dcbe3 100644 --- a/pages/test1.tsx +++ b/pages/test1.tsx @@ -5,6 +5,7 @@ import { IconHelpFilled16 } from '@giveth/ui-design-system'; import { FC, useEffect, useRef, useState } from 'react'; import dynamic from 'next/dynamic'; import { useRouter } from 'next/router'; + import { gToast, ToastType } from '@/components/toasts'; import { useAppDispatch } from '@/features/hooks'; import { fetchXDaiInfoAsync } from '@/features/subgraph/subgraph.thunks'; From dfe28bf3adbafe6aa0cc2048a03689e51896b675 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 12 Mar 2023 13:05:39 +0330 Subject: [PATCH 137/163] handle not connected wallet --- lang/en.json | 1 + lang/es.json | 1 + .../ArchiveAndNetworkCover.tsx | 2 +- .../WrongNetworkCover.tsx | 30 ++++++++++++------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/lang/en.json b/lang/en.json index d601ecd984..0ea17f7f02 100644 --- a/lang/en.json +++ b/lang/en.json @@ -731,6 +731,7 @@ "label.you_are_currently_connected_to": "You are currently connected to", "label.switch_to": "switch to", "label.to_interact_with_this_farm": "to interact with this farm.", + "label.please_connect_your_wallet": "Please Connect your wallet", "label.this_farm_has_ended": "This farm has ended", "label.this_stream_has_ended": "This stream has ended", "label.an_exploit_has_removed_available_rewards": "An exploit has removed available rewards from this pool. Please refer to", diff --git a/lang/es.json b/lang/es.json index 552767ed6b..36c21db30e 100644 --- a/lang/es.json +++ b/lang/es.json @@ -728,6 +728,7 @@ "label.you_are_currently_connected_to": "", "label.switch_to": "", "label.to_interact_with_this_farm": "", + "label.please_connect_your_wallet": "", "label.this_farm_has_ended": "", "label.this_stream_has_ended": "", "label.an_exploit_has_removed_available_rewards": "", diff --git a/src/components/ArchiveAndNetworkCover/ArchiveAndNetworkCover.tsx b/src/components/ArchiveAndNetworkCover/ArchiveAndNetworkCover.tsx index fca5045671..94e95a514b 100644 --- a/src/components/ArchiveAndNetworkCover/ArchiveAndNetworkCover.tsx +++ b/src/components/ArchiveAndNetworkCover/ArchiveAndNetworkCover.tsx @@ -18,7 +18,7 @@ export const ArchiveAndNetworkCover: FC = ({ }) => { const { chainId } = useWeb3React(); - return chainId !== targetNetwork ? ( + return chainId === undefined || chainId !== targetNetwork ? ( ) : isArchived || isExploited ? ( diff --git a/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx b/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx index 34f4259ae1..bb2d322829 100644 --- a/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx +++ b/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx @@ -21,17 +21,25 @@ export const WrongNetworkCover: FC = ({ - - {formatMessage({ - id: 'label.you_are_currently_connected_to', - })}{' '} - {chainName(chainId || 0)}{' '} - {formatMessage({ id: 'label.switch_to' })}{' '} - {chainName(targetNetwork || 0)}{' '} - {formatMessage({ - id: 'label.to_interact_with_this_farm', - })} - + {chainId !== undefined ? ( + + {formatMessage({ + id: 'label.you_are_currently_connected_to', + })}{' '} + {chainName(chainId || 0)}{' '} + {formatMessage({ id: 'label.switch_to' })}{' '} + {chainName(targetNetwork || 0)}{' '} + {formatMessage({ + id: 'label.to_interact_with_this_farm', + })} + + ) : ( + + {formatMessage({ + id: 'label.please_connect_your_wallet', + })} + + )} ) : null; }; From 407f34e57beb45c798e0a8fe5b68c93d5733b992 Mon Sep 17 00:00:00 2001 From: Cherik Date: Sun, 12 Mar 2023 13:14:00 +0330 Subject: [PATCH 138/163] fix formatMessage usage --- lang/en.json | 7 +++---- lang/es.json | 3 +-- .../WrongNetworkCover.tsx | 18 +++++++++--------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lang/en.json b/lang/en.json index 0ea17f7f02..1ed024764e 100644 --- a/lang/en.json +++ b/lang/en.json @@ -728,10 +728,9 @@ "label.bridge_your_giv": "Bridge your GIV", "label.contract": "Contract", "label.switch_to_archive_cards": "Switch to Archive Cards", - "label.you_are_currently_connected_to": "You are currently connected to", - "label.switch_to": "switch to", - "label.to_interact_with_this_farm": "to interact with this farm.", - "label.please_connect_your_wallet": "Please Connect your wallet", + "label.wrong_network": "You are currently connected to {chainName} switch to {targetChain} to interact with this farm.", + "label.switch_to": "", + "label.please_connect_your_wallet": "Please connect your wallet", "label.this_farm_has_ended": "This farm has ended", "label.this_stream_has_ended": "This stream has ended", "label.an_exploit_has_removed_available_rewards": "An exploit has removed available rewards from this pool. Please refer to", diff --git a/lang/es.json b/lang/es.json index 36c21db30e..0955f8f71f 100644 --- a/lang/es.json +++ b/lang/es.json @@ -725,9 +725,8 @@ "label.bridge_your_giv": "", "label.contract": "Contrato", "label.switch_to_archive_cards": "", - "label.you_are_currently_connected_to": "", + "label.wrong_network": "", "label.switch_to": "", - "label.to_interact_with_this_farm": "", "label.please_connect_your_wallet": "", "label.this_farm_has_ended": "", "label.this_stream_has_ended": "", diff --git a/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx b/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx index bb2d322829..a9c7c21198 100644 --- a/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx +++ b/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx @@ -23,15 +23,15 @@ export const WrongNetworkCover: FC = ({ {chainId !== undefined ? ( - {formatMessage({ - id: 'label.you_are_currently_connected_to', - })}{' '} - {chainName(chainId || 0)}{' '} - {formatMessage({ id: 'label.switch_to' })}{' '} - {chainName(targetNetwork || 0)}{' '} - {formatMessage({ - id: 'label.to_interact_with_this_farm', - })} + {formatMessage( + { + id: 'label.wrong_network', + }, + { + chainName: chainName(chainId || 0), + targetChain: chainName(targetNetwork || 0), + }, + )} ) : ( From 68492cb5f52f072dc6ff8efb215e604629ad0074 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 20 Mar 2023 17:24:17 +0330 Subject: [PATCH 139/163] comment GIV / ETH v3 --- src/config/production.ts | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/config/production.ts b/src/config/production.ts index 4f07713802..ea6c139265 100644 --- a/src/config/production.ts +++ b/src/config/production.ts @@ -119,30 +119,30 @@ const config: EnvConfig = { exploited: true, farmEndTimeMS: 1660946400000, }, - { - network: MAINNET_NETWORK_NUMBER, - INCENTIVE_START_TIME: 1640361600, - INCENTIVE_END_TIME: 1656086400, - INCENTIVE_REWARD_AMOUNT: 10000000, - NFT_POSITIONS_MANAGER_ADDRESS: - '0xC36442b4a4522E871399CD717aBDD847Ab11FE88', - UNISWAP_V3_STAKER: '0x1f98407aaB862CdDeF78Ed252D6f557aA5b0f00d', - STAKING_REWARDS_CONTRACT: - '0x79A7CAD3Ac4554C133dCaaa9Bc3319385Eb7FD5D', - REWARD_TOKEN: '0x3115e5aAa3D6f742d09fbB649150dfE285a9c2A3', - UNISWAP_V3_LP_POOL: - '0xc763b6b3d0f75167db95daa6a0a0d75dd467c4e1', - INCENTIVE_REFUNDEE_ADDRESS: - '0x34d27210cC319EC5281bDc4DC2ad8FbcF4EAEAEB', - type: StakingType.UNISWAPV3_ETH_GIV, - platform: StakingPlatform.UNISWAP, - title: 'GIV / ETH', - description: '0.3% tier only', - provideLiquidityLink: `https://app.uniswap.org/#/add/ETH/0x900dB999074d9277c5DA2A43F252D74366230DA0/3000`, - unit: 'NFT', - infinitePositionId: 193935, - farmEndTimeMS: 1660946400000, - }, + // { + // network: MAINNET_NETWORK_NUMBER, + // INCENTIVE_START_TIME: 1640361600, + // INCENTIVE_END_TIME: 1656086400, + // INCENTIVE_REWARD_AMOUNT: 10000000, + // NFT_POSITIONS_MANAGER_ADDRESS: + // '0xC36442b4a4522E871399CD717aBDD847Ab11FE88', + // UNISWAP_V3_STAKER: '0x1f98407aaB862CdDeF78Ed252D6f557aA5b0f00d', + // STAKING_REWARDS_CONTRACT: + // '0x79A7CAD3Ac4554C133dCaaa9Bc3319385Eb7FD5D', + // REWARD_TOKEN: '0x3115e5aAa3D6f742d09fbB649150dfE285a9c2A3', + // UNISWAP_V3_LP_POOL: + // '0xc763b6b3d0f75167db95daa6a0a0d75dd467c4e1', + // INCENTIVE_REFUNDEE_ADDRESS: + // '0x34d27210cC319EC5281bDc4DC2ad8FbcF4EAEAEB', + // type: StakingType.UNISWAPV3_ETH_GIV, + // platform: StakingPlatform.UNISWAP, + // title: 'GIV / ETH', + // description: '0.3% tier only', + // provideLiquidityLink: `https://app.uniswap.org/#/add/ETH/0x900dB999074d9277c5DA2A43F252D74366230DA0/3000`, + // unit: 'NFT', + // infinitePositionId: 193935, + // farmEndTimeMS: 1660946400000, + // }, ], regenPools: [ { From e74993ec7afa9c82dfa35637add64ded129095be Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 20 Mar 2023 19:59:55 +0330 Subject: [PATCH 140/163] change cover background --- src/components/ArchiveAndNetworkCover/common.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/ArchiveAndNetworkCover/common.ts b/src/components/ArchiveAndNetworkCover/common.ts index 8084c2eeb9..4456666912 100644 --- a/src/components/ArchiveAndNetworkCover/common.ts +++ b/src/components/ArchiveAndNetworkCover/common.ts @@ -1,4 +1,3 @@ -import { brandColors } from '@giveth/ui-design-system'; import styled from 'styled-components'; import { FlexCenter } from '../styled-components/Flex'; @@ -11,7 +10,11 @@ export const Cover = styled(FlexCenter)` left: 0; right: 0; padding: 24px; - background: ${brandColors.giv[900]}dd; + background: linear-gradient( + 180deg, + rgba(56, 17, 191, 0) 32.57%, + rgba(26, 4, 102, 0.9) 84.84% + ); z-index: 2; gap: 16px; `; From 6c2aedaed1e5b2d78c7aa77088ed52e157d56a3d Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 20 Mar 2023 20:26:08 +0330 Subject: [PATCH 141/163] change cover background --- src/components/ArchiveAndNetworkCover/common.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ArchiveAndNetworkCover/common.ts b/src/components/ArchiveAndNetworkCover/common.ts index 4456666912..02dcf45a3c 100644 --- a/src/components/ArchiveAndNetworkCover/common.ts +++ b/src/components/ArchiveAndNetworkCover/common.ts @@ -12,8 +12,8 @@ export const Cover = styled(FlexCenter)` padding: 24px; background: linear-gradient( 180deg, - rgba(56, 17, 191, 0) 32.57%, - rgba(26, 4, 102, 0.9) 84.84% + rgba(56, 17, 191, 0) 30%, + rgba(26, 4, 102, 1) 80% ); z-index: 2; gap: 16px; From 0f081f13d41aec7f108cbb1ea333eebc03dadf28 Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 20 Mar 2023 20:26:14 +0330 Subject: [PATCH 142/163] fix styles --- .../WrongNetworkCover.tsx | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx b/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx index a9c7c21198..3ce7dd27a5 100644 --- a/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx +++ b/src/components/ArchiveAndNetworkCover/WrongNetworkCover.tsx @@ -5,6 +5,7 @@ import { useIntl } from 'react-intl'; import styled from 'styled-components'; import { chainName } from '@/lib/constants/constants'; import { Cover } from './common'; +import { Flex } from '../styled-components/Flex'; interface IWrongNetworkCoverProps { targetNetwork: number; @@ -17,33 +18,39 @@ export const WrongNetworkCover: FC = ({ const { chainId } = useWeb3React(); return targetNetwork !== chainId ? ( - - - - - {chainId !== undefined ? ( - - {formatMessage( - { - id: 'label.wrong_network', - }, - { - chainName: chainName(chainId || 0), - targetChain: chainName(targetNetwork || 0), - }, - )} - - ) : ( - - {formatMessage({ - id: 'label.please_connect_your_wallet', - })} - - )} - + + + + + + {chainId !== undefined ? ( + + {formatMessage( + { + id: 'label.wrong_network', + }, + { + chainName: chainName(chainId || 0), + targetChain: chainName(targetNetwork || 0), + }, + )} + + ) : ( + + {formatMessage({ + id: 'label.please_connect_your_wallet', + })} + + )} + + ) : null; }; +const StyledCover = styled(Cover)` + align-items: flex-end; +`; + const IconWrapper = styled.div` width: 16px; height: 16px; @@ -51,4 +58,5 @@ const IconWrapper = styled.div` const Content = styled(Caption)` max-width: 320px; + margin-bottom: 36px; `; From 34a4a127222f5a9a332ba38347c22570e67add5c Mon Sep 17 00:00:00 2001 From: Cherik Date: Mon, 20 Mar 2023 20:37:53 +0330 Subject: [PATCH 143/163] add switch_to --- lang/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en.json b/lang/en.json index 375fbd6eb6..dddf90b93d 100644 --- a/lang/en.json +++ b/lang/en.json @@ -698,7 +698,7 @@ "label.contract": "Contract", "label.switch_to_archive_cards": "Switch to Archive Cards", "label.wrong_network": "You are currently connected to {chainName} switch to {targetChain} to interact with this farm.", - "label.switch_to": "", + "label.switch_to": "switch to", "label.please_connect_your_wallet": "Please connect your wallet", "label.this_farm_has_ended": "This farm has ended", "label.this_stream_has_ended": "This stream has ended", From 33b8b1640c300499627f03ef6ea29919bdbe1710 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 22 Mar 2023 11:34:23 +0330 Subject: [PATCH 144/163] use BaseStakingCard instead of StakingCard --- .../cards/StakingCards/StakingPoolCard.tsx | 15 --------------- src/components/views/givfarm/GIVfarmBottom.tsx | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) delete mode 100644 src/components/cards/StakingCards/StakingPoolCard.tsx diff --git a/src/components/cards/StakingCards/StakingPoolCard.tsx b/src/components/cards/StakingCards/StakingPoolCard.tsx deleted file mode 100644 index fa1ea23914..0000000000 --- a/src/components/cards/StakingCards/StakingPoolCard.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import BaseStakingCard from './BaseStakingCard/BaseStakingCard'; -import type { - RegenPoolStakingConfig, - SimplePoolStakingConfig, -} from '@/types/config'; -import type { FC } from 'react'; -interface IStakingPoolCardProps { - poolStakingConfig: SimplePoolStakingConfig | RegenPoolStakingConfig; -} - -const StakingPoolCard: FC = ({ poolStakingConfig }) => { - return ; -}; - -export default StakingPoolCard; diff --git a/src/components/views/givfarm/GIVfarmBottom.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx index 2c0f40c639..2300ce4085 100644 --- a/src/components/views/givfarm/GIVfarmBottom.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -23,7 +23,7 @@ import { Col, Container } from '@/components/Grid'; import { DaoCard } from '../../givfarm/DaoCard'; import { getNowUnixMS } from '@/helpers/time'; import { TWO_WEEK } from '@/lib/constants/constants'; -import StakingPoolCard from '../../cards/StakingCards/StakingPoolCard'; +import StakingPoolCard from '@/components/cards/StakingCards/BaseStakingCard/BaseStakingCard'; import { RegenStreamSection } from '@/components/givfarm/RegenStreamSection'; import ToggleSwitch from '@/components/styled-components/Switch'; From aa5f9f89f8911839acd0568f22182d100b0bcebc Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 22 Mar 2023 11:47:08 +0330 Subject: [PATCH 145/163] fix import --- src/helpers/blockchain.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/blockchain.ts b/src/helpers/blockchain.ts index f060b8667a..79f8bcb970 100644 --- a/src/helpers/blockchain.ts +++ b/src/helpers/blockchain.ts @@ -1,4 +1,4 @@ -import { ethers } from 'ethers'; +import { parseUnits } from '@ethersproject/units'; export interface INetworkParam { chainId: string; @@ -94,4 +94,4 @@ export const networksParams: { }; export const gwei2wei = (gweiAmount: string): string => - ethers.utils.parseUnits(gweiAmount, 'gwei').toString(); + parseUnits(gweiAmount, 'gwei').toString(); From a54b066483b8103a4bcf8bfcd4e4addeb6a896a2 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 22 Mar 2023 11:47:37 +0330 Subject: [PATCH 146/163] move getPoolIconWithName to platform helper --- .../BaseStakingCard/BaseStakingCard.tsx | 40 ------------------ src/helpers/platform.tsx | 41 +++++++++++++++++++ 2 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 src/helpers/platform.tsx diff --git a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx index 83ab698f9d..8e64256469 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/BaseStakingCard.tsx @@ -1,9 +1,7 @@ import React, { FC, ReactNode, useState } from 'react'; -import { useWeb3React } from '@web3-react/core'; import { PoolStakingConfig, RegenPoolStakingConfig, - StakingPlatform, StakingType, } from '@/types/config'; import { @@ -14,14 +12,6 @@ import { } from './BaseStakingCard.sc'; import config from '@/configuration'; -import { IconAngelVault } from '@/components/Icons/AngelVault'; -import { IconBalancer } from '@/components/Icons/Balancer'; -import { IconEthereum } from '@/components/Icons/Eth'; -import { IconGIV } from '@/components/Icons/GIV'; -import { IconGnosisChain } from '@/components/Icons/GnosisChain'; -import { IconHoneyswap } from '@/components/Icons/Honeyswap'; -import { IconSushiswap } from '@/components/Icons/Sushiswap'; -import { IconUniswap } from '@/components/Icons/Uniswap'; import { GIVPowerExplainModal } from '@/components/modals/GIVPowerExplain'; import { StakingPoolImages } from '@/components/StakingPoolImages'; import GIVpowerCardIntro from '../GIVpowerCard/GIVpowerCardIntro'; @@ -38,34 +28,6 @@ export enum StakeCardState { GIVPOWER_INTRO, } -export const getPoolIconWithName = ( - platform: StakingPlatform, - poolNetwork?: number, -) => { - switch (poolNetwork) { - case config.MAINNET_NETWORK_NUMBER: - return ; - case config.XDAI_NETWORK_NUMBER: - return ; - } - // if no number is set then it defaults to platform icon - switch (platform) { - case StakingPlatform.BALANCER: - return ; - case StakingPlatform.GIVETH: - return ; - case StakingPlatform.HONEYSWAP: - return ; - case StakingPlatform.UNISWAP: - return ; - case StakingPlatform.SUSHISWAP: - return ; - case StakingPlatform.ICHI: - return ; - default: - break; - } -}; interface IBaseStakingCardProps { poolStakingConfig: PoolStakingConfig | RegenPoolStakingConfig; notif?: ReactNode; @@ -86,8 +48,6 @@ const BaseStakingCard: FC = ({ const [state, setState] = useState(StakeCardState.NORMAL); const [showGIVPowerExplain, setShowGIVPowerExplain] = useState(false); - const { chainId } = useWeb3React(); - const { type, title, diff --git a/src/helpers/platform.tsx b/src/helpers/platform.tsx new file mode 100644 index 0000000000..b45134c129 --- /dev/null +++ b/src/helpers/platform.tsx @@ -0,0 +1,41 @@ +import React from 'react'; +import { StakingPlatform } from '@/types/config'; + +import config from '@/configuration'; +import { IconAngelVault } from '@/components/Icons/AngelVault'; +import { IconBalancer } from '@/components/Icons/Balancer'; +import { IconEthereum } from '@/components/Icons/Eth'; +import { IconGIV } from '@/components/Icons/GIV'; +import { IconGnosisChain } from '@/components/Icons/GnosisChain'; +import { IconHoneyswap } from '@/components/Icons/Honeyswap'; +import { IconSushiswap } from '@/components/Icons/Sushiswap'; +import { IconUniswap } from '@/components/Icons/Uniswap'; + +export const getPoolIconWithName = ( + platform: StakingPlatform, + poolNetwork?: number, +) => { + switch (poolNetwork) { + case config.MAINNET_NETWORK_NUMBER: + return ; + case config.XDAI_NETWORK_NUMBER: + return ; + } + // if no number is set then it defaults to platform icon + switch (platform) { + case StakingPlatform.BALANCER: + return ; + case StakingPlatform.GIVETH: + return ; + case StakingPlatform.HONEYSWAP: + return ; + case StakingPlatform.UNISWAP: + return ; + case StakingPlatform.SUSHISWAP: + return ; + case StakingPlatform.ICHI: + return ; + default: + break; + } +}; From 5b842040f4bb722097db43cf4775170d438497d1 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 22 Mar 2023 11:48:31 +0330 Subject: [PATCH 147/163] remove getPoolIconWithName from StakingCardHeader --- .../cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx index 8c8200f2db..21205dfcee 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx @@ -8,7 +8,7 @@ import { useIntl } from 'react-intl'; import { IconWithTooltip } from '@/components/IconWithToolTip'; import { FlexSpacer } from '@/components/styled-components/Flex'; import { PoolStakingConfig, StakingType } from '@/types/config'; -import { getPoolIconWithName, StakeCardState } from './BaseStakingCard'; +import { StakeCardState } from './BaseStakingCard'; import { StakingPoolExchangeRow, StakingPoolExchange, @@ -42,7 +42,6 @@ export const StakingCardHeader: FC = ({ return ( - {getPoolIconWithName(platform, poolNetwork)} {platformTitle || platform} From 24ea4c8281e1115f58f6521727e06403d55b5d57 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 22 Mar 2023 11:48:54 +0330 Subject: [PATCH 148/163] fix import --- src/components/modals/HarvestAll.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/modals/HarvestAll.tsx b/src/components/modals/HarvestAll.tsx index 6597c994b7..e1c162e966 100644 --- a/src/components/modals/HarvestAll.tsx +++ b/src/components/modals/HarvestAll.tsx @@ -72,7 +72,7 @@ import { LiquidityPosition } from '@/types/nfts'; import { Flex } from '../styled-components/Flex'; import { useModalAnimation } from '@/hooks/useModalAnimation'; import LottieControl from '@/components/LottieControl'; -import { getPoolIconWithName } from '../cards/StakingCards/BaseStakingCard/BaseStakingCard'; +import { getPoolIconWithName } from '@/helpers/platform'; import { useTokenDistroHelper } from '@/hooks/useTokenDistroHelper'; import { useStakingPool } from '@/hooks/useStakingPool'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; From 8f0bacb46f341e28d8d77301eaa1358a2d54f622 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 22 Mar 2023 11:57:51 +0330 Subject: [PATCH 149/163] fix titles --- .../BaseStakingCard/StakingCardHeader.tsx | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx index 21205dfcee..74be331695 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingCardHeader.tsx @@ -7,7 +7,11 @@ import { Dispatch, FC, ReactNode, SetStateAction } from 'react'; import { useIntl } from 'react-intl'; import { IconWithTooltip } from '@/components/IconWithToolTip'; import { FlexSpacer } from '@/components/styled-components/Flex'; -import { PoolStakingConfig, StakingType } from '@/types/config'; +import { + PoolStakingConfig, + RegenPoolStakingConfig, + StakingType, +} from '@/types/config'; import { StakeCardState } from './BaseStakingCard'; import { StakingPoolExchangeRow, @@ -32,18 +36,17 @@ export const StakingCardHeader: FC = ({ }) => { const { formatMessage } = useIntl(); - const { - type, - platform, - platformTitle, - introCard, - network: poolNetwork, - } = poolStakingConfig; + const { type, introCard, network: poolNetwork } = poolStakingConfig; + const { regenStreamType } = poolStakingConfig as RegenPoolStakingConfig; return ( - {platformTitle || platform} + {regenStreamType + ? 'REGENFARM' + : isGIVpower + ? 'GIVPOWER' + : 'GIVFARM'} {poolNetwork === config.XDAI_NETWORK_NUMBER && type === StakingType.GIV_LM && ( From 1e68d78de2fd063da661fbc7004b637115a796fd Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 22 Mar 2023 12:30:52 +0330 Subject: [PATCH 150/163] remove RegenFarm component --- src/components/RegenFarm.tsx | 95 ------------------------------------ 1 file changed, 95 deletions(-) delete mode 100644 src/components/RegenFarm.tsx diff --git a/src/components/RegenFarm.tsx b/src/components/RegenFarm.tsx deleted file mode 100644 index 3dc817cf44..0000000000 --- a/src/components/RegenFarm.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import React, { FC } from 'react'; -import { useWeb3React } from '@web3-react/core'; -import { H4 } from '@giveth/ui-design-system'; -import styled from 'styled-components'; -import { Row, Col } from '@giveth/ui-design-system'; -import { - givEconomySupportedNetworks, - regenFarmStreamCardCol, - TWO_WEEK, -} from '@/lib/constants/constants'; -import StakingPoolCard from './cards/StakingPoolCard'; -import { PoolRow } from './homeTabs/GIVfarm.sc'; -import config from '@/configuration'; -import { RegenFarmConfig } from '@/types/config'; -import { DAOChangeNetworkModal } from './DAOChangeNetworkModal'; -import { DAOContainer, DAOChangeNetwork } from './givfarm/GIVfrens.sc'; -import { RegenStreamCard } from './givfarm/RegenStreamCard'; -import { getNowUnixMS } from '@/helpers/time'; - -interface IRegenFarmProps { - regenFarm: RegenFarmConfig; - showArchivedPools: boolean; -} - -export const RegenFarm: FC = ({ - regenFarm, - showArchivedPools, -}) => { - const { chainId } = useWeb3React(); - const { pools } = regenFarm; - - const now = getNowUnixMS(); - - const filteredPools = showArchivedPools - ? pools - : pools.filter( - pool => - !( - pool.farmEndTimeMS && - now > pool.farmEndTimeMS + TWO_WEEK - ) || pool.dontArchive, - ); - - if (filteredPools.length === 0) return null; - - return ( - - - {regenFarm.title} - - {filteredPools.map((poolStakingConfig, idx) => ( - - - - ))} - - {regenFarm && ( - - )} - - - {chainId !== config.MAINNET_NETWORK_NUMBER && - chainId !== config.XDAI_NETWORK_NUMBER && ( - <> - - - - )} - - - ); -}; - -const DaoTitle = styled(H4)` - margin-top: 32px; - margin-bottom: 24px; -`; From a298cb165a3293542460d63fae07b478440a7430 Mon Sep 17 00:00:00 2001 From: Cherik Date: Wed, 22 Mar 2023 12:55:39 +0330 Subject: [PATCH 151/163] fix build issue --- src/components/givfarm/RegenStreamSection.tsx | 3 +-- src/components/views/givfarm/GIVfarmBottom.tsx | 9 +++++++-- src/components/views/givfarm/GIVfarmTop.tsx | 3 +-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/components/givfarm/RegenStreamSection.tsx b/src/components/givfarm/RegenStreamSection.tsx index 4325e96b33..ff306d4f06 100644 --- a/src/components/givfarm/RegenStreamSection.tsx +++ b/src/components/givfarm/RegenStreamSection.tsx @@ -1,8 +1,7 @@ import React, { FC } from 'react'; -import { H3 } from '@giveth/ui-design-system'; +import { Col, H3, Row } from '@giveth/ui-design-system'; import { useWeb3React } from '@web3-react/core'; import { useIntl } from 'react-intl'; -import { Col, Row } from '../Grid'; import { Subtitle, GIVfrensLink } from './RegenStreamSection.sc'; import config from '@/configuration'; import { RegenStreamCard } from './RegenStreamCard'; diff --git a/src/components/views/givfarm/GIVfarmBottom.tsx b/src/components/views/givfarm/GIVfarmBottom.tsx index 2300ce4085..9f9a5ad2ea 100644 --- a/src/components/views/givfarm/GIVfarmBottom.tsx +++ b/src/components/views/givfarm/GIVfarmBottom.tsx @@ -1,5 +1,11 @@ import React, { useState } from 'react'; -import { IconExternalLink, GLink, IconCopy } from '@giveth/ui-design-system'; +import { + IconExternalLink, + GLink, + IconCopy, + Col, + Container, +} from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; import { useWeb3React } from '@web3-react/core'; import config from '@/configuration'; @@ -18,7 +24,6 @@ import { NetworkSelector } from '@/components/NetworkSelector'; import { getGivStakingConfig } from '@/helpers/networkProvider'; import { ExtLinkRow } from '../../GIVeconomyPages/commons'; import { shortenAddress } from '@/lib/helpers'; -import { Col, Container } from '@/components/Grid'; import { DaoCard } from '../../givfarm/DaoCard'; import { getNowUnixMS } from '@/helpers/time'; diff --git a/src/components/views/givfarm/GIVfarmTop.tsx b/src/components/views/givfarm/GIVfarmTop.tsx index 7a6b6edf3d..e879991d7d 100644 --- a/src/components/views/givfarm/GIVfarmTop.tsx +++ b/src/components/views/givfarm/GIVfarmTop.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react'; -import { IconGIVFarm } from '@giveth/ui-design-system'; +import { Col, IconGIVFarm, Row } from '@giveth/ui-design-system'; import { useIntl } from 'react-intl'; import { BigNumber } from 'bignumber.js'; import { constants } from 'ethers'; @@ -16,7 +16,6 @@ import { import useGIVTokenDistroHelper from '@/hooks/useGIVTokenDistroHelper'; import { useFarms } from '@/context/farm.context'; import { TopInnerContainer } from '../../GIVeconomyPages/commons'; -import { Col, Row } from '@/components/Grid'; export const GIVfarmTop = () => { const { formatMessage } = useIntl(); From 05b7361a5f1ffeb70f6ea79e806f3300ee96a920 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 16:22:23 +0330 Subject: [PATCH 152/163] use getUserClaimableNow instead --- src/components/givfarm/RegenStreamCard.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 495082c8a5..b22ed5b104 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -122,14 +122,12 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { useEffect(() => { setRewardLiquidPart( - regenTokenDistroHelper - .getLiquidPart(lockedAmount) - .sub(claimedAmount), + regenTokenDistroHelper.getUserClaimableNow(tokenDistroBalance), ); setRewardStream( regenTokenDistroHelper.getStreamPartTokenPerWeek(lockedAmount), ); - }, [claimedAmount, lockedAmount, regenTokenDistroHelper]); + }, [lockedAmount, regenTokenDistroHelper, tokenDistroBalance]); const percentage = regenTokenDistroHelper?.GlobalReleasePercentage || 0; const remainTime = durationToString(regenTokenDistroHelper?.remain || 0); From 2adb213c28f66ce0d2b13b1b1fae4796fda1b23b Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 16:23:01 +0330 Subject: [PATCH 153/163] remove regenStreamType from useTokenDistroHelper --- .../BaseStakingCard/StakingPoolInfoAndActions.tsx | 1 - src/components/modals/APR.tsx | 1 - src/components/modals/HarvestAll.tsx | 4 ---- src/hooks/useTokenDistroHelper.tsx | 7 +++---- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index 49fb3c8efc..342a1c327c 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -124,7 +124,6 @@ export const StakingPoolInfoAndActions: FC = ({ const { tokenDistroHelper, sdh } = useTokenDistroHelper( poolNetwork, - regenStreamType, regenStreamConfig, hold, ); diff --git a/src/components/modals/APR.tsx b/src/components/modals/APR.tsx index d728385218..44f710dc0c 100644 --- a/src/components/modals/APR.tsx +++ b/src/components/modals/APR.tsx @@ -77,7 +77,6 @@ const Content: FC = ({ }) => { const { tokenDistroHelper } = useTokenDistroHelper( poolNetwork, - regenStreamType, regenStreamConfig, ); const streamName = regenStreamConfig ? 'RegenStream' : 'GIVstream'; diff --git a/src/components/modals/HarvestAll.tsx b/src/components/modals/HarvestAll.tsx index e1c162e966..82958a2e49 100644 --- a/src/components/modals/HarvestAll.tsx +++ b/src/components/modals/HarvestAll.tsx @@ -27,7 +27,6 @@ import { PoolStakingConfig, RegenStreamConfig, SimplePoolStakingConfig, - StreamType, } from '@/types/config'; import { BN, formatWeiHelper, Zero } from '@/helpers/number'; import { harvestTokens } from '@/lib/stakingPool'; @@ -81,7 +80,6 @@ interface IHarvestAllInnerModalProps { title: string; poolStakingConfig?: PoolStakingConfig; regenStreamConfig?: RegenStreamConfig; - regenStreamType?: StreamType; stakedPositions?: LiquidityPosition[]; currentIncentive?: { key?: (string | number)[] | null | undefined; @@ -103,7 +101,6 @@ export const HarvestAllModal: FC = ({ setShowModal, poolStakingConfig, regenStreamConfig, - regenStreamType, stakedPositions, currentIncentive, }) => { @@ -136,7 +133,6 @@ export const HarvestAllModal: FC = ({ const { chainId } = useWeb3React(); const { tokenDistroHelper, sdh } = useTokenDistroHelper( chainId!, - regenStreamType, regenStreamConfig, ); diff --git a/src/hooks/useTokenDistroHelper.tsx b/src/hooks/useTokenDistroHelper.tsx index 56a5eaa582..9c2d498774 100644 --- a/src/hooks/useTokenDistroHelper.tsx +++ b/src/hooks/useTokenDistroHelper.tsx @@ -2,12 +2,11 @@ import { useState, useEffect } from 'react'; import { TokenDistroHelper } from '@/lib/contractHelper/TokenDistroHelper'; import { SubgraphDataHelper } from '@/lib/subgraph/subgraphDataHelper'; import config from '@/configuration'; -import { StreamType, RegenStreamConfig } from '@/types/config'; +import { RegenStreamConfig } from '@/types/config'; import { useAppSelector } from '@/features/hooks'; export const useTokenDistroHelper = ( poolNetwork: number, - regenStreamType?: StreamType, regenStreamConfig?: RegenStreamConfig, hold: boolean = false, ) => { @@ -24,7 +23,7 @@ export const useTokenDistroHelper = ( const sdh = new SubgraphDataHelper(currentValues); useEffect(() => { - if (regenStreamType) { + if (regenStreamConfig) { setTokenDistroHelper( new TokenDistroHelper( sdh.getTokenDistro( @@ -37,6 +36,6 @@ export const useTokenDistroHelper = ( new TokenDistroHelper(sdh.getGIVTokenDistro()), ); } - }, [currentValues, regenStreamConfig, regenStreamType]); + }, [currentValues, regenStreamConfig]); return { tokenDistroHelper, sdh }; }; From 533f6fcb4523975583f1e0aec2a9596cd9aaea50 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 16:52:56 +0330 Subject: [PATCH 154/163] fix showing data on wrong network for RegenStreamCard --- src/components/givfarm/RegenStreamCard.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index b22ed5b104..20195799ff 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -65,11 +65,6 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { ); const { chainId } = useWeb3React(); - const currentValues = useAppSelector( - state => state.subgraph.currentValues, - () => (showModal ? true : false), - ); - const { title, tokenDistroAddress, @@ -80,6 +75,14 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { archived, } = streamConfig; + const currentValues = useAppSelector( + state => + streamNetwork === config.XDAI_NETWORK_NUMBER + ? state.subgraph.xDaiValues + : state.subgraph.mainnetValues, + () => (showModal ? true : false), + ); + const { regenTokenDistroHelper, tokenDistroBalance } = useMemo(() => { const sdh = new SubgraphDataHelper(currentValues); const tokenDistroBalance = From d0f7fb666e7e6eedcc5bce05ab6cb95d5d29ffc7 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 16:54:59 +0330 Subject: [PATCH 155/163] update archived copy --- lang/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang/en.json b/lang/en.json index ae1946541b..1dc6342b11 100644 --- a/lang/en.json +++ b/lang/en.json @@ -945,7 +945,7 @@ "label.your_donations_and_participation_in_the_giveconomy": "Your donations, and participation in the GIVeconomy, enables us to build a new future where real world impact projects benefit from their own community-driven regenerative economies.", "label.discover_our_roadmap": "discover our roadmap", "label.more_about_us": "More about us", - "component.archive_cover.archived": "ARCHIVED!!", + "component.archive_cover.archived": "ARCHIVED", "modal.news_letter": "Newsletter sign up", "section.we_wont_send_it": "We won’t send it every 5 second! Promise :)", "section.subscribe_to_our_newsletter": "Subscribe to our newsletter and get all updates straight to your mailbox!", From c0b8492f4dfc6d782849cf7186a5d9c95179cbd7 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 16:59:05 +0330 Subject: [PATCH 156/163] update harvest caption copy --- lang/en.json | 3 ++- lang/es.json | 3 ++- src/components/givfarm/RegenStreamCard.tsx | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lang/en.json b/lang/en.json index 1dc6342b11..3e2d19a084 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1227,5 +1227,6 @@ "label.coming_soon": "Coming soon...", "label.getting_started": "Getting Started", "label.the_mt_pelerin_onramp_allows_you_to_use_a_credit_card_or_bank_transfer": "The Mt Pelerin 'onramp' allows you to use a credit card or bank transfer to get crypto in your web3 wallet to donate. First, select the method of payment (bank transfer or credit card), and then select the currency you want to use to purchase crypto. Then, select the crypto currency you wish to purchase. The currency xDAI and network Gnosis Chain will be selected by default. Finally, click 'Buy'.", - "label.you_can_wait_on_this_page_until_the_payment_goes_through": "You can wait on this page until the payment goes through, or you can close it. If the payment is successful, the funds will automatically appear in your chosen wallet after some time. Note: If you click 'Close', you will be redirected back to the start and will not get to the next page." + "label.you_can_wait_on_this_page_until_the_payment_goes_through": "You can wait on this page until the payment goes through, or you can close it. If the payment is successful, the funds will automatically appear in your chosen wallet after some time. Note: If you click 'Close', you will be redirected back to the start and will not get to the next page.", + "component.regenstream_card.harvest_caption": "Use the Harvest button to claim liquid rewards from this RegenStream" } diff --git a/lang/es.json b/lang/es.json index 36949abf14..c046c3bc75 100644 --- a/lang/es.json +++ b/lang/es.json @@ -1237,5 +1237,6 @@ "label.donate_with_email": "Dona con un email", "label.you_can_wait_on_this_page_until_the_payment_goes_through": "Puedes esperar en esta página mientras el pago se procesa, o puedes cerrarla. Si el pago es exitoso, los fondos aparecerán automáticamente en tu billetera luego de un tiempo. Nota: Si presionas 'Close', serás redirigído al inicio y no a la siguiente página.", "label.mtpelerin_pricing_starts_at_zero": "La tarifa de MtPelerin comienza en 0%, ¡muy difícil de superar! En general, tratamos de mantener nuestra estructura de precios lo más atractiva, simple y transparente posible. Damos al usuario la mejor tasa de cambio que podemos encontrar como comerciantes profesionales en el mercado. Cobramos un pequeño porcentaje a esa tarifa cuando se superan los $500 por año, por debajo de eso no cobramos nada.", - "label.the_mt_pelerin_onramp_allows_you_to_use_a_credit_card_or_bank_transfer": "El 'ramp' de Mt Pelerin te permite usar una tarjeta de crédito o transferencia bancaria para obtener cripto en tu billetera web3 para donar. Primero, seleccione el método de pago (transferencia bancaria o tarjeta de crédito) y luego seleccione la moneda que desea usar para comprar criptomonedas. Luego, seleccione la cripto que desea comprar. xDAI y la red Gnosis Chain estarán seleccionadas por defecto. Finalmente, haga clic en 'Buy'." + "label.the_mt_pelerin_onramp_allows_you_to_use_a_credit_card_or_bank_transfer": "El 'ramp' de Mt Pelerin te permite usar una tarjeta de crédito o transferencia bancaria para obtener cripto en tu billetera web3 para donar. Primero, seleccione el método de pago (transferencia bancaria o tarjeta de crédito) y luego seleccione la moneda que desea usar para comprar criptomonedas. Luego, seleccione la cripto que desea comprar. xDAI y la red Gnosis Chain estarán seleccionadas por defecto. Finalmente, haga clic en 'Buy'.", + "component.regenstream_card.harvest_caption": "" } diff --git a/src/components/givfarm/RegenStreamCard.tsx b/src/components/givfarm/RegenStreamCard.tsx index 20195799ff..0fa4dd15da 100644 --- a/src/components/givfarm/RegenStreamCard.tsx +++ b/src/components/givfarm/RegenStreamCard.tsx @@ -225,8 +225,9 @@ export const RegenStreamCard: FC = ({ streamConfig }) => { - Use the Harvest button harvest this liquid - stream alone. + {formatMessage({ + id: 'component.regenstream_card.harvest_caption', + })} From 7b447c797f816da35eb770e56446be7d5ae36fe2 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 19:43:10 +0330 Subject: [PATCH 157/163] fix horizontal scrollbar --- styles/globals.css | 1 + 1 file changed, 1 insertion(+) diff --git a/styles/globals.css b/styles/globals.css index 8755fda0bc..77f1f88b31 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -26,6 +26,7 @@ body { ::-webkit-scrollbar { width: 20px; + height: 20px; } ::-webkit-scrollbar-track { From 9ccad07cc70de7fb4fac2980d416308e858b3c3a Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 20:32:44 +0330 Subject: [PATCH 158/163] update scrolls style --- pages/_document.tsx | 2 ++ src/components/controller/general.ctrl.tsx | 33 ++++++++++++++++++---- styles/globals.css | 6 ++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/pages/_document.tsx b/pages/_document.tsx index 8ad040db51..dd0a94a654 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -49,6 +49,8 @@ export default class MyDocument extends Document { const r = document.querySelector(':root'); r.style.setProperty('--bgColor', '#090446'); r.style.setProperty('--color', '#FFFFFF'); + r.style.setProperty('--scrollColor', '#754CFF'); + r.style.setProperty('--scrollHoverColor', '#211985'); }`, }} > diff --git a/src/components/controller/general.ctrl.tsx b/src/components/controller/general.ctrl.tsx index 7dc96aecc6..9f0e490db0 100644 --- a/src/components/controller/general.ctrl.tsx +++ b/src/components/controller/general.ctrl.tsx @@ -30,21 +30,26 @@ const GeneralController = () => { } } }, [router, account, isWalletActive, chainId]); + console.log('theme', theme); return ; }; const GlobalStyle = createGlobalStyle<{ theme: ETheme }>` - body { + :root { ${props => props.theme === ETheme.Dark ? css` - background-color: ${brandColors.giv[900]}; - color: ${'white'}; + --bgColor: ${brandColors.giv[900]} !important; + --color: white !important; + --scrollColor: ${brandColors.giv[400]}!important; + --scrollHoverColor: ${brandColors.giv[700]}!important; ` : props.theme === ETheme.Light ? css` - background-color: ${neutralColors.gray[200]}; - color: ${neutralColors.gray[900]}; + --bgColor: ${neutralColors.gray[200]}!important; + --color: ${neutralColors.gray[900]}!important; + --scrollColor: #d6dee1 !important; + --scrollHoverColor: #a8bbbf !important; ` : ''} @@ -52,4 +57,22 @@ const GlobalStyle = createGlobalStyle<{ theme: ETheme }>` } `; +// const GlobalStyle = createGlobalStyle<{ theme: ETheme }>` +// body { +// ${props => +// props.theme === ETheme.Dark +// ? css` +// background-color: ${brandColors.giv[900]}; +// color: ${'white'}; +// ` +// : props.theme === ETheme.Light +// ? css` +// background-color: ${neutralColors.gray[200]}; +// color: ${neutralColors.gray[900]}; +// ` +// : ''} + +// } +// `; + export default GeneralController; diff --git a/styles/globals.css b/styles/globals.css index 77f1f88b31..7c199435ee 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -1,6 +1,8 @@ :root { --bgColor: #F7F7F9; --color: #1D1E1F; + --scrollColor: #d6dee1; + --scrollHoverColor: #a8bbbf; } html, @@ -34,14 +36,14 @@ body { } ::-webkit-scrollbar-thumb { - background-color: #d6dee1; + background-color: var(--scrollColor); border-radius: 20px; border: 6px solid transparent; background-clip: content-box; } ::-webkit-scrollbar-thumb:hover { - background-color: #a8bbbf; + background-color: var(--scrollHoverColor); } a { From 7efbf71a7e1c63d0f93514edfd26f786159553c8 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 20:59:18 +0330 Subject: [PATCH 159/163] fix build issue --- src/helpers/blockchain.ts | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/helpers/blockchain.ts b/src/helpers/blockchain.ts index 43de1921a4..ff318e0e8b 100644 --- a/src/helpers/blockchain.ts +++ b/src/helpers/blockchain.ts @@ -1,21 +1,4 @@ -<<<<<<< HEAD -import { parseUnits } from '@ethersproject/units'; - -export interface INetworkParam { - chainId: string; - chainName: string; - blockExplorerUrls: Array; - rpcUrls?: Array; - iconUrls?: Array; - nativeCurrency: { - name: string; - symbol: string; - decimals: number; - }; -} -======= import { INetworkParam } from '@/types/config'; ->>>>>>> main export const networksParams: { [key: number]: INetworkParam; @@ -107,9 +90,3 @@ export const networksParams: { rpcUrls: ['https://polygon-rpc.com'], }, }; -<<<<<<< HEAD - -export const gwei2wei = (gweiAmount: string): string => - parseUnits(gweiAmount, 'gwei').toString(); -======= ->>>>>>> main From 0febaf58cc5754704b11db4d14afc7d3703a415a Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 21:03:16 +0330 Subject: [PATCH 160/163] fix spaces --- src/components/controller/general.ctrl.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/controller/general.ctrl.tsx b/src/components/controller/general.ctrl.tsx index 9f0e490db0..a2eb342ade 100644 --- a/src/components/controller/general.ctrl.tsx +++ b/src/components/controller/general.ctrl.tsx @@ -41,13 +41,13 @@ const GlobalStyle = createGlobalStyle<{ theme: ETheme }>` ? css` --bgColor: ${brandColors.giv[900]} !important; --color: white !important; - --scrollColor: ${brandColors.giv[400]}!important; - --scrollHoverColor: ${brandColors.giv[700]}!important; + --scrollColor: ${brandColors.giv[400]} !important; + --scrollHoverColor: ${brandColors.giv[700]} !important; ` : props.theme === ETheme.Light ? css` - --bgColor: ${neutralColors.gray[200]}!important; - --color: ${neutralColors.gray[900]}!important; + --bgColor: ${neutralColors.gray[200]} !important; + --color: ${neutralColors.gray[900]} !important; --scrollColor: #d6dee1 !important; --scrollHoverColor: #a8bbbf !important; ` From 75966e31dcf224983af4647eb94921df15a1b838 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 21:09:47 +0330 Subject: [PATCH 161/163] format amounts --- src/components/modals/HarvestAll.tsx | 38 ++++------------------------ 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/src/components/modals/HarvestAll.tsx b/src/components/modals/HarvestAll.tsx index 82958a2e49..f198515c42 100644 --- a/src/components/modals/HarvestAll.tsx +++ b/src/components/modals/HarvestAll.tsx @@ -324,11 +324,7 @@ export const HarvestAllModal: FC = ({ = ({ earnedLiquid.sub( givbackLiquidPart, ), - config.TOKEN_PRECISION, - false, )} @@ -418,8 +412,6 @@ export const HarvestAllModal: FC = ({ rewardStream.minus( givBackStream, ), - config.TOKEN_PRECISION, - false, )} @@ -438,8 +430,6 @@ export const HarvestAllModal: FC = ({ {formatWeiHelper( givBackStream, - config.TOKEN_PRECISION, - false, )} @@ -481,8 +471,6 @@ export const HarvestAllModal: FC = ({ {formatWeiHelper( givbackLiquidPart, - config.TOKEN_PRECISION, - false, )} @@ -516,24 +504,14 @@ export const HarvestAllModal: FC = ({
- {formatWeiHelper( - sumLiquid, - config.TOKEN_PRECISION, - false, - )} + {formatWeiHelper(sumLiquid)} {tokenSymbol} -

- {formatWeiHelper( - sumStream, - config.TOKEN_PRECISION, - false, - )} -

+

{formatWeiHelper(sumStream)}

{tokenSymbol} @@ -658,16 +636,10 @@ const EarnedBreakDown: FC = ({ - {formatWeiHelper( - rewardLiquidPart, - config.TOKEN_PRECISION, - false, - )} + {formatWeiHelper(rewardLiquidPart)} {tokenSymbol} - - +{formatWeiHelper(earnedStream, config.TOKEN_PRECISION, false)} - + +{formatWeiHelper(earnedStream)} {tokenSymbol} {formatMessage({ From 7b6c1c6ddde9f997ba83fa92d043761a04263437 Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 21:15:59 +0330 Subject: [PATCH 162/163] user precise multiplier --- .../StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx index 342a1c327c..daae3945ab 100644 --- a/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx +++ b/src/components/cards/StakingCards/BaseStakingCard/StakingPoolInfoAndActions.tsx @@ -237,7 +237,7 @@ export const StakingPoolInfoAndActions: FC = ({ apr && formatEthHelper( apr.effectiveAPR.multipliedBy( - 5.2, // sqrt(1 + max rounds) + 5.196152423, // sqrt(1 + max rounds) ), ) }%. ${formatMessage({ From 5e82591b54f64a1d7c0187409265bf692e9f687b Mon Sep 17 00:00:00 2001 From: Cherik Date: Tue, 28 Mar 2023 21:40:06 +0330 Subject: [PATCH 163/163] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 87ac6dd0d8..d9bc6a1443 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "givethdapp", - "version": "2.12.3", + "version": "2.13.0", "private": true, "scripts": { "build": "next build",