Skip to content
This repository was archived by the owner on Apr 7, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/AddressInputPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { useCallback, useContext } from 'react'
import styled, { ThemeContext } from 'styled-components'

import { AutoColumn } from '../Column'
import { ChainId } from '@zeroexchange/sdk'
import { RowBetween } from '../Row'
import { getEtherscanLink } from '../../utils'
import { useActiveWeb3React } from '../../hooks'
Expand Down
2 changes: 1 addition & 1 deletion src/components/BlockchainSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const BlockchainSelector = ({
}) => {
useEffect(() => {
onSetTransferTo(transferTo?.name)
}, [transferTo])
}, [transferTo, onSetTransferTo])

const openChangeChainInfo = () => {
onShowCrossChainModal()
Expand Down
1 change: 0 additions & 1 deletion src/components/CrossChainModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import BlockchainLogo from '../BlockchainLogo'
import { CHAIN_LABELS } from '../../constants'
import { CrosschainChain } from '../../state/crosschain/actions'
import Modal from '../Modal'
import React from 'react'
Expand Down
2 changes: 2 additions & 0 deletions src/components/CurrencyLogo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export default function CurrencyLogo({
// find logos on ETH address for non-ETH assets
let logoAddress = currency.address
const allConfigTokens: any = []
// eslint-disable-next-line
crosschainConfig.chains.map(chain => {
// eslint-disable-next-line
chain.tokens.map(token => {
allConfigTokens.push(token)
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BarChart, Book, CreditCard, DollarSign, Menu as MenuIcon, RefreshCw } from 'react-feather'
import { ExternalLink, TYPE } from '../../theme'
import { BarChart, Book, CreditCard, DollarSign, RefreshCw } from 'react-feather'
import { ExternalLink } from '../../theme'
import Row, { RowFixed } from '../Row'

// import AvaxLogo from '../../assets/images/avax-logo.png'
Expand Down
1 change: 0 additions & 1 deletion src/components/Popups/TransactionPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import styled, { ThemeContext } from 'styled-components'

import { AutoColumn } from '../Column'
import { AutoRow } from '../Row'
import { ChainId } from '@zeroexchange/sdk'
import { ExternalLink } from '../../theme/components'
import { TYPE } from '../../theme'
import { getEtherscanLink } from '../../utils'
Expand Down
4 changes: 2 additions & 2 deletions src/components/TokenWarningModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AutoRow, RowBetween } from '../Row'
import { ChainId, Token } from '@zeroexchange/sdk'
import { Token } from '@zeroexchange/sdk'
import { ExternalLink, TYPE } from '../../theme'
import React, { useCallback, useMemo, useState } from 'react'
import { getEtherscanLink, shortenAddress } from '../../utils'
Expand Down Expand Up @@ -48,7 +48,7 @@ function TokenWarningCard({ token }: TokenWarningCardProps) {
const allTokens = useAllTokens()

const duplicateNameOrSymbol = useMemo(() => {
if (!token || chainId == undefined) return false
if (!token || chainId === undefined) return false

return Object.keys(allTokens).some(tokenAddress => {
const userToken = allTokens[tokenAddress]
Expand Down
4 changes: 2 additions & 2 deletions src/components/WalletModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ export default function WalletModal({
}, [setWalletView, active, error, connector, walletModalOpen, activePrevious, connectorPrevious])

const tryActivation = async (connector: AbstractConnector | undefined) => {
let name = ''

Object.keys(SUPPORTED_WALLETS).map(key => {
if (connector === SUPPORTED_WALLETS[key].connector) {
return (name = SUPPORTED_WALLETS[key].name)
return SUPPORTED_WALLETS[key].name
}
return true
})
Expand Down
22 changes: 11 additions & 11 deletions src/components/earn/PoolCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { AVAX, ChainId, ETHER, JSBI, TokenAmount } from '@zeroexchange/sdk'
import { Break, CardBGImage, CardNoise } from './styled'
import { ButtonPrimary, ButtonWhiteBg } from '../Button'
import { ExternalLink, StyledInternalLink, TYPE } from '../../theme'
import React, { useState } from 'react'
import { useTokenBalance, useTokenBalancesWithLoadingIndicator } from '../../state/wallet/hooks'
import React from 'react'
// import { useTokenBalance } from '../../state/wallet/hooks'

import { AutoColumn } from '../Column'
import { BIG_INT_SECONDS_IN_WEEK } from '../../constants'
Expand Down Expand Up @@ -75,7 +75,7 @@ const BottomSection = styled.div<{ showBackground: boolean }>`
`

export default function PoolCard({ stakingInfoTop }: { stakingInfoTop: StakingInfo }) {
const { chainId, account } = useActiveWeb3React()
const { chainId } = useActiveWeb3React()

const token0 = stakingInfoTop.tokens[0]
const token1 = stakingInfoTop.tokens[1]
Expand All @@ -93,16 +93,16 @@ export default function PoolCard({ stakingInfoTop }: { stakingInfoTop: StakingIn
const isStaking = Boolean(stakingInfo?.stakedAmount?.greaterThan('0'))

// detect existing unstaked LP position to show add button if none found
const userLiquidityUnstaked = useTokenBalance(account ?? undefined, stakingInfo?.stakedAmount?.token)
const showAddLiquidityButton = Boolean(stakingInfo?.stakedAmount?.equalTo('0') && userLiquidityUnstaked?.equalTo('0'))
// const userLiquidityUnstaked = useTokenBalance(account ?? undefined, stakingInfo?.stakedAmount?.token)
// const showAddLiquidityButton = Boolean(stakingInfo?.stakedAmount?.equalTo('0') && userLiquidityUnstaked?.equalTo('0'))

// toggle for staking modal and unstaking modal
const [showStakingModal, setShowStakingModal] = useState(false)
const [showUnstakingModal, setShowUnstakingModal] = useState(false)
const [showClaimRewardModal, setShowClaimRewardModal] = useState(false)
// // toggle for staking modal and unstaking modal
// const [showStakingModal, setShowStakingModal] = useState(false)
// const [showUnstakingModal, setShowUnstakingModal] = useState(false)
// const [showClaimRewardModal, setShowClaimRewardModal] = useState(false)

// fade cards if nothing staked or nothing earned yet
const disableTop = !stakingInfo?.stakedAmount || stakingInfo.stakedAmount.equalTo(JSBI.BigInt(0))
// // fade cards if nothing staked or nothing earned yet
// const disableTop = !stakingInfo?.stakedAmount || stakingInfo.stakedAmount.equalTo(JSBI.BigInt(0))

const token = currencyA === ETHER || currencyA === AVAX ? tokenB : tokenA
const WETH = currencyA === ETHER || currencyA === AVAX ? tokenA : tokenB
Expand Down
2 changes: 2 additions & 0 deletions src/components/swap/ConfirmSwapModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default function ConfirmSwapModal({
chainId={chainId}
/>
) : null
// eslint-disable-next-line
}, [allowedSlippage, onAcceptChanges, recipient, showAcceptChanges, trade])

const modalBottom = useCallback(() => {
Expand All @@ -79,6 +80,7 @@ export default function ConfirmSwapModal({
chainId={chainId}
/>
) : null
// eslint-disable-next-line
}, [allowedSlippage, onConfirm, showAcceptChanges, swapErrorMessage, trade])

// text to show while loading
Expand Down
2 changes: 2 additions & 0 deletions src/components/swap/SwapModalFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export default function SwapModalFooter({
allowedSlippage,
trade
])

// eslint-disable-next-line
const { priceImpactWithoutFee, realizedLPFee } = useMemo(() => computeTradePriceBreakdown(trade, chainId), [trade])
const severity = warningSeverity(priceImpactWithoutFee)

Expand Down
2 changes: 2 additions & 0 deletions src/components/swap/SwapModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export default function SwapModalHeader({
trade,
allowedSlippage
])

// eslint-disable-next-line
const { priceImpactWithoutFee } = useMemo(() => computeTradePriceBreakdown(trade, chainId), [trade])
const priceImpactSeverity = warningSeverity(priceImpactWithoutFee)

Expand Down
2 changes: 1 addition & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AVAX, ChainId, JSBI, Percent, Token, WETH } from '@zeroexchange/sdk'
import { ChainId, JSBI, Percent, Token, WETH } from '@zeroexchange/sdk'
import { fortmatic, injected, portis, walletconnect, walletlink } from '../connectors'

import { AbstractConnector } from '@web3-react/abstract-connector'
Expand Down
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createWeb3ReactRoot, Web3ReactProvider } from '@web3-react/core'
import 'inter-ui'
import React, { StrictMode } from 'react'
import { isMobile } from 'react-device-detect'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import { HashRouter } from 'react-router-dom'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Earn/Countdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { REWARDS_DURATION_DAYS_CHAINS, STAKING_GENESIS_CHAINS } from '../../state/stake/hooks'
import React, { useEffect, useMemo, useState } from 'react'

import { ChainId } from '@zeroexchange/sdk'
import { TYPE } from '../../theme'
import { useActiveWeb3React } from '../../hooks'
import { CHAIN_LABELS } from '../../constants'
Expand All @@ -10,6 +9,7 @@ const MINUTE = 60
const HOUR = MINUTE * 60
const DAY = HOUR * 24
let REWARDS_DURATION = 0;
// eslint-disable-next-line
let STAKING_GENESIS = 0;


Expand Down
18 changes: 8 additions & 10 deletions src/pages/Earn/Manage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AVAX, BNB, ChainId, ETHER, JSBI, Pair, TokenAmount } from '@zeroexchange/sdk'
import { AVAX, BNB, ETHER, JSBI, Pair, TokenAmount } from '@zeroexchange/sdk'
import { BIG_INT_SECONDS_IN_WEEK, BIG_INT_ZERO } from '../../constants'
import { CardBGImage, CardNoise, CardSection, DataCard } from '../../components/earn/styled'
import React, { useCallback, useContext, useMemo, useState } from 'react'
Expand All @@ -24,7 +24,6 @@ import { currencyId } from '../../utils/currencyId'
import { useActiveWeb3React } from '../../hooks'
import { useColor } from '../../hooks/useColor'
import { useCurrency } from '../../hooks/Tokens'
import { useHistory } from 'react-router'
import { usePair } from '../../data/Reserves'
import { usePairs } from '../../data/Reserves'
import usePrevious from '../../hooks/usePrevious'
Expand Down Expand Up @@ -140,7 +139,6 @@ export default function Manage({
const { account, chainId } = useActiveWeb3React()

const theme = useContext(ThemeContext)
const history = useHistory()
// get currencies and pair
const [currencyA, currencyB] = [useCurrency(currencyIdA), useCurrency(currencyIdB)]
const tokenA = wrappedCurrency(currencyA ?? undefined, chainId)
Expand Down Expand Up @@ -240,13 +238,13 @@ export default function Manage({
const stakingPairs = usePairs(stakingInfosWithBalance?.map(stakingInfo => stakingInfo.tokens))

// remove any pairs that also are included in pairs with stake in mining pool
const v2PairsWithoutStakedAmount = allV2PairsWithLiquidity.filter(v2Pair => {
return (
stakingPairs
?.map(stakingPair => stakingPair[1])
.filter(stakingPair => stakingPair?.liquidityToken.address === v2Pair.liquidityToken.address).length === 0
)
})
// const v2PairsWithoutStakedAmount = allV2PairsWithLiquidity.filter(v2Pair => {
// return (
// stakingPairs
// ?.map(stakingPair => stakingPair[1])
// .filter(stakingPair => stakingPair?.liquidityToken.address === v2Pair.liquidityToken.address).length === 0
// )
// })

const showMe = (pair: any) => {
return (
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Earn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default function Earn() {
otherAddress: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
},
]
// eslint-disable-next-line
};

// staking info for connected account
Expand All @@ -132,6 +133,7 @@ export default function Earn() {
*/
const stakingInfosWithBalance = stakingInfos
let timeToStakingFinish = stakingInfos?.[0]?.periodFinish
// eslint-disable-next-line
stakingInfos.map(item => {
const period = item ? item.periodFinish : timeToStakingFinish
if (period && item.active && timeToStakingFinish && timeToStakingFinish < period) {
Expand Down
2 changes: 0 additions & 2 deletions src/pages/Guides/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import AppBody from '../AppBody'
import { AutoColumn } from '../../components/Column'
import { Book } from 'react-feather'
import React from 'react'
import { TYPE } from '../../theme'
import { Wrapper } from '../../components/swap/styleds'
import styled from 'styled-components'

const GuideItem = styled.div`
Expand Down
9 changes: 4 additions & 5 deletions src/pages/Swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ArrowWrapper, BottomGrouping, SwapCallbackError, Wrapper } from '../../
import { AutoRow, RowBetween } from '../../components/Row'
import { ButtonConfirmed, ButtonError, ButtonLight, ButtonPrimary } from '../../components/Button'
import Card, { GreyCard } from '../../components/Card'
import { ChainId, CurrencyAmount, JSBI, Token, Trade } from '@zeroexchange/sdk'
import { CurrencyAmount, JSBI, Token, Trade } from '@zeroexchange/sdk'
import {
ChainTransferState,
CrosschainChain,
Expand All @@ -14,7 +14,7 @@ import {
} from '../../state/crosschain/actions'
import Column, { AutoColumn } from '../../components/Column'
import { CHAIN_LABELS, SUPPORTED_CHAINS, ETH_RPCS } from '../../constants'
import { Field, selectCurrency } from '../../state/swap/actions'
import { Field } from '../../state/swap/actions'
import { GetTokenByAddress, useCrossChain, useCrosschainHooks, useCrosschainState } from '../../state/crosschain/hooks'
import { LinkStyledButton, TYPE } from '../../theme'
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react'
Expand Down Expand Up @@ -56,7 +56,6 @@ import { Text } from 'rebass'
import TokenWarningModal from '../../components/TokenWarningModal'
import TradePrice from '../../components/swap/TradePrice'
import confirmPriceImpactWithoutFee from '../../components/swap/confirmPriceImpactWithoutFee'
import { getTradeVersion } from '../../data/V1'
import { maxAmountSpend } from '../../utils/maxAmountSpend'
import { useActiveWeb3React } from '../../hooks'
import { useCurrency } from '../../hooks/Tokens'
Expand Down Expand Up @@ -116,7 +115,6 @@ export default function Swap() {
const {
currentTxID,
availableChains: allChains,
availableTokens,
currentChain,
currentToken,
transferAmount,
Expand Down Expand Up @@ -151,7 +149,7 @@ export default function Swap() {

const availableChains = useMemo(() => {
return allChains.filter(i => i.name !== (chainId ? CHAIN_LABELS[chainId] : 'Ethereum'))
}, [allChains])
}, [allChains, chainId])

const theme = useContext(ThemeContext)

Expand Down Expand Up @@ -303,6 +301,7 @@ export default function Swap() {
txHash: undefined
})
})
// eslint-disable-next-line
}, [tradeToConfirm, account, priceImpactWithoutFee, recipient, recipientAddress, showConfirm, swapCallback, trade])

// errors
Expand Down
50 changes: 25 additions & 25 deletions src/state/claim/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { UNI } from './../../constants/index'
import { TokenAmount, JSBI, ChainId } from '@zeroexchange/sdk'
import { TokenAmount, JSBI } from '@zeroexchange/sdk'
import { TransactionResponse } from '@ethersproject/providers'
import { useEffect, useState } from 'react'
import { useState } from 'react'
import { useActiveWeb3React } from '../../hooks'
import { useMerkleDistributorContract } from '../../hooks/useContract'
import { useSingleCallResult } from '../multicall/hooks'
import { calculateGasMargin, isAddress } from '../../utils'
import { calculateGasMargin } from '../../utils'
import { useTransactionAdder } from '../transactions/hooks'

interface UserClaimData {
Expand All @@ -19,37 +19,37 @@ interface UserClaimData {
}
}

const CLAIM_PROMISES: { [key: string]: Promise<UserClaimData | null> } = {}
// const CLAIM_PROMISES: { [key: string]: Promise<UserClaimData | null> } = {}

// returns the claim for the given address, or null if not valid
function fetchClaim(account: string, chainId: ChainId): Promise<UserClaimData | null> {
const formatted = isAddress(account)
if (!formatted) return Promise.reject(new Error('Invalid address'))
const key = `${chainId}:${account}`

return (CLAIM_PROMISES[key] =
CLAIM_PROMISES[key] ??
fetch(`https://gentle-frost-9e74.uniswap.workers.dev/${chainId}/${formatted}`)
.then(res => {
if (res.status === 200) {
return res.json()
} else {
console.debug(`No claim for account ${formatted} on chain ID ${chainId}`)
return null
}
})
.catch(error => {
console.error('Failed to get claim data', error)
}))
}
// function fetchClaim(account: string, chainId: ChainId): Promise<UserClaimData | null> {
// const formatted = isAddress(account)
// if (!formatted) return Promise.reject(new Error('Invalid address'))
// const key = `${chainId}:${account}`

// return (CLAIM_PROMISES[key] =
// CLAIM_PROMISES[key] ??
// fetch(`https://gentle-frost-9e74.uniswap.workers.dev/${chainId}/${formatted}`)
// .then(res => {
// if (res.status === 200) {
// return res.json()
// } else {
// console.debug(`No claim for account ${formatted} on chain ID ${chainId}`)
// return null
// }
// })
// .catch(error => {
// console.error('Failed to get claim data', error)
// }))
// }

// parse distributorContract blob and detect if user has claim data
// null means we know it does not
export function useUserClaimData(account: string | null | undefined): UserClaimData | null | undefined {
const { chainId } = useActiveWeb3React()

const key = `${chainId}:${account}`
const [claimInfo, setClaimInfo] = useState<{ [key: string]: UserClaimData | null }>({})
const [claimInfo] = useState<{ [key: string]: UserClaimData | null }>({})

// useEffect(() => {
// if (!account || !chainId) return
Expand Down
2 changes: 1 addition & 1 deletion src/state/crosschain/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
setCrosschainSwapDetails,
setCrosschainTransferStatus,
setCurrentChain,
setCurrentToken,
setCurrentTokenBalance,
setCurrentTxID,
setPendingTransfer,
Expand Down Expand Up @@ -588,5 +587,6 @@ export function useCrossChain() {
dispatch(setCrosschainRecipient({ address: account || '' }))
UpdateOwnTokenBalance().catch(console.error)
UpdateFee().catch(console.error)
// eslint-disable-next-line
}, [account, currentToken])
}
Loading