Commit 1a7b86d1 authored by Vignesh Mohankumar's avatar Vignesh Mohankumar Committed by GitHub

chore: remove unused exports (#4380)

parent f66f8c4d
import { loadingOpacityMixin } from 'components/Loader/styled'
import { TooltipContainer } from 'components/Tooltip'
import { transparentize } from 'polished'
import { ReactNode } from 'react'
......@@ -6,9 +5,7 @@ import { AlertTriangle } from 'react-feather'
import { Text } from 'rebass'
import styled, { css } from 'styled-components/macro'
import { ThemedText } from '../../theme'
import { AutoColumn } from '../Column'
import TradePrice from './TradePrice'
export const Wrapper = styled.div`
position: relative;
......@@ -135,11 +132,6 @@ export const SwapShowAcceptChanges = styled(AutoColumn)`
margin-top: 8px;
`
export const TransactionDetailsLabel = styled(ThemedText.DeprecatedBlack)`
border-bottom: 1px solid ${({ theme }) => theme.deprecated_bg2};
padding-bottom: 0.5rem;
`
export const ResponsiveTooltipContainer = styled(TooltipContainer)<{ origin?: string; width?: string }>`
background-color: ${({ theme }) => theme.deprecated_bg0};
border: 1px solid ${({ theme }) => theme.deprecated_bg2};
......@@ -151,7 +143,3 @@ export const ResponsiveTooltipContainer = styled(TooltipContainer)<{ origin?: st
transform-origin: ${origin ?? 'top left'};
`}
`
export const StyledTradePrice = styled(TradePrice)<{ $loading: boolean }>`
${loadingOpacityMixin}
`
......@@ -3,10 +3,6 @@ import JSBI from 'jsbi'
export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'
export const NetworkContextName = 'NETWORK'
export const IS_IN_IFRAME = window.parent !== window
// 30 minutes, denominated in seconds
export const DEFAULT_DEADLINE_FROM_NOW = 60 * 30
export const L2_DEADLINE_FROM_NOW = 60 * 5
......@@ -33,8 +29,5 @@ export const PRICE_IMPACT_WITHOUT_FEE_CONFIRM_MIN: Percent = new Percent(JSBI.Bi
// for non expert mode disable swaps above this
export const BLOCKED_PRICE_IMPACT_NON_EXPERT: Percent = new Percent(JSBI.BigInt(1500), BIPS_BASE) // 15%
export const BETTER_TRADE_LESS_HOPS_THRESHOLD = new Percent(JSBI.BigInt(50), BIPS_BASE)
export const ZERO_PERCENT = new Percent('0')
export const TWO_PERCENT = new Percent(JSBI.BigInt(200), BIPS_BASE)
export const ONE_HUNDRED_PERCENT = new Percent('1')
import { useEffect, useRef, useState } from 'react'
import { useEffect, useState } from 'react'
/**
* Debounces updates to a value.
......@@ -24,34 +24,3 @@ export default function useDebounce<T>(value: T, delay: number): T {
return debouncedValue
}
export function useDebouncedCallback<A extends unknown[]>(callback: (...args: A) => void, wait: number) {
// track args & timeout handle between calls
const argsRef = useRef<A>()
const timeout = useRef<ReturnType<typeof setTimeout>>()
function cleanup() {
if (timeout.current) {
clearTimeout(timeout.current)
}
}
// make sure our timeout gets cleared if
// our consuming component gets unmounted
useEffect(() => cleanup, [])
return function debouncedCallback(...args: A) {
// capture latest args
argsRef.current = args
// clear debounce timer
cleanup()
// start waiting again
timeout.current = setTimeout(() => {
if (argsRef.current) {
callback(...argsRef.current)
}
}, wait)
}
}
import { useEffect } from 'react'
/**
* Disable scroll of an element based on condition
*/
export function useImperativeDisableScroll({ element, disabled }: { element?: HTMLElement; disabled?: boolean }) {
useEffect(() => {
if (!element) return
element.style.overflowY = disabled ? 'hidden' : 'auto'
return () => {
element.style.overflowY = 'auto'
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [disabled])
}
import { useEffect, useState } from 'react'
const getReturnValues = (countDown: number): [number, number, number, number] => {
// calculate time left
const days = Math.floor(countDown / (1000 * 60 * 60 * 24))
const hours = Math.floor((countDown % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
const minutes = Math.floor((countDown % (1000 * 60 * 60)) / (1000 * 60))
const seconds = Math.floor((countDown % (1000 * 60)) / 1000)
return [days, hours, minutes, seconds]
}
export const useTimeout = (targetDate: Date) => {
const countDownDate = new Date(targetDate).getTime()
const [countDown, setCountDown] = useState<number>(countDownDate - new Date().getTime())
useEffect(() => {
const interval = setInterval(() => {
setCountDown(countDownDate - new Date().getTime())
}, 1000)
return () => clearInterval(interval)
}, [countDownDate])
return getReturnValues(countDown)
}
import { useWeb3React } from '@web3-react/core'
import { atomWithImmer } from 'jotai/immer'
import { useAtomValue, useUpdateAtom } from 'jotai/utils'
import { useAtomValue } from 'jotai/utils'
import { useCallback } from 'react'
import useBlockNumber from './useBlockNumber'
......@@ -10,20 +10,6 @@ const oldestBlockMapAtom = atomWithImmer<{ [chainId: number]: number }>({})
const DEFAULT_MAX_BLOCK_AGE = 10
export function useSetOldestValidBlock(): (block: number) => void {
const { chainId } = useWeb3React()
const updateValidBlock = useUpdateAtom(oldestBlockMapAtom)
return useCallback(
(block: number) => {
if (!chainId) return
updateValidBlock((oldestBlockMap) => {
oldestBlockMap[chainId] = Math.max(block, oldestBlockMap[chainId] || 0)
})
},
[chainId, updateValidBlock]
)
}
export function useGetIsValidBlock(maxBlockAge = DEFAULT_MAX_BLOCK_AGE): (block: number) => boolean {
const { chainId } = useWeb3React()
const currentBlock = useBlockNumber()
......
import styled from 'styled-components/macro'
export const IframeBodyWrapper = styled.div`
display: flex;
flex-direction: column;
width: 100%;
margin-top: 3rem;
padding: 1rem;
align-items: center;
flex: 1;
z-index: 1;
`
......@@ -66,10 +66,6 @@ export function useTogglePrivacyPolicy(): () => void {
return useToggleModal(ApplicationModal.PRIVACY_POLICY)
}
export function useToggleTimeSelector(): () => void {
return useToggleModal(ApplicationModal.TIME_SELECTOR)
}
export function useToggleFeatureFlags(): () => void {
return useToggleModal(ApplicationModal.FEATURE_FLAGS)
}
......
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { useWeb3React } from '@web3-react/core'
import JSBI from 'jsbi'
import { useTokenBalance, useTokenBalancesWithLoadingIndicator } from 'lib/hooks/useCurrencyBalance'
import { useTokenBalancesWithLoadingIndicator } from 'lib/hooks/useCurrencyBalance'
import { useMemo } from 'react'
import { UNI } from '../../constants/tokens'
import { useAllTokens } from '../../hooks/Tokens'
import { useUserUnclaimedAmount } from '../claim/hooks'
import { useTotalUniEarned } from '../stake/hooks'
export {
default as useCurrencyBalance,
......@@ -27,24 +23,3 @@ export function useAllTokenBalances(): [{ [tokenAddress: string]: CurrencyAmount
const [balances, balancesIsLoading] = useTokenBalancesWithLoadingIndicator(account ?? undefined, allTokensArray)
return [balances ?? {}, balancesIsLoading]
}
// get the total owned, unclaimed, and unharvested UNI for account
export function useAggregateUniBalance(): CurrencyAmount<Token> | undefined {
const { account, chainId } = useWeb3React()
const uni = chainId ? UNI[chainId] : undefined
const uniBalance: CurrencyAmount<Token> | undefined = useTokenBalance(account ?? undefined, uni)
const uniUnclaimed: CurrencyAmount<Token> | undefined = useUserUnclaimedAmount(account)
const uniUnHarvested: CurrencyAmount<Token> | undefined = useTotalUniEarned()
if (!uni) return undefined
return CurrencyAmount.fromRawAmount(
uni,
JSBI.add(
JSBI.add(uniBalance?.quotient ?? JSBI.BigInt(0), uniUnclaimed?.quotient ?? JSBI.BigInt(0)),
uniUnHarvested?.quotient ?? JSBI.BigInt(0)
)
)
}
......@@ -228,22 +228,6 @@ export function useStakingInfo(pairToFilterBy?: Pair | null): StakingInfo[] {
])
}
export function useTotalUniEarned(): CurrencyAmount<Token> | undefined {
const { chainId } = useWeb3React()
const uni = chainId ? UNI[chainId] : undefined
const stakingInfos = useStakingInfo()
return useMemo(() => {
if (!uni) return undefined
return (
stakingInfos?.reduce(
(accumulator, stakingInfo) => accumulator.add(stakingInfo.earnedAmount),
CurrencyAmount.fromRawAmount(uni, '0')
) ?? CurrencyAmount.fromRawAmount(uni, '0')
)
}, [stakingInfos, uni])
}
// based on typed value
export function useDerivedStakeInfo(
typedValue: string,
......
......@@ -4,7 +4,6 @@ import { useWeb3React } from '@web3-react/core'
import { L2_CHAIN_IDS } from 'constants/chains'
import { SupportedLocale } from 'constants/locales'
import { L2_DEADLINE_FROM_NOW } from 'constants/misc'
import useCurrentBlockTimestamp from 'hooks/useCurrentBlockTimestamp'
import JSBI from 'jsbi'
import { useCallback, useMemo } from 'react'
import { shallowEqual } from 'react-redux'
......@@ -19,7 +18,6 @@ import {
addSerializedToken,
removeSerializedToken,
updateHideClosedPositions,
updateShowDonationLink,
updateShowSurveyPopup,
updateUserClientSideRouter,
updateUserDarkMode,
......@@ -118,26 +116,6 @@ export function useShowSurveyPopup(): [boolean | undefined, (showPopup: boolean)
return [showSurveyPopup, toggleShowSurveyPopup]
}
const DONATION_END_TIMESTAMP = 1646864954 // Jan 15th
export function useShowDonationLink(): [boolean | undefined, (showDonationLink: boolean) => void] {
const dispatch = useAppDispatch()
const showDonationLink = useAppSelector((state) => state.user.showDonationLink)
const toggleShowDonationLink = useCallback(
(showPopup: boolean) => {
dispatch(updateShowDonationLink({ showDonationLink: showPopup }))
},
[dispatch]
)
const timestamp = useCurrentBlockTimestamp()
const durationOver = timestamp ? timestamp.toNumber() > DONATION_END_TIMESTAMP : false
const donationVisible = showDonationLink !== false && !durationOver
return [donationVisible, toggleShowDonationLink]
}
export function useClientSideRouter(): [boolean, (userClientSideRouter: boolean) => void] {
const dispatch = useAppDispatch()
......
import { getChainInfo, NetworkType } from 'constants/chainInfo'
import { SupportedL1ChainId, SupportedL2ChainId } from 'constants/chains'
export function isL1ChainId(chainId: number | undefined): chainId is SupportedL1ChainId {
const chainInfo = getChainInfo(chainId)
return chainInfo?.networkType === NetworkType.L1
}
import { SupportedL2ChainId } from 'constants/chains'
export function isL2ChainId(chainId: number | undefined): chainId is SupportedL2ChainId {
const chainInfo = getChainInfo(chainId)
......
......@@ -3,7 +3,6 @@ import { AddressZero } from '@ethersproject/constants'
import { Contract } from '@ethersproject/contracts'
import { JsonRpcProvider, JsonRpcSigner } from '@ethersproject/providers'
import { Token } from '@uniswap/sdk-core'
import { FeeAmount } from '@uniswap/v3-sdk'
import { ChainTokenMap } from 'lib/hooks/useTokenList/utils'
// returns the checksummed address if the address is valid, otherwise returns false
......@@ -50,7 +49,3 @@ export function escapeRegExp(string: string): string {
export function isTokenOnList(chainTokenMap: ChainTokenMap, token?: Token): boolean {
return Boolean(token?.isToken && chainTokenMap[token.chainId]?.[token.address])
}
export function formattedFeeAmount(feeAmount: FeeAmount): number {
return feeAmount / 10000
}
import { Currency, Percent, TradeType } from '@uniswap/sdk-core'
import { Trade as V2Trade } from '@uniswap/v2-sdk'
import { ONE_HUNDRED_PERCENT, ZERO_PERCENT } from '../constants/misc'
// returns whether tradeB is better than tradeA by at least a threshold percentage amount
// only used by v2 hooks
export function isTradeBetter(
tradeA: V2Trade<Currency, Currency, TradeType> | undefined | null,
tradeB: V2Trade<Currency, Currency, TradeType> | undefined | null,
minimumDelta: Percent = ZERO_PERCENT
): boolean | undefined {
if (tradeA && !tradeB) return false
if (tradeB && !tradeA) return true
if (!tradeA || !tradeB) return undefined
if (
tradeA.tradeType !== tradeB.tradeType ||
!tradeA.inputAmount.currency.equals(tradeB.inputAmount.currency) ||
!tradeA.outputAmount.currency.equals(tradeB.outputAmount.currency)
) {
throw new Error('Comparing incomparable trades')
}
if (minimumDelta.equalTo(ZERO_PERCENT)) {
return tradeA.executionPrice.lessThan(tradeB.executionPrice)
} else {
return tradeA.executionPrice.asFraction
.multiply(minimumDelta.add(ONE_HUNDRED_PERCENT))
.lessThan(tradeB.executionPrice)
}
}
......@@ -21,12 +21,6 @@ export function computeRealizedPriceImpact(trade: Trade<Currency, Currency, Trad
return trade.priceImpact.subtract(realizedLpFeePercent)
}
export function getPriceImpactWarning(priceImpact?: Percent): 'warning' | 'error' | undefined {
if (priceImpact?.greaterThan(ALLOWED_PRICE_IMPACT_HIGH)) return 'error'
if (priceImpact?.greaterThan(ALLOWED_PRICE_IMPACT_MEDIUM)) return 'warning'
return
}
// computes realized lp fee as a percent
export function computeRealizedLPFeePercent(trade: Trade<Currency, Currency, TradeType>): Percent {
let percent: Percent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment