diff --git a/src/components/NavBar/index.tsx b/src/components/NavBar/index.tsx index 87785091..c3137976 100644 --- a/src/components/NavBar/index.tsx +++ b/src/components/NavBar/index.tsx @@ -20,6 +20,7 @@ import { } from './styled' import { useAccountDetails } from 'hooks/starknet-react' import { ChainId } from '@vnaysn/jediswap-sdk-core' +import StarkIcon from 'assets/svg/starknet.svg' const MenuItemLink = ({ to, dataTestId, id, isActive, children }) => { const Component = isActive ? ActiveMenuItem : MenuItem @@ -56,6 +57,7 @@ export const PageTabs = () => { V1 + starknet_logo Rewards diff --git a/src/components/Tooltip/index.tsx b/src/components/Tooltip/index.tsx index 8ee69924..91ec8a8d 100644 --- a/src/components/Tooltip/index.tsx +++ b/src/components/Tooltip/index.tsx @@ -6,6 +6,7 @@ import noop from 'utils/noop'; import Popover, { PopoverProps } from '../Popover'; export enum TooltipSize { + UltraSmall = '135px', ExtraSmall = '200px', Small = '256px', Large = '400px', @@ -13,6 +14,8 @@ export enum TooltipSize { const getPaddingForSize = (size: TooltipSize) => { switch (size) { + case TooltipSize.UltraSmall: + return '8px'; case TooltipSize.ExtraSmall: return '8px'; case TooltipSize.Small: @@ -22,7 +25,7 @@ const getPaddingForSize = (size: TooltipSize) => { } }; -const TooltipContainer = styled.div<{ size: TooltipSize }>` +const TooltipContainer = styled.div<{ size: TooltipSize, borderRadius?: string }>` max-width: ${({ size }) => size}; width: calc(100vw - 16px); cursor: default; @@ -36,7 +39,7 @@ const TooltipContainer = styled.div<{ size: TooltipSize }>` word-break: break-word; background: ${({ theme }) => theme.surface1}; - border-radius: 4px; + border-radius: ${({ borderRadius }) => borderRadius || '4px'}; border: 1px solid ${({ theme }) => theme.surface3}; box-shadow: 0 4px 8px 0 ${({ theme }) => transparentize(0.9, theme.shadow1)}; `; @@ -48,16 +51,17 @@ type TooltipProps = Omit & { size?: TooltipSize disabled?: boolean timeout?: number + borderRadius?: string } // TODO(WEB-2024) // Migrate to MouseoverTooltip and move this component inline to MouseoverTooltip -export default function Tooltip({ text, open, close, disabled, size = TooltipSize.Small, ...rest }: TooltipProps) { +export default function Tooltip({ text, open, close, disabled, size = TooltipSize.Small, borderRadius, ...rest }: TooltipProps) { return ( + {text} ) @@ -73,6 +77,7 @@ type MouseoverTooltipProps = Omit & PropsWithChildren<{ text: ReactNode size?: TooltipSize + borderRadius?: string disabled?: boolean timeout?: number placement?: PopoverProps['placement'] diff --git a/src/pages/Rewards/index.tsx b/src/pages/Rewards/index.tsx index e9bbaa46..b1873778 100644 --- a/src/pages/Rewards/index.tsx +++ b/src/pages/Rewards/index.tsx @@ -1,8 +1,11 @@ -import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react' +import React, { MouseEvent, useCallback, useContext, useEffect, useMemo, useState } from 'react' +import { Link } from 'react-router-dom' import { BodyWrapper } from '../AppBody' import styled, { ThemeContext, css, keyframes } from 'styled-components' import { AutoColumn } from 'components/Column' import StarkIcon from 'assets/svg/starknet.svg' +import WalletIcon from 'assets/wallets/Wallet.png' +import { MouseoverTooltip, TooltipSize } from 'components/Tooltip' import './style.css' import { CurrencyAmount, Token } from '@jediswap/sdk' import { ButtonPrimary, ButtonSecondary } from 'components/Button' @@ -26,6 +29,7 @@ import { findClosestAPRPeriod } from 'utils/getClosest' import { formattedPercent } from 'utils/formattedPercent' import { apiTimeframeOptions } from 'constants/apiTimeframeOptions' import { ApolloQueryResult } from '@apollo/client' +import { ChainId } from '@vnaysn/jediswap-sdk-core' const PageWrapper = styled(AutoColumn)` max-width: 996px; @@ -418,6 +422,45 @@ const MobileWrapper = styled.div` padding: 0px; } ` +const ConnectWalletText = styled.div` + font-size: 20px; + font-weight: 600; + font-family: "Avenir LT Std", sans-serif; + max-width: 410px; + text-align: center; +` +const ConnectWalletWrapper = styled.div` + display: flex; + flex-direction: column; + align-items: center; +` + +const WalletNotConnected = () => { + const toggleWalletDrawer = useToggleAccountDrawer() + return ( + + + Connect wallet to see your STRK rewards + + Connect Wallet + + + ) +} + +const ConnectedToSepolia = () => { + return ( + + + + Switch your network from Sepolia to Mainnet to see rewards + + + ) +} export default function Rewards() { const [allPools, setAllPools] = useState([]) @@ -425,6 +468,8 @@ export default function Rewards() { const [poolsLoading, setPoolsLoading] = useState(true) const STRK_REWARDS_ADDRESS = getStarkRewardAddress(chainId ?? DEFAULT_CHAIN_ID) const allTokens = useDefaultActiveTokens(DEFAULT_CHAIN_ID) + const isSepoliaSelected = chainId === ChainId.GOERLI + const isMainnetSelected = chainId === ChainId.MAINNET useEffect(() => { async function getPairsData() { @@ -534,12 +579,11 @@ export default function Rewards() { const [txPending, setTxPending] = useState(false) const [attemptingTxn, setAttemptingTxn] = useState(false) - const toggleWalletDrawer = useToggleAccountDrawer() //fetch allocation data useEffect(() => { const getAllocation = async () => { - if (address) { + if (address && isMainnetSelected) { try { setAllocationsLoading(true) const requests = [ @@ -571,7 +615,7 @@ export default function Rewards() { } getAllocation() - }, [address]) + }, [address, chainId]) useEffect(() => { if (callData.length && address) { @@ -638,32 +682,47 @@ export default function Rewards() { const buttonText = (totalRewardsClaimed && 'Claimed') || (unclaimed_rewards && 'Claim STRK') || (attemptingTxn && 'Claiming...') + const onLinkClick = (e: MouseEvent) => { + if (isSepoliaSelected) { + e.preventDefault() + } + } const PairListItem = ({ pool }: { pool: any }) => { const token0 = pool.token0.symbol === 'ETH' ? pool.token0 : allTokens[validateAndParseAddress(pool.token0.tokenAddress)] const token1 = pool.token1.symbol === 'ETH' ? pool.token1 : allTokens[validateAndParseAddress(pool.token1.tokenAddress)] - + const token0ForLink = pool.token0.symbol === 'ETH' ? 'ETH' : pool.token0.tokenAddress + const token1ForLink = pool.token1.symbol === 'ETH' ? 'ETH' : pool.token1.tokenAddress + const link = `/add/${token0ForLink}/${token1ForLink}/${pool.fee}` return ( -
- -
- - {pool?.token0?.symbol}-{pool?.token1?.symbol} - - -
Total APR:
-
{pool.displayAprCommon}
-
- -
Fee APR:
-
{pool.displayAprFee}
-
- -
STRK APR:
-
{pool.displayAprStarknet}
-
+ + +
+ +
+ + {pool?.token0?.symbol}-{pool?.token1?.symbol} + + +
Total APR:
+
{pool.displayAprCommon}
+
+ +
Fee APR:
+
{pool.displayAprFee}
+
+ +
STRK APR:
+
{pool.displayAprStarknet}
+
+
+
) } @@ -730,58 +789,54 @@ export default function Rewards() { - - - Your STRK Rewards - - - - - - - <> - - STRK ALLOCATED - - - {allocations?.toSignificant() ?? 0} - - - - <> - - STRK CLAIMED - - - {formattedClaimRewards?.toSignificant() ?? 0} - - - - <> - - STRK UNCLAIMED - - - - {unclaimed_rewards.toSignificant(5) ?? 0} - - {!address ? ( - - Connect Wallet - - ) : allocated && allocations && (totalRewardsClaimed || unclaimed_rewards || attemptingTxn) ? ( - - {buttonText} - - ) : null} - - - - - + { + !chainId ? : isSepoliaSelected ? : + + + Your STRK Rewards + + + + + + + <> + + STRK ALLOCATED + + + {allocations?.toSignificant() ?? 0} + + + + <> + + STRK CLAIMED + + + {formattedClaimRewards?.toSignificant() ?? 0} + + + + <> + + STRK UNCLAIMED + + + + {unclaimed_rewards.toSignificant(5) ?? 0} + + {allocated && allocations && (totalRewardsClaimed || unclaimed_rewards || attemptingTxn) ? ( + + {buttonText} + + ) : null} + + + + + + } )