From d42bc55dbec80add7cb4abd3dbd3907e489b4f62 Mon Sep 17 00:00:00 2001 From: Ian Lapham Date: Thu, 5 Aug 2021 14:16:41 -0400 Subject: [PATCH 1/3] update token day data query --- src/apollo/queries.js | 4 ++-- src/components/GlobalChart/index.js | 2 +- src/components/TokenList/index.js | 2 +- src/contexts/TokenData.js | 5 ++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/apollo/queries.js b/src/apollo/queries.js index 186874d21..c2796e1c9 100644 --- a/src/apollo/queries.js +++ b/src/apollo/queries.js @@ -752,10 +752,10 @@ const TokenFields = ` } ` -// used for getting top tokens by total liquidity +// used for getting top tokens by daily volume export const TOKEN_TOP_DAY_DATAS = gql` query tokenDayDatas($date: Int) { - tokenDayDatas(first: 50, orderBy: dailyVolumeUSD, orderDirection: desc, where: { date_gt: $date }) { + tokenDayDatas(first: 50, orderBy: totalLiquidityUSD, orderDirection: desc, where: { date_gt: $date }) { id date } diff --git a/src/components/GlobalChart/index.js b/src/components/GlobalChart/index.js index 6fa0dc229..f1ad87b57 100644 --- a/src/components/GlobalChart/index.js +++ b/src/components/GlobalChart/index.js @@ -45,7 +45,7 @@ const GlobalChart = ({ display }) => { if (item.date > utcStartTime) { return item } else { - return + return true } }) .filter((item) => { diff --git a/src/components/TokenList/index.js b/src/components/TokenList/index.js index d6d941a42..5e557e637 100644 --- a/src/components/TokenList/index.js +++ b/src/components/TokenList/index.js @@ -128,7 +128,7 @@ function TopTokenList({ tokens, itemMax = 10, useTracked = false }) { // sorting const [sortDirection, setSortDirection] = useState(true) - const [sortedColumn, setSortedColumn] = useState(SORT_FIELD.LIQ) + const [sortedColumn, setSortedColumn] = useState(SORT_FIELD.VOL) const below1080 = useMedia('(max-width: 1080px)') const below680 = useMedia('(max-width: 680px)') diff --git a/src/contexts/TokenData.js b/src/contexts/TokenData.js index 3441e0559..9ec7e2034 100644 --- a/src/contexts/TokenData.js +++ b/src/contexts/TokenData.js @@ -238,9 +238,8 @@ const getTopTokens = async (ethPrice, ethPriceOld) => { }) const ids = tokenids?.data?.tokenDayDatas?.reduce((accum, entry) => { - const newMap = accum - newMap.push(entry.id.slice(0, 42)) - return newMap + accum.push(entry.id.slice(0, 42)) + return accum }, []) let current = await client.query({ From fc8d164931bccfb7134db7cc4b777b12a1e0906b Mon Sep 17 00:00:00 2001 From: ianlapham Date: Tue, 7 Dec 2021 22:43:12 -0500 Subject: [PATCH 2/3] update client --- src/apollo/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apollo/client.js b/src/apollo/client.js index e765a2245..c11e1ec89 100644 --- a/src/apollo/client.js +++ b/src/apollo/client.js @@ -4,7 +4,7 @@ import { HttpLink } from 'apollo-link-http' export const client = new ApolloClient({ link: new HttpLink({ - uri: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswapv2', + uri: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap-v2-dev', }), cache: new InMemoryCache(), shouldBatch: true, From 5eeba4c402028cc7eaebbb2d377a6266a8af8bd8 Mon Sep 17 00:00:00 2001 From: ianlapham Date: Wed, 8 Dec 2021 00:07:06 -0500 Subject: [PATCH 3/3] update fetching policy --- src/constants/index.js | 5 +---- src/contexts/Application.js | 8 ++++++-- src/contexts/TokenData.js | 4 +++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/constants/index.js b/src/constants/index.js index fdf05c2b8..4f0d0437d 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -12,10 +12,7 @@ export const timeframeOptions = { } // token list urls to fetch tokens from - use for warnings on tokens and pairs -export const SUPPORTED_LIST_URLS__NO_ENS = [ - 'https://gateway.ipfs.io/ipns/tokens.uniswap.org', - 'https://www.coingecko.com/tokens_list/uniswap/defi_100/v_0_0_0.json', -] +export const SUPPORTED_LIST_URLS__NO_ENS = ['https://tokens.coingecko.com/uniswap/all.json'] // hide from overview list export const TOKEN_BLACKLIST = [ diff --git a/src/contexts/Application.js b/src/contexts/Application.js index 8885f1e9c..05930d151 100644 --- a/src/contexts/Application.js +++ b/src/contexts/Application.js @@ -271,8 +271,12 @@ export function useListedTokens() { async function fetchList() { const allFetched = await SUPPORTED_LIST_URLS__NO_ENS.reduce(async (fetchedTokens, url) => { const tokensSoFar = await fetchedTokens - const newTokens = await getTokenList(url) - return Promise.resolve([...tokensSoFar, ...newTokens.tokens]) + try { + const newTokens = await getTokenList(url) + return Promise.resolve([...tokensSoFar, ...newTokens.tokens]) + } catch (e) { + return Promise.resolve([...tokensSoFar]) + } }, Promise.resolve([])) let formatted = allFetched?.map((t) => t.address.toLowerCase()) updateSupportedTokens(formatted) diff --git a/src/contexts/TokenData.js b/src/contexts/TokenData.js index 9ec7e2034..e57838940 100644 --- a/src/contexts/TokenData.js +++ b/src/contexts/TokenData.js @@ -229,7 +229,7 @@ const getTopTokens = async (ethPrice, ethPriceOld) => { try { // need to get the top tokens by liquidity by need token day datas - const currentDate = parseInt(Date.now() / 86400 / 1000) * 86400 - 86400 + const currentDate = parseInt(Date.now() / 86400 / 1000) * 86400 - 86400 - 86400 let tokenids = await client.query({ query: TOKEN_TOP_DAY_DATAS, @@ -237,6 +237,8 @@ const getTopTokens = async (ethPrice, ethPriceOld) => { variables: { date: currentDate }, }) + console.log(tokenids) + const ids = tokenids?.data?.tokenDayDatas?.reduce((accum, entry) => { accum.push(entry.id.slice(0, 42)) return accum