mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
* get pools data from graph * TVL displayed * ESlint fixes * Code style fixed on App.tsx * footer stats display changes * ApolloProvider wrapping * config subgraphUri verified * pool number taken from graph * Apollo provider fix * Pools number set fixed * deleted unused imports * fix fetch, gatsby build Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * remove apollo client redundant init Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * fix prop Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * update pool count Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * tooltip added * small development config refactor * make sure initial config is actually overwritten with local addresses * log error on missing subgraphUri * copy change Co-authored-by: claudia.holhos <claudia.holhos@hpm.ro> Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro> Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import React, { ReactElement, useEffect, useState } from 'react'
|
|
import styles from './MarketStats.module.css'
|
|
import { gql, useQuery } from '@apollo/client'
|
|
import Conversion from '../atoms/Price/Conversion'
|
|
import PriceUnit from '../atoms/Price/PriceUnit'
|
|
import Tooltip from '../atoms/Tooltip'
|
|
|
|
const getTotalPoolsValues = gql`
|
|
query PoolsData {
|
|
poolFactories {
|
|
totalValueLocked
|
|
totalOceanLiquidity
|
|
finalizedPoolCount
|
|
}
|
|
}
|
|
`
|
|
|
|
export default function MarketStats(): ReactElement {
|
|
const [totalValueLocked, setTotalValueLocked] = useState<string>()
|
|
const [totalOceanLiquidity, setTotalOceanLiquidity] = useState<string>()
|
|
const [poolCount, setPoolCount] = useState<number>()
|
|
const { data } = useQuery(getTotalPoolsValues)
|
|
|
|
useEffect(() => {
|
|
if (!data) return
|
|
|
|
setTotalValueLocked(data.poolFactories[0].totalValueLocked)
|
|
setTotalOceanLiquidity(data.poolFactories[0].totalOceanLiquidity)
|
|
setPoolCount(data.poolFactories[0].finalizedPoolCount)
|
|
}, [data])
|
|
|
|
return (
|
|
<div className={styles.stats}>
|
|
<Conversion price={`${totalValueLocked}`} hideApproximateSymbol />{' '}
|
|
<abbr title="Total Value Locked">TVL</abbr> across{' '}
|
|
<strong>{poolCount}</strong> data set pools that contain{' '}
|
|
<PriceUnit price={totalOceanLiquidity} small className={styles.total} />,
|
|
plus datatokens for each pool.
|
|
<Tooltip
|
|
className={styles.info}
|
|
content="Counted on-chain from our pool factory. Does not filter out data sets in "
|
|
reference="list-purgatory"
|
|
link="https://github.com/oceanprotocol/list-purgatory"
|
|
/>
|
|
</div>
|
|
)
|
|
}
|