diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 23fd35f..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "editor.formatOnSave": true -} \ No newline at end of file diff --git a/src/apollo/client.js b/src/apollo/client.js index 9395018..5ed96f7 100644 --- a/src/apollo/client.js +++ b/src/apollo/client.js @@ -18,14 +18,6 @@ export const healthClient = new ApolloClient({ shouldBatch: true }) -export const v1Client = new ApolloClient({ - link: new HttpLink({ - uri: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap' - }), - cache: new InMemoryCache(), - shouldBatch: true -}) - export const blockClient = new ApolloClient({ link: new HttpLink({ uri: 'https://api.thegraph.com/subgraphs/name/blocklytics/ethereum-blocks' diff --git a/src/apollo/queries.js b/src/apollo/queries.js index f1658a6..12c7d89 100644 --- a/src/apollo/queries.js +++ b/src/apollo/queries.js @@ -3,7 +3,7 @@ import { FACTORY_ADDRESS, BUNDLE_ID } from '../constants' export const SUBGRAPH_HEALTH = gql` query health { - indexingStatusForCurrentVersion(subgraphName: "ianlapham/uniswapv2") { + indexingStatusForCurrentVersion(subgraphName: "zippoxer/sushiswap-subgraph-fork") { synced health chains { @@ -18,34 +18,6 @@ export const SUBGRAPH_HEALTH = gql` } ` -export const V1_DATA_QUERY = gql` - query uniswap($date: Int!, $date2: Int!) { - current: uniswap(id: "1") { - totalVolumeUSD - totalLiquidityUSD - txCount - } - oneDay: uniswapHistoricalDatas(where: { timestamp_lt: $date }, first: 1, orderBy: timestamp, orderDirection: desc) { - totalVolumeUSD - totalLiquidityUSD - txCount - } - twoDay: uniswapHistoricalDatas( - where: { timestamp_lt: $date2 } - first: 1 - orderBy: timestamp - orderDirection: desc - ) { - totalVolumeUSD - totalLiquidityUSD - txCount - } - exchanges(first: 200, orderBy: ethBalance, orderDirection: desc) { - ethBalance - } - } -` - export const GET_BLOCK = gql` query blocks($timestampFrom: Int!, $timestampTo: Int!) { blocks( @@ -77,7 +49,7 @@ export const POSITIONS_BY_BLOCK = (account, blocks) => { let queryString = 'query blocks {' queryString += blocks.map( block => ` - t${block.timestamp}:liquidityPositions(where: {user: "${account}"}, block: { number: ${block.number} }) { + t${block.timestamp}:liquidityPositions(where: {user: "${account}"}, block: { number: ${block.number} }) { liquidityTokenBalance pair { id @@ -95,7 +67,7 @@ export const PRICES_BY_BLOCK = (tokenAddress, blocks) => { let queryString = 'query blocks {' queryString += blocks.map( block => ` - t${block.timestamp}:token(id:"${tokenAddress}", block: { number: ${block.number} }) { + t${block.timestamp}:token(id:"${tokenAddress}", block: { number: ${block.number} }) { derivedETH } ` @@ -103,7 +75,7 @@ export const PRICES_BY_BLOCK = (tokenAddress, blocks) => { queryString += ',' queryString += blocks.map( block => ` - b${block.timestamp}: bundle(id:"1", block: { number: ${block.number} }) { + b${block.timestamp}: bundle(id:"1", block: { number: ${block.number} }) { ethPrice } ` @@ -131,7 +103,7 @@ export const HOURLY_PAIR_RATES = (pairAddress, blocks) => { let queryString = 'query blocks {' queryString += blocks.map( block => ` - t${block.timestamp}: pair(id:"${pairAddress}", block: { number: ${block.number} }) { + t${block.timestamp}: pair(id:"${pairAddress}", block: { number: ${block.number} }) { token0Price token1Price } @@ -146,11 +118,11 @@ export const SHARE_VALUE = (pairAddress, blocks) => { let queryString = 'query blocks {' queryString += blocks.map( block => ` - t${block.timestamp}:pair(id:"${pairAddress}", block: { number: ${block.number} }) { + t${block.timestamp}:pair(id:"${pairAddress}", block: { number: ${block.number} }) { reserve0 reserve1 reserveUSD - totalSupply + totalSupply token0{ derivedETH } @@ -163,7 +135,7 @@ export const SHARE_VALUE = (pairAddress, blocks) => { queryString += ',' queryString += blocks.map( block => ` - b${block.timestamp}: bundle(id:"1", block: { number: ${block.number} }) { + b${block.timestamp}: bundle(id:"1", block: { number: ${block.number} }) { ethPrice } ` @@ -413,7 +385,7 @@ export const PAIR_DAY_DATA_BULK = (pairs, startTimestamp) => { totalSupply reserveUSD } - } + } ` return gql(queryString) } @@ -435,7 +407,7 @@ export const GLOBAL_CHART = gql` export const GLOBAL_DATA = block => { const queryString = ` query uniswapFactories { uniswapFactories( - ${block ? `block: { number: ${block}}` : ``} + ${block ? `block: { number: ${block}}` : ``} where: { id: "${FACTORY_ADDRESS}" }) { id totalVolumeUSD diff --git a/src/contexts/V1Data.js b/src/contexts/V1Data.js deleted file mode 100644 index 1fd95d3..0000000 --- a/src/contexts/V1Data.js +++ /dev/null @@ -1,58 +0,0 @@ -import { v1Client } from '../apollo/client' -import dayjs from 'dayjs' -import utc from 'dayjs/plugin/utc' -import { getPercentChange, get2DayPercentChange } from '../utils' -import { V1_DATA_QUERY } from '../apollo/queries' -import weekOfYear from 'dayjs/plugin/weekOfYear' - -dayjs.extend(utc) -dayjs.extend(weekOfYear) - -export async function getV1Data() { - dayjs.extend(utc) - - const utcCurrentTime = dayjs() - const utcOneDayBack = utcCurrentTime.subtract(1, 'day').unix() - const utcTwoDaysBack = utcCurrentTime.subtract(2, 'day').unix() - - try { - // get the current data - let result = await v1Client.query({ - query: V1_DATA_QUERY, - variables: { - date: utcOneDayBack, - date2: utcTwoDaysBack - }, - fetchPolicy: 'cache-first' - }) - - let data = result.data.current - let oneDayData = result.data.oneDay[0] - let twoDayData = result.data.twoDay[0] - - let [volumeChangeUSD, volumePercentChangeUSD] = get2DayPercentChange( - data.totalVolumeUSD, - oneDayData.totalVolumeUSD, - twoDayData.totalVolumeUSD - ) - - let [txCountChange, txCountPercentChange] = get2DayPercentChange( - data.txCount, - oneDayData.txCount, - twoDayData.txCount - ) - - // regular percent changes - let liquidityPercentChangeUSD = getPercentChange(data.liquidityUsd, oneDayData.liquidityUsd) - - data.liquidityPercentChangeUSD = liquidityPercentChangeUSD - data.volumePercentChangeUSD = volumePercentChangeUSD - data.txCount = txCountChange - data.txCountPercentChange = txCountPercentChange - data.dailyVolumeUSD = volumeChangeUSD - - return data - } catch (err) { - console.log('error: ', err) - } -}