Skip to content

Commit b6e2256

Browse files
committed
small fixes
1 parent 68db058 commit b6e2256

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

schema.graphql

+2
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ type GlobalTotalPoolSwapPair @entity {
437437
globalStatistic: GlobalStatistic!
438438
token : Token!
439439
value : BigDecimal!
440+
count: BigInt!
440441
}
441442
"utility type"
442443
type GlobalTotalFixedSwapPair @entity {
@@ -445,6 +446,7 @@ type GlobalTotalFixedSwapPair @entity {
445446
globalStatistic: GlobalStatistic!
446447
token : Token!
447448
value : BigDecimal!
449+
count: BigInt!
448450
}
449451
type GlobalStatistic @entity {
450452
id: ID!

src/mappings/erc721Factory.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { weiToDecimal } from './utils/generic'
55

66
import { getUser } from './utils/userUtils'
77
import { getToken, getNftToken } from './utils/tokenUtils'
8+
import { addDatatoken } from './utils/globalUtils'
89

910
export function handleNftCreated(event: NFTCreated): void {
1011
log.warning('nft handleNftCreated {}', [event.params.tokenURI.toString()])
@@ -42,4 +43,5 @@ export function handleNewToken(event: TokenCreated): void {
4243
token.cap = weiToDecimal(event.params.cap.toBigDecimal(), 18)
4344

4445
token.save()
46+
addDatatoken()
4547
}

src/mappings/fixedRateExchange.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
updateFixedRateExchangeSupply
2222
} from './utils/fixedRateUtils'
2323
import { weiToDecimal } from './utils/generic'
24-
import { addFixedRateExchange } from './utils/globalUtils'
24+
import { addFixedRateExchange, addFixedSwap } from './utils/globalUtils'
2525
import { getToken } from './utils/tokenUtils'
2626
import { getUser } from './utils/userUtils'
2727

@@ -188,6 +188,16 @@ export function handleSwap(event: Swapped): void {
188188

189189
swap.save()
190190
updateFixedRateExchangeSupply(event.params.exchangeId, event.address)
191+
if (event.params.tokenOutAddress.toHexString() == fixedRateExchange.datatoken)
192+
addFixedSwap(
193+
event.params.tokenOutAddress.toHexString(),
194+
swap.dataTokenAmount
195+
)
196+
else
197+
addFixedSwap(
198+
event.params.tokenOutAddress.toHexString(),
199+
swap.baseTokenAmount
200+
)
191201
}
192202

193203
export function handlePublishMarketFeeChanged(

src/mappings/utils/globalUtils.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BigDecimal } from '@graphprotocol/graph-ts'
1+
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
22
import {
33
GlobalStatistic,
44
GlobalTotalFixedSwapPair,
@@ -71,6 +71,7 @@ export function addPoolSwap(tokenAddress: string, value: BigDecimal): void {
7171
poolSwapPair.token = tokenAddress
7272
}
7373
poolSwapPair.value = poolSwapPair.value.plus(value)
74+
poolSwapPair.count = poolSwapPair.count.plus(BigInt.fromI32(1))
7475

7576
poolSwapPair.save()
7677
}
@@ -83,7 +84,7 @@ export function addFixedSwap(tokenAddress: string, value: BigDecimal): void {
8384
fixedSwapPair.token = tokenAddress
8485
}
8586
fixedSwapPair.value = fixedSwapPair.value.plus(value)
86-
87+
fixedSwapPair.count = fixedSwapPair.count.plus(BigInt.fromI32(1))
8788
fixedSwapPair.save()
8889
}
8990

0 commit comments

Comments
 (0)