mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
pool graph tinkering with poolSnapshots
This commit is contained in:
parent
c28cdd318f
commit
8996722fcb
@ -105,16 +105,17 @@ const graphTypes = ['Liquidity', 'Price']
|
|||||||
|
|
||||||
const poolHistory = gql`
|
const poolHistory = gql`
|
||||||
query PoolHistory($id: String!, $block: Int) {
|
query PoolHistory($id: String!, $block: Int) {
|
||||||
poolTransactions(
|
poolSnapshots(
|
||||||
first: 1000
|
first: 1000
|
||||||
where: { pool: $id, block_gt: $block }
|
where: { pool: $id }
|
||||||
orderBy: block
|
block: { number_gte: $block }
|
||||||
|
orderBy: date
|
||||||
subgraphError: deny
|
subgraphError: deny
|
||||||
) {
|
) {
|
||||||
block
|
date
|
||||||
timestamp
|
spotPrice
|
||||||
baseTokenValue
|
baseTokenLiquidity
|
||||||
datatokenValue
|
datatokenLiquidity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@ -194,8 +195,8 @@ export default function Graph(): ReactElement {
|
|||||||
|
|
||||||
const latestTimestamps = [
|
const latestTimestamps = [
|
||||||
...timestamps,
|
...timestamps,
|
||||||
...data.poolTransactions.map((item) => {
|
...data.poolSnapshots.map((item) => {
|
||||||
const date = new Date(item.timestamp * 1000)
|
const date = new Date(item.date * 1000)
|
||||||
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
|
return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
@ -203,25 +204,22 @@ export default function Graph(): ReactElement {
|
|||||||
|
|
||||||
const latestLiquidityHistory = [
|
const latestLiquidityHistory = [
|
||||||
...liquidityHistory,
|
...liquidityHistory,
|
||||||
...data.poolTransactions.map((item) => item.baseTokenValue)
|
...data.poolSnapshots.map((item) => item.baseTokenLiquidity)
|
||||||
]
|
]
|
||||||
|
|
||||||
setLiquidityHistory(latestLiquidityHistory)
|
setLiquidityHistory(latestLiquidityHistory)
|
||||||
|
|
||||||
const latestPriceHistory = [
|
const latestPriceHistory = [
|
||||||
...priceHistory,
|
...priceHistory,
|
||||||
...data.poolTransactions.map((item) => item.datatokenValue)
|
...data.poolSnapshots.map((item) => item.datatokenLiquidity)
|
||||||
]
|
]
|
||||||
|
|
||||||
setPriceHistory(latestPriceHistory)
|
setPriceHistory(latestPriceHistory)
|
||||||
|
|
||||||
if (data.poolTransactions.length > 0) {
|
if (data.poolSnapshots.length > 0) {
|
||||||
const newBlock =
|
const newBlock = data.poolSnapshots[data.poolSnapshots.length - 1].block
|
||||||
data.poolTransactions[data.poolTransactions.length - 1].block
|
|
||||||
if (newBlock === lastBlock) return
|
if (newBlock === lastBlock) return
|
||||||
setLastBlock(
|
setLastBlock(data.poolSnapshots[data.poolSnapshots.length - 1].block)
|
||||||
data.poolTransactions[data.poolTransactions.length - 1].block
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
setGraphData({
|
setGraphData({
|
||||||
labels: latestTimestamps.slice(0),
|
labels: latestTimestamps.slice(0),
|
||||||
|
Loading…
Reference in New Issue
Block a user