mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
small fixes
This commit is contained in:
parent
68db058782
commit
b6e2256826
@ -437,6 +437,7 @@ type GlobalTotalPoolSwapPair @entity {
|
|||||||
globalStatistic: GlobalStatistic!
|
globalStatistic: GlobalStatistic!
|
||||||
token : Token!
|
token : Token!
|
||||||
value : BigDecimal!
|
value : BigDecimal!
|
||||||
|
count: BigInt!
|
||||||
}
|
}
|
||||||
"utility type"
|
"utility type"
|
||||||
type GlobalTotalFixedSwapPair @entity {
|
type GlobalTotalFixedSwapPair @entity {
|
||||||
@ -445,6 +446,7 @@ type GlobalTotalFixedSwapPair @entity {
|
|||||||
globalStatistic: GlobalStatistic!
|
globalStatistic: GlobalStatistic!
|
||||||
token : Token!
|
token : Token!
|
||||||
value : BigDecimal!
|
value : BigDecimal!
|
||||||
|
count: BigInt!
|
||||||
}
|
}
|
||||||
type GlobalStatistic @entity {
|
type GlobalStatistic @entity {
|
||||||
id: ID!
|
id: ID!
|
||||||
|
@ -5,6 +5,7 @@ import { weiToDecimal } from './utils/generic'
|
|||||||
|
|
||||||
import { getUser } from './utils/userUtils'
|
import { getUser } from './utils/userUtils'
|
||||||
import { getToken, getNftToken } from './utils/tokenUtils'
|
import { getToken, getNftToken } from './utils/tokenUtils'
|
||||||
|
import { addDatatoken } from './utils/globalUtils'
|
||||||
|
|
||||||
export function handleNftCreated(event: NFTCreated): void {
|
export function handleNftCreated(event: NFTCreated): void {
|
||||||
log.warning('nft handleNftCreated {}', [event.params.tokenURI.toString()])
|
log.warning('nft handleNftCreated {}', [event.params.tokenURI.toString()])
|
||||||
@ -42,4 +43,5 @@ export function handleNewToken(event: TokenCreated): void {
|
|||||||
token.cap = weiToDecimal(event.params.cap.toBigDecimal(), 18)
|
token.cap = weiToDecimal(event.params.cap.toBigDecimal(), 18)
|
||||||
|
|
||||||
token.save()
|
token.save()
|
||||||
|
addDatatoken()
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
updateFixedRateExchangeSupply
|
updateFixedRateExchangeSupply
|
||||||
} from './utils/fixedRateUtils'
|
} from './utils/fixedRateUtils'
|
||||||
import { weiToDecimal } from './utils/generic'
|
import { weiToDecimal } from './utils/generic'
|
||||||
import { addFixedRateExchange } from './utils/globalUtils'
|
import { addFixedRateExchange, addFixedSwap } from './utils/globalUtils'
|
||||||
import { getToken } from './utils/tokenUtils'
|
import { getToken } from './utils/tokenUtils'
|
||||||
import { getUser } from './utils/userUtils'
|
import { getUser } from './utils/userUtils'
|
||||||
|
|
||||||
@ -188,6 +188,16 @@ export function handleSwap(event: Swapped): void {
|
|||||||
|
|
||||||
swap.save()
|
swap.save()
|
||||||
updateFixedRateExchangeSupply(event.params.exchangeId, event.address)
|
updateFixedRateExchangeSupply(event.params.exchangeId, event.address)
|
||||||
|
if (event.params.tokenOutAddress.toHexString() == fixedRateExchange.datatoken)
|
||||||
|
addFixedSwap(
|
||||||
|
event.params.tokenOutAddress.toHexString(),
|
||||||
|
swap.dataTokenAmount
|
||||||
|
)
|
||||||
|
else
|
||||||
|
addFixedSwap(
|
||||||
|
event.params.tokenOutAddress.toHexString(),
|
||||||
|
swap.baseTokenAmount
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handlePublishMarketFeeChanged(
|
export function handlePublishMarketFeeChanged(
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BigDecimal } from '@graphprotocol/graph-ts'
|
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||||
import {
|
import {
|
||||||
GlobalStatistic,
|
GlobalStatistic,
|
||||||
GlobalTotalFixedSwapPair,
|
GlobalTotalFixedSwapPair,
|
||||||
@ -71,6 +71,7 @@ export function addPoolSwap(tokenAddress: string, value: BigDecimal): void {
|
|||||||
poolSwapPair.token = tokenAddress
|
poolSwapPair.token = tokenAddress
|
||||||
}
|
}
|
||||||
poolSwapPair.value = poolSwapPair.value.plus(value)
|
poolSwapPair.value = poolSwapPair.value.plus(value)
|
||||||
|
poolSwapPair.count = poolSwapPair.count.plus(BigInt.fromI32(1))
|
||||||
|
|
||||||
poolSwapPair.save()
|
poolSwapPair.save()
|
||||||
}
|
}
|
||||||
@ -83,7 +84,7 @@ export function addFixedSwap(tokenAddress: string, value: BigDecimal): void {
|
|||||||
fixedSwapPair.token = tokenAddress
|
fixedSwapPair.token = tokenAddress
|
||||||
}
|
}
|
||||||
fixedSwapPair.value = fixedSwapPair.value.plus(value)
|
fixedSwapPair.value = fixedSwapPair.value.plus(value)
|
||||||
|
fixedSwapPair.count = fixedSwapPair.count.plus(BigInt.fromI32(1))
|
||||||
fixedSwapPair.save()
|
fixedSwapPair.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user