mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
capture total locked value and keep it up to date with pool updates.
This commit is contained in:
parent
ecb9e8ba52
commit
083dfe6255
@ -1,6 +1,7 @@
|
|||||||
type PoolFactory @entity {
|
type PoolFactory @entity {
|
||||||
id: ID!
|
id: ID!
|
||||||
|
|
||||||
|
totalLockedValue: BigDecimal # total value from all pools expressed in OCEAN
|
||||||
totalLiquidity: BigDecimal! # All the pools liquidity value in Ocean
|
totalLiquidity: BigDecimal! # All the pools liquidity value in Ocean
|
||||||
totalSwapVolume: BigDecimal! # All the swap volume in Ocean
|
totalSwapVolume: BigDecimal! # All the swap volume in Ocean
|
||||||
totalSwapFee: BigDecimal! # All the swap fee in Ocean
|
totalSwapFee: BigDecimal! # All the swap fee in Ocean
|
||||||
@ -28,6 +29,7 @@ type Pool @entity {
|
|||||||
totalSwapVolume: BigDecimal! # Total swap volume in OCEAN
|
totalSwapVolume: BigDecimal! # Total swap volume in OCEAN
|
||||||
totalSwapFee: BigDecimal! # Total swap fee in OCEAN
|
totalSwapFee: BigDecimal! # Total swap fee in OCEAN
|
||||||
|
|
||||||
|
lockedValue: BigDecimal! # locked value expressed in OCEAN (captures both Ocean and Datatoken)
|
||||||
datatokenReserve: BigDecimal! # Total pool reserve of Datatoken
|
datatokenReserve: BigDecimal! # Total pool reserve of Datatoken
|
||||||
oceanReserve: BigDecimal! # Total pool reserve of OCEAN
|
oceanReserve: BigDecimal! # Total pool reserve of OCEAN
|
||||||
spotPrice: BigDecimal!
|
spotPrice: BigDecimal!
|
||||||
|
@ -303,10 +303,15 @@ export function createPoolTransaction(
|
|||||||
|
|
||||||
pool.consumePrice = poolTx.consumePrice
|
pool.consumePrice = poolTx.consumePrice
|
||||||
pool.spotPrice = poolTx.spotPrice
|
pool.spotPrice = poolTx.spotPrice
|
||||||
|
const lockedValue = pool.lockedValue
|
||||||
|
pool.lockedValue = pool.oceanReserve + (pool.datatokenReserve * pool.spotPrice)
|
||||||
|
let factory = PoolFactory.load('1')
|
||||||
|
factory.totalLockedValue = factory.totalLockedValue - lockedValue + pool.lockedValue
|
||||||
|
|
||||||
pool.transactionCount = pool.transactionCount.plus(BigInt.fromI32(1))
|
pool.transactionCount = pool.transactionCount.plus(BigInt.fromI32(1))
|
||||||
|
|
||||||
pool.save()
|
pool.save()
|
||||||
|
factory.save()
|
||||||
|
|
||||||
debuglog(
|
debuglog(
|
||||||
'updated pool reserves (source, dtBalance, ocnBalance, dtReserve, ocnReserve): ',
|
'updated pool reserves (source, dtBalance, ocnBalance, dtReserve, ocnReserve): ',
|
||||||
|
@ -12,6 +12,7 @@ export function handleNewPool(event: BPoolRegistered): void {
|
|||||||
factory.totalLiquidity = ZERO_BD
|
factory.totalLiquidity = ZERO_BD
|
||||||
factory.totalSwapVolume = ZERO_BD
|
factory.totalSwapVolume = ZERO_BD
|
||||||
factory.totalSwapFee = ZERO_BD
|
factory.totalSwapFee = ZERO_BD
|
||||||
|
factory.totalLockedValue = ZERO_BD
|
||||||
|
|
||||||
factory.poolCount = 0
|
factory.poolCount = 0
|
||||||
factory.finalizedPoolCount = 0
|
factory.finalizedPoolCount = 0
|
||||||
@ -36,6 +37,7 @@ export function handleNewPool(event: BPoolRegistered): void {
|
|||||||
pool.totalShares = ZERO_BD
|
pool.totalShares = ZERO_BD
|
||||||
pool.totalSwapVolume = ZERO_BD
|
pool.totalSwapVolume = ZERO_BD
|
||||||
pool.totalSwapFee = ZERO_BD
|
pool.totalSwapFee = ZERO_BD
|
||||||
|
pool.lockedValue = ZERO_BD
|
||||||
|
|
||||||
pool.datatokenReserve = ZERO_BD
|
pool.datatokenReserve = ZERO_BD
|
||||||
pool.oceanReserve = ZERO_BD
|
pool.oceanReserve = ZERO_BD
|
||||||
|
Loading…
Reference in New Issue
Block a user