refactor: some clean up of the common bases code, add WETH

This commit is contained in:
Moody Salem 2021-05-21 10:01:58 -05:00
parent 679a58daf4
commit bc243e1c07
No known key found for this signature in database
GPG Key ID: 8CB5CD10385138DB
2 changed files with 17 additions and 7 deletions

@ -3,7 +3,7 @@ import { Text } from 'rebass'
import { Currency } from '@uniswap/sdk-core'
import styled from 'styled-components/macro'
import { SUGGESTED_BASES } from '../../constants/routing'
import { COMMON_BASES } from '../../constants/routing'
import { currencyId } from '../../utils/currencyId'
import { AutoColumn } from '../Column'
import QuestionHelper from '../QuestionHelper'
@ -35,7 +35,9 @@ export default function CommonBases({
selectedCurrency?: Currency | null
onSelect: (currency: Currency) => void
}) {
return (
const bases = typeof chainId !== 'undefined' ? COMMON_BASES[chainId] ?? [] : []
return bases.length > 0 ? (
<AutoColumn gap="md">
<AutoRow>
<Text fontWeight={500} fontSize={14}>
@ -44,7 +46,7 @@ export default function CommonBases({
<QuestionHelper text="These tokens are commonly paired with other tokens." />
</AutoRow>
<AutoRow gap="4px">
{(typeof chainId === 'number' ? SUGGESTED_BASES[chainId] ?? [] : []).map((currency: Currency) => {
{bases.map((currency: Currency) => {
const isSelected = selectedCurrency?.equals(currency)
return (
<BaseWrapper
@ -61,5 +63,5 @@ export default function CommonBases({
})}
</AutoRow>
</AutoColumn>
)
) : null
}

@ -66,10 +66,18 @@ export const CUSTOM_BASES: { [chainId: number]: { [tokenAddress: string]: Token[
[AMPL.address]: [DAI, WETH9[1]],
},
}
// used for display in the default list when adding liquidity
export const SUGGESTED_BASES: ChainCurrencyList = {
[1]: [Ether.onChain(1), DAI, USDC, USDT, WBTC],
/**
* Shows up in the currency select for swap and add liquidity
*/
export const COMMON_BASES: ChainCurrencyList = {
[1]: [Ether.onChain(1), DAI, USDC, USDT, WBTC, WETH9[1]],
[3]: [Ether.onChain(3), WETH9[3]],
[4]: [Ether.onChain(4), WETH9[4]],
[5]: [Ether.onChain(5), WETH9[5]],
[42]: [Ether.onChain(42), WETH9[42]],
}
// used to construct the list of all pairs we consider by default in the frontend
export const BASES_TO_TRACK_LIQUIDITY_FOR: ChainTokenList = {
...WETH_ONLY,