Skip to content

Commit

Permalink
fix(apps/earn): 24h data for trident pools
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewlilley committed Oct 22, 2022
1 parent a33ace8 commit 47b490f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
17 changes: 8 additions & 9 deletions apps/earn/components/PoolSection/PoolStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface PoolStats {
export const PoolStats: FC<PoolStats> = ({ pair }) => {
const { data: prices } = usePrices({ chainId: pair.chainId })
const nativePrice = prices?.[Native.onChain(pair.chainId).wrapped.address]

return (
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
<div className="flex flex-col gap-1 p-3 rounded-md shadow-md bg-slate-800 shadow-black/20">
Expand All @@ -23,12 +22,12 @@ export const PoolStats: FC<PoolStats> = ({ pair }) => {
<Typography weight={500} className="text-slate-50">
{formatUSD(pair.liquidityNative * Number(nativePrice?.toFixed(4)))}
</Typography>
{pair.liquidity1dChange && (
{pair.liquidity1dChange ? (
<Typography variant="xs" weight={500} className={pair.liquidity1dChange > 0 ? 'text-green' : 'text-red'}>
{pair.liquidity1dChange > 0 ? '+' : '-'}
{formatPercent(Math.abs(pair.liquidity1dChange))}
</Typography>
)}
) : null}
</div>
<div className="flex flex-col gap-1 p-3 rounded-md shadow-md bg-slate-800 shadow-black/20">
<Typography variant="xs" weight={500} className="text-slate-400">
Expand All @@ -37,12 +36,12 @@ export const PoolStats: FC<PoolStats> = ({ pair }) => {
<Typography weight={500} className="text-slate-50">
{formatUSD(pair.volume1d)}
</Typography>
{pair.volume1dChange && (
{pair.volume1dChange ? (
<Typography variant="xs" weight={500} className={pair.volume1dChange > 0 ? 'text-green' : 'text-red'}>
{pair.volume1dChange > 0 ? '+' : '-'}
{formatPercent(Math.abs(pair.volume1dChange))}
</Typography>
)}
) : null}
</div>
<div className="flex flex-col gap-1 p-3 rounded-md shadow-md bg-slate-800 shadow-black/20">
<Typography variant="xs" weight={500} className="text-slate-400">
Expand All @@ -51,12 +50,12 @@ export const PoolStats: FC<PoolStats> = ({ pair }) => {
<Typography weight={500} className="text-slate-50">
{formatUSD(pair.volume1d * (pair.swapFee / 10000))}
</Typography>
{pair.volume1dChange && (
{pair.volume1dChange ? (
<Typography variant="xs" weight={500} className={pair.volume1dChange > 0 ? 'text-green' : 'text-red'}>
{pair.volume1dChange > 0 ? '+' : '-'}
{formatPercent(Math.abs(pair.volume1dChange))}
</Typography>
)}
) : null}
</div>
<div className="flex flex-col gap-1 p-3 rounded-md shadow-md bg-slate-800 shadow-black/20">
<Typography variant="xs" weight={500} className="text-slate-400">
Expand All @@ -66,12 +65,12 @@ export const PoolStats: FC<PoolStats> = ({ pair }) => {
{/* Don't need decimals for a count */}
{formatNumber(pair.txCount1d).replace('.00', '')}
</Typography>
{pair.txCount1dChange && (
{pair.txCount1dChange ? (
<Typography variant="xs" weight={500} className={pair.txCount1dChange > 0 ? 'text-green' : 'text-red'}>
{pair.txCount1dChange > 0 ? '+' : '-'}
{formatPercent(Math.abs(pair.txCount1dChange))}
</Typography>
)}
) : null}
</div>
</div>
)
Expand Down
14 changes: 7 additions & 7 deletions packages/graph-client/queries/sushiswap.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,19 @@ query CrossChainPair($id: ID!, $now: Int!, $chainId: Int!) {
reserve1
swapFee
twapEnabled
liquidity
liquidityNative
liquidityUSD
liquidity1dChange
liquidity1wChange
volumeUSD
volume1d
volume1dChange
volume1w
feesUSD
fees1d
txCount
txCount1d
txCount1dChange
txCount1w
txCount1d,
txCount1dChange,
source
type
token0 {
Expand All @@ -260,9 +263,6 @@ query CrossChainPair($id: ID!, $now: Int!, $chainId: Int!) {
decimals
symbol
}
liquidity
liquidityNative
liquidityUSD
apr
feeApr
incentiveApr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const crossChainPair: QueryResolvers['crossChainPair'] = async (root, arg
TRIDENT_ENABLED_NETWORKS.includes(args.chainId)
? context.Trident.Query.pair({
root,
args: { ...args },
args: { ...args, block },
context: {
...context,
now: args.now,
Expand Down

0 comments on commit 47b490f

Please sign in to comment.