Skip to content

Commit

Permalink
Merge pull request #15 from QuickSwap/feature/analytics-pair-details
Browse files Browse the repository at this point in the history
Analytics pair details page
  • Loading branch information
totop716 authored Dec 29, 2021
2 parents b2c237e + 4eacc81 commit 8dbe3bf
Show file tree
Hide file tree
Showing 32 changed files with 1,476 additions and 108 deletions.
6 changes: 6 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
PoolsPage,
SwapPage,
AnalyticsTokenDetails,
AnalyticsPairDetails,
} from 'pages';
import { PageLayout } from 'layouts';
import { getLibrary } from 'utils';
Expand Down Expand Up @@ -133,6 +134,11 @@ const App: React.FC = () => {
<AnalyticsTokenDetails />
</PageLayout>
</Route>
<Route exact path='/analytics/pair/:id'>
<PageLayout>
<AnalyticsPairDetails />
</PageLayout>
</Route>
</Switch>
</Web3ReactManager>
</Gelato>
Expand Down
8 changes: 8 additions & 0 deletions src/apollo/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ export const healthClient = new ApolloClient({
shouldBatch: true,
});

export const txClient = new ApolloClient({
link: new HttpLink({
uri: 'https://polygon.furadao.org/subgraphs/name/quickswap',
}),
cache: new InMemoryCache(),
shouldBatch: true,
});

export const v1Client = new ApolloClient({
link: new HttpLink({
uri: 'https://api.thegraph.com/subgraphs/name/ianlapham/uniswap',
Expand Down
123 changes: 123 additions & 0 deletions src/apollo/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,60 @@ export const TOKEN_CHART = gql`
}
`;

export const PAIR_CHART = gql`
query pairDayDatas($pairAddress: Bytes!, $skip: Int!, $startTime: Int!) {
pairDayDatas(
first: 1000
skip: $skip
orderBy: date
orderDirection: asc
where: { pairAddress: $pairAddress, date_gt: $startTime }
) {
id
date
dailyVolumeToken0
dailyVolumeToken1
dailyVolumeUSD
reserveUSD
}
}
`;

export const HOURLY_PAIR_RATES = (pairAddress: string, blocks: any[]) => {
let queryString = 'query blocks {';
queryString += blocks.map(
(block) => `
t${block.timestamp}: pair(id:"${pairAddress}", block: { number: ${block.number} }) {
token0Price
token1Price
}
`,
);

queryString += '}';
return gql(queryString);
};

const PairFields = `
fragment PairFields on Pair {
id
trackedReserveETH
reserve0
reserve1
volumeUSD
reserveUSD
totalSupply
token0 {
symbol
id
decimals
derivedETH
}
token1 {
symbol
id
decimals
derivedETH
}
}
`;
Expand Down Expand Up @@ -487,3 +525,88 @@ export const GET_BLOCKS: any = (timestamps: number[]) => {
queryString += '}';
return gql(queryString);
};

export const FILTERED_TRANSACTIONS = gql`
query($allPairs: [Bytes]!) {
mints(
first: 20
where: { pair_in: $allPairs }
orderBy: timestamp
orderDirection: desc
) {
transaction {
id
timestamp
}
pair {
token0 {
id
symbol
}
token1 {
id
symbol
}
}
to
liquidity
amount0
amount1
amountUSD
}
burns(
first: 20
where: { pair_in: $allPairs }
orderBy: timestamp
orderDirection: desc
) {
transaction {
id
timestamp
}
pair {
token0 {
id
symbol
}
token1 {
id
symbol
}
}
sender
liquidity
amount0
amount1
amountUSD
}
swaps(
first: 30
where: { pair_in: $allPairs }
orderBy: timestamp
orderDirection: desc
) {
transaction {
id
timestamp
}
id
pair {
token0 {
id
symbol
}
token1 {
id
symbol
}
}
amount0In
amount0Out
amount1In
amount1Out
amountUSD
to
}
}
`;
2 changes: 1 addition & 1 deletion src/components/CurrencySearchModal/CurrencySearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => ({
flexDirection: 'column',
background: palette.background.paper,
backdropFilter: 'blur(9.9px)',
border: '1px solid #3e4252',
border: `1px solid ${palette.grey.A400}`,
[breakpoints.down('xs')]: {
height: '90vh',
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/FarmDualCard/FarmDualCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => ({
},
},
buttonToken: {
backgroundColor: '#3e4252',
backgroundColor: palette.grey.A400,
borderRadius: '10px',
height: '50px',
display: 'flex',
Expand Down
2 changes: 1 addition & 1 deletion src/components/FarmLPCard/FarmLPCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => ({
},
},
buttonToken: {
backgroundColor: '#3e4252',
backgroundColor: palette.grey.A400,
borderRadius: '10px',
height: '50px',
display: 'flex',
Expand Down
2 changes: 1 addition & 1 deletion src/components/FarmLPCard/FarmLPCardDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => ({
},
},
buttonToken: {
backgroundColor: '#3e4252',
backgroundColor: palette.grey.A400,
borderRadius: '10px',
height: '50px',
display: 'flex',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const useStyles = makeStyles(({ palette, breakpoints }) => ({
},
},
accountDetails: {
border: `solid 1px #3e4252`,
border: `solid 1px ${palette.grey.A400}`,
padding: '0 16px',
height: 36,
cursor: 'pointer',
Expand Down
69 changes: 47 additions & 22 deletions src/components/PairsTable/PairsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Box, Typography, Divider } from '@material-ui/core';
import { Link } from 'react-router-dom';
import { ChainId, Token } from '@uniswap/sdk';
import { getAddress } from '@ethersproject/address';
import { DoubleCurrencyLogo, CustomTable } from 'components';
Expand Down Expand Up @@ -102,12 +103,23 @@ const PairTable: React.FC<TokensTableProps> = ({ data }) => {
<StarUnchecked />
)}
</Box>
<DoubleCurrencyLogo currency0={token0} currency1={token1} size={28} />
<Box ml={1}>
<Typography variant='body1'>
{token0.symbol} / {token1.symbol}
</Typography>
</Box>
<Link
to={`/analytics/pair/${pair.id}`}
style={{ textDecoration: 'none' }}
>
<Box display='flex' alignItems='center'>
<DoubleCurrencyLogo
currency0={token0}
currency1={token1}
size={28}
/>
<Box ml={1}>
<Typography variant='body1' color='textPrimary'>
{token0.symbol} / {token1.symbol}
</Typography>
</Box>
</Box>
</Link>
</Box>
<Divider />
<Box
Expand Down Expand Up @@ -174,12 +186,18 @@ const PairTable: React.FC<TokensTableProps> = ({ data }) => {
const liquidity = pair.trackedReserveUSD
? pair.trackedReserveUSD
: pair.reserveUSD;
const oneDayVolume = pair.oneDayVolumeUSD
? pair.oneDayVolumeUSD
: pair.oneDayVolumeUntracked;
const oneWeekVolume = pair.oneWeekVolumeUSD
? pair.oneWeekVolumeUSD
: pair.oneWeekVolumeUntracked;
const oneDayVolume =
pair.oneDayVolumeUSD && !isNaN(pair.oneDayVolumeUSD)
? pair.oneDayVolumeUSD
: pair.oneDayVolumeUntracked && !isNaN(pair.oneDayVolumeUntracked)
? pair.oneDayVolumeUntracked
: 0;
const oneWeekVolume =
pair.oneWeekVolumeUSD && !isNaN(pair.oneWeekVolumeUSD)
? pair.oneWeekVolumeUSD
: pair.oneWeekVolumeUntracked && !isNaN(pair.oneWeekVolumeUntracked)
? pair.oneWeekVolumeUntracked
: 0;
const oneDayFee = (Number(oneDayVolume) * 0.003).toLocaleString();
return [
{
Expand All @@ -203,16 +221,23 @@ const PairTable: React.FC<TokensTableProps> = ({ data }) => {
<StarUnchecked />
)}
</Box>
<DoubleCurrencyLogo
currency0={token0}
currency1={token1}
size={28}
/>
<Box ml={1}>
<Typography variant='body1'>
{token0.symbol} / {token1.symbol}
</Typography>
</Box>
<Link
to={`/analytics/pair/${pair.id}`}
style={{ textDecoration: 'none' }}
>
<Box display='flex' alignItems='center'>
<DoubleCurrencyLogo
currency0={token0}
currency1={token1}
size={28}
/>
<Box ml={1}>
<Typography variant='body1' color='textPrimary'>
{token0.symbol} / {token1.symbol}
</Typography>
</Box>
</Box>
</Link>
</Box>
),
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/SyrupCard/SyrupCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const SyrupCard: React.FC<{ syrup: SyrupInfo }> = ({ syrup }) => {
<Box display='flex'>
<Box
borderRadius='4px'
border='1px solid #3e4252'
border={`1px solid ${palette.grey.A400}`}
padding='4px 6px'
marginTop='6px'
display='flex'
Expand Down
12 changes: 2 additions & 10 deletions src/components/TokensTable/TokensTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ const TokensTable: React.FC<TokensTableProps> = ({ data }) => {
to={`/analytics/token/${tokenCurrency.address}`}
style={{ textDecoration: 'none' }}
>
<Box
display='flex'
alignItems='center'
style={{ cursor: 'pointer' }}
>
<Box display='flex' alignItems='center'>
<CurrencyLogo currency={tokenCurrency} size='28px' />
<Box ml={1}>
<Typography
Expand Down Expand Up @@ -216,11 +212,7 @@ const TokensTable: React.FC<TokensTableProps> = ({ data }) => {
to={`/analytics/token/${tokenCurrency.address}`}
style={{ textDecoration: 'none' }}
>
<Box
display='flex'
alignItems='center'
style={{ cursor: 'pointer' }}
>
<Box display='flex' alignItems='center'>
<CurrencyLogo currency={tokenCurrency} size='28px' />
<Box ml={1}>
<Typography
Expand Down
Loading

0 comments on commit 8dbe3bf

Please sign in to comment.