small fixes

This commit is contained in:
alexcos20 2022-02-20 05:51:01 -08:00
parent 68db058782
commit b6e2256826
4 changed files with 18 additions and 3 deletions

View File

@ -437,6 +437,7 @@ type GlobalTotalPoolSwapPair @entity {
globalStatistic: GlobalStatistic!
token : Token!
value : BigDecimal!
count: BigInt!
}
"utility type"
type GlobalTotalFixedSwapPair @entity {
@ -445,6 +446,7 @@ type GlobalTotalFixedSwapPair @entity {
globalStatistic: GlobalStatistic!
token : Token!
value : BigDecimal!
count: BigInt!
}
type GlobalStatistic @entity {
id: ID!

View File

@ -5,6 +5,7 @@ import { weiToDecimal } from './utils/generic'
import { getUser } from './utils/userUtils'
import { getToken, getNftToken } from './utils/tokenUtils'
import { addDatatoken } from './utils/globalUtils'
export function handleNftCreated(event: NFTCreated): void {
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.save()
addDatatoken()
}

View File

@ -21,7 +21,7 @@ import {
updateFixedRateExchangeSupply
} from './utils/fixedRateUtils'
import { weiToDecimal } from './utils/generic'
import { addFixedRateExchange } from './utils/globalUtils'
import { addFixedRateExchange, addFixedSwap } from './utils/globalUtils'
import { getToken } from './utils/tokenUtils'
import { getUser } from './utils/userUtils'
@ -188,6 +188,16 @@ export function handleSwap(event: Swapped): void {
swap.save()
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(

View File

@ -1,4 +1,4 @@
import { BigDecimal } from '@graphprotocol/graph-ts'
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
import {
GlobalStatistic,
GlobalTotalFixedSwapPair,
@ -71,6 +71,7 @@ export function addPoolSwap(tokenAddress: string, value: BigDecimal): void {
poolSwapPair.token = tokenAddress
}
poolSwapPair.value = poolSwapPair.value.plus(value)
poolSwapPair.count = poolSwapPair.count.plus(BigInt.fromI32(1))
poolSwapPair.save()
}
@ -83,7 +84,7 @@ export function addFixedSwap(tokenAddress: string, value: BigDecimal): void {
fixedSwapPair.token = tokenAddress
}
fixedSwapPair.value = fixedSwapPair.value.plus(value)
fixedSwapPair.count = fixedSwapPair.count.plus(BigInt.fromI32(1))
fixedSwapPair.save()
}