Skip to content

Commit

Permalink
Merge pull request #274 from ianlapham/v2
Browse files Browse the repository at this point in the history
updated untracked
  • Loading branch information
ianlapham authored Sep 1, 2020
2 parents 004c7d5 + 327bc11 commit a825109
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/apollo/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ const PairFields = `
trackedReserveETH
reserveETH
volumeUSD
untrackedVolumeUSD
token0Price
token1Price
createdAtTimestamp
Expand Down Expand Up @@ -689,6 +690,7 @@ export const PAIRS_HISTORICAL_BULK = (block, pairs) => {
reserveUSD
trackedReserveETH
volumeUSD
untrackedVolumeUSD
}
}
`
Expand Down Expand Up @@ -730,6 +732,7 @@ const TokenFields = `
derivedETH
tradeVolume
tradeVolumeUSD
untrackedVolumeUSD
totalLiquidity
txCount
}
Expand Down
30 changes: 24 additions & 6 deletions src/pages/PairPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ function PairPage({ pairAddress, history }) {
trackedReserveUSD,
oneDayVolumeUSD,
volumeChangeUSD,
oneDayVolumeUntracked,
volumeChangeUntracked,
liquidityChangeUSD
} = usePairData(pairAddress)

Expand All @@ -140,13 +142,29 @@ function PairPage({ pairAddress, history }) {
setUsingTracked(!trackedReserveUSD ? false : true)
}, [trackedReserveUSD])

// volume
const volume = oneDayVolumeUSD ? formattedNum(oneDayVolumeUSD, true) : oneDayVolumeUSD === 0 ? '$0' : '-'
// volume // volume
const volume =
oneDayVolumeUSD || oneDayVolumeUSD === 0
? formattedNum(oneDayVolumeUSD === 0 ? oneDayVolumeUntracked : oneDayVolumeUSD, true)
: oneDayVolumeUSD === 0
? '$0'
: '-'

const volumeChange = formattedPercent(volumeChangeUSD)
// mark if using untracked volume
const [usingUtVolume, setUsingUtVolume] = useState(false)
useEffect(() => {
setUsingUtVolume(oneDayVolumeUSD === 0 ? true : false)
}, [oneDayVolumeUSD])

const volumeChange = formattedPercent(!usingUtVolume ? volumeChangeUSD : volumeChangeUntracked)

// get fees
const fees = oneDayVolumeUSD ? formattedNum(oneDayVolumeUSD * 0.003, true) : oneDayVolumeUSD === 0 ? 0 : '-'
// get fees // get fees
const fees =
oneDayVolumeUSD || oneDayVolumeUSD === 0
? usingUtVolume
? formattedNum(oneDayVolumeUntracked * 0.003, true)
: formattedNum(oneDayVolumeUSD * 0.003, true)
: '-'

// token data for usd
const [ethPrice] = useEthPrice()
Expand Down Expand Up @@ -311,7 +329,7 @@ function PairPage({ pairAddress, history }) {
<Panel style={{ height: '100%' }}>
<AutoColumn gap="20px">
<RowBetween>
<TYPE.main>Volume (24hrs) </TYPE.main>
<TYPE.main>Volume (24hrs) {usingUtVolume && '(Untracked)'}</TYPE.main>
<div />
</RowBetween>
<RowBetween align="flex-end">
Expand Down
21 changes: 17 additions & 4 deletions src/pages/TokenPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useState } from 'react'
import 'feather-icons'
import { withRouter } from 'react-router-dom'
import { Text } from 'rebass'
Expand Down Expand Up @@ -97,6 +97,8 @@ function TokenPage({ address, history }) {
oneDayVolumeUSD,
totalLiquidityUSD,
volumeChangeUSD,
oneDayVolumeUT,
volumeChangeUT,
priceChangeUSD,
liquidityChangeUSD,
oneDayTxns,
Expand All @@ -123,9 +125,20 @@ function TokenPage({ address, history }) {
const priceChange = priceChangeUSD ? formattedPercent(priceChangeUSD) : ''

// volume
const volume = oneDayVolumeUSD ? formattedNum(oneDayVolumeUSD, true) : oneDayVolumeUSD === 0 ? '$0' : '-'
const volume =
oneDayVolumeUSD || oneDayVolumeUSD === 0
? formattedNum(oneDayVolumeUSD === 0 ? oneDayVolumeUT : oneDayVolumeUSD, true)
: oneDayVolumeUSD === 0
? '$0'
: '-'

const volumeChange = formattedPercent(volumeChangeUSD)
// mark if using untracked volume
const [usingUtVolume, setUsingUtVolume] = useState(false)
useEffect(() => {
setUsingUtVolume(oneDayVolumeUSD === 0 ? true : false)
}, [oneDayVolumeUSD])

const volumeChange = formattedPercent(!usingUtVolume ? volumeChangeUSD : volumeChangeUT)

// liquidity
const liquidity = totalLiquidityUSD ? formattedNum(totalLiquidityUSD, true) : totalLiquidityUSD === 0 ? '$0' : '-'
Expand Down Expand Up @@ -270,7 +283,7 @@ function TokenPage({ address, history }) {
<Panel>
<AutoColumn gap="20px">
<RowBetween>
<TYPE.main>Volume (24hrs)</TYPE.main>
<TYPE.main>Volume (24hrs) {usingUtVolume && '(Untracked)'}</TYPE.main>
<div />
</RowBetween>
<RowBetween align="flex-end">
Expand Down

1 comment on commit a825109

@vercel
Copy link

@vercel vercel bot commented on a825109 Sep 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.