mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix global stats (#1512)
* fix global stats * switch graph schema to ropsten * minor fix
This commit is contained in:
parent
ce12c0e1c1
commit
a1856d79a4
@ -17,7 +17,7 @@
|
|||||||
"type-check": "tsc --noEmit",
|
"type-check": "tsc --noEmit",
|
||||||
"deploy:s3": "bash scripts/deploy-s3.sh",
|
"deploy:s3": "bash scripts/deploy-s3.sh",
|
||||||
"postinstall": "husky install",
|
"postinstall": "husky install",
|
||||||
"codegen:apollo": "apollo client:codegen --endpoint=https://v4.subgraph.rinkeby.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph --target typescript --tsFileExtension=d.ts --outputFlat src/@types/subgraph/",
|
"codegen:apollo": "apollo client:codegen --endpoint=https://v4.subgraph.ropsten.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph --target typescript --tsFileExtension=d.ts --outputFlat src/@types/subgraph/",
|
||||||
"storybook": "cross-env NODE_ENV=test start-storybook -p 6006 --quiet",
|
"storybook": "cross-env NODE_ENV=test start-storybook -p 6006 --quiet",
|
||||||
"storybook:build": "cross-env NODE_ENV=test build-storybook"
|
"storybook:build": "cross-env NODE_ENV=test build-storybook"
|
||||||
},
|
},
|
||||||
|
@ -61,7 +61,9 @@ export default function MarketStats(): ReactElement {
|
|||||||
//
|
//
|
||||||
const getMarketStats = useCallback(async () => {
|
const getMarketStats = useCallback(async () => {
|
||||||
if (!mainChainIds?.length) return
|
if (!mainChainIds?.length) return
|
||||||
|
const newData: {
|
||||||
|
[chainId: number]: FooterStatsValuesGlobalStatistics
|
||||||
|
} = {}
|
||||||
for (const chainId of mainChainIds) {
|
for (const chainId of mainChainIds) {
|
||||||
const context: OperationContext = {
|
const context: OperationContext = {
|
||||||
url: `${getSubgraphUri(
|
url: `${getSubgraphUri(
|
||||||
@ -73,15 +75,12 @@ export default function MarketStats(): ReactElement {
|
|||||||
try {
|
try {
|
||||||
const response = await fetchData(queryGlobalStatistics, null, context)
|
const response = await fetchData(queryGlobalStatistics, null, context)
|
||||||
if (!response?.data?.globalStatistics) return
|
if (!response?.data?.globalStatistics) return
|
||||||
|
newData[chainId] = response.data.globalStatistics[0]
|
||||||
setData((prevState) => ({
|
|
||||||
...prevState,
|
|
||||||
[chainId]: response.data.globalStatistics[0]
|
|
||||||
}))
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
LoggerInstance.error('Error fetching global stats: ', error.message)
|
LoggerInstance.error('Error fetching global stats: ', error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setData(newData)
|
||||||
}, [mainChainIds])
|
}, [mainChainIds])
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -96,10 +95,12 @@ export default function MarketStats(): ReactElement {
|
|||||||
//
|
//
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!data || !mainChainIds?.length) return
|
if (!data || !mainChainIds?.length) return
|
||||||
|
|
||||||
const newTotal: StatsTotal = {
|
const newTotal: StatsTotal = {
|
||||||
...initialTotal // always start calculating beginning from initial 0 values
|
...initialTotal // always start calculating beginning from initial 0 values
|
||||||
}
|
}
|
||||||
|
const newTVLInOcean: StatsValue = {}
|
||||||
|
const newTotalLiquidity: StatsValue = {}
|
||||||
|
const newPoolCount: StatsValue = {}
|
||||||
|
|
||||||
for (const chainId of mainChainIds) {
|
for (const chainId of mainChainIds) {
|
||||||
const baseTokenValue = data[chainId]?.totalLiquidity[0]?.value
|
const baseTokenValue = data[chainId]?.totalLiquidity[0]?.value
|
||||||
@ -109,25 +110,15 @@ export default function MarketStats(): ReactElement {
|
|||||||
? new Decimal(baseTokenValue).mul(2)
|
? new Decimal(baseTokenValue).mul(2)
|
||||||
: new Decimal(0)
|
: new Decimal(0)
|
||||||
|
|
||||||
setTotalValueLockedInOcean((prevState) => ({
|
newTVLInOcean[chainId] = `${totalValueLockedInOcean}`
|
||||||
...prevState,
|
|
||||||
[chainId]: `${totalValueLockedInOcean}`
|
|
||||||
}))
|
|
||||||
|
|
||||||
const totalOceanLiquidity = Number(baseTokenValue) || 0
|
const totalOceanLiquidity = Number(baseTokenValue) || 0
|
||||||
|
|
||||||
setTotalOceanLiquidity((prevState) => ({
|
newTotalLiquidity[chainId] = `${totalOceanLiquidity}`
|
||||||
...prevState,
|
|
||||||
[chainId]: `${totalOceanLiquidity}`
|
|
||||||
}))
|
|
||||||
|
|
||||||
const poolCount = data[chainId]?.poolCount || 0
|
const poolCount = data[chainId]?.poolCount || 0
|
||||||
|
|
||||||
setPoolCount((prevState) => ({
|
newPoolCount[chainId] = `${poolCount}`
|
||||||
...prevState,
|
|
||||||
[chainId]: `${poolCount}`
|
|
||||||
}))
|
|
||||||
|
|
||||||
const nftCount = data[chainId]?.nftCount || 0
|
const nftCount = data[chainId]?.nftCount || 0
|
||||||
const datatokenCount = data[chainId]?.datatokenCount || 0
|
const datatokenCount = data[chainId]?.datatokenCount || 0
|
||||||
const orderCount = data[chainId]?.orderCount || 0
|
const orderCount = data[chainId]?.orderCount || 0
|
||||||
@ -142,7 +133,9 @@ export default function MarketStats(): ReactElement {
|
|||||||
LoggerInstance.error('Error data manipulation: ', error.message)
|
LoggerInstance.error('Error data manipulation: ', error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setTotalValueLockedInOcean(newTVLInOcean)
|
||||||
|
setTotalOceanLiquidity(newTotalLiquidity)
|
||||||
|
setPoolCount(newPoolCount)
|
||||||
setTotal(newTotal)
|
setTotal(newTotal)
|
||||||
}, [data, mainChainIds, prices, currency])
|
}, [data, mainChainIds, prices, currency])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user