Skip to content

Commit dd7710b

Browse files
committed
schema update + other
1 parent c708e83 commit dd7710b

7 files changed

+204
-124
lines changed

schema.graphql

+193-106
Large diffs are not rendered by default.

src/mappings/dispenser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '../@types/Dispenser/Dispenser'
88
import { DispenserCreated } from '../@types/ERC721Factory/ERC721Factory'
99
import { DispenserTransaction } from '../@types/schema'
10-
import { ZERO_BD } from './utils/constants'
10+
import { decimal } from './utils/constants'
1111
import { createDispenser, getDispenser } from './utils/dispenserUtils'
1212
import { getUser } from './utils/userUtils'
1313

@@ -60,6 +60,6 @@ export function handleTokensDispensed(event: TokensDispensed): void {
6060

6161
export function handleOwnerWinthdraw(event: OwnerWithdrawed): void {
6262
const dispenser = getDispenser(event.params.datatoken.toHex())
63-
dispenser.balance = ZERO_BD
63+
dispenser.balance = decimal.ZERO_BD
6464
dispenser.save()
6565
}

src/mappings/erc721Factory.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NFTCreated, TokenCreated } from '../@types/ERC721Factory/ERC721Factory'
22
import { Nft, Token } from '../@types/schema'
3-
import { ZERO_BD } from './utils/constants'
3+
import { decimal } from './utils/constants'
44
import { getUser } from './utils/userUtils'
55

66
export function handleNftCreated(event: NFTCreated): void {
@@ -28,6 +28,6 @@ export function handleNewToken(event: TokenCreated): void {
2828

2929
token.name = event.params.tokenName.toString()
3030
token.decimals = 18
31-
token.supply = ZERO_BD
31+
token.supply = decimal.ZERO_BD
3232
token.save()
3333
}

src/mappings/fixedRateExchange.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
FixedRateExchangeSwap,
1414
FixedRateExchangeUpdate
1515
} from '../@types/schema'
16-
import { tokenToDecimal } from '../helpers'
1716
import { getFixedRateExchange, getUpdateOrSwapId } from './utils/fixedRateUtils'
17+
import { tokenToDecimal } from './utils/generic'
1818
import { getToken } from './utils/tokenUtils'
1919
import { getUser } from './utils/userUtils'
2020

@@ -146,8 +146,9 @@ export function handleSwap(event: Swapped): void {
146146

147147
// reduce supply if the fixed rate is not minting tokens
148148
if (fixedRateExchange.isMinter || fixedRateExchange.withMint) {
149-
fixedRateExchange.supply =
150-
fixedRateExchange.supply - event.params.dataTokenSwappedAmount
149+
fixedRateExchange.supply = fixedRateExchange.supply.minus(
150+
event.params.dataTokenSwappedAmount
151+
)
151152
}
152153

153154
const swap = new FixedRateExchangeSwap(

src/mappings/pool.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Pool, PoolTransaction } from '../@types/schema'
22
import { LOG_JOIN } from '../@types/templates/BPool/BPool'
3-
import { integer, PoolTransactionType } from './utils/constants'
3+
import { integer } from './utils/constants'
44
import { gweiToEth } from './utils/generic'
55
import { getUser } from './utils/userUtils'
66

@@ -17,7 +17,6 @@ export function handleJoin(event: LOG_JOIN): void {
1717
const user = getUser(event.params.caller.toHex())
1818
poolTx.user = user.id
1919
poolTx.pool = pool.id
20-
poolTx.type = PoolTransactionType.JOIN
2120

2221
poolTx.timestamp = event.block.timestamp.toI32()
2322
poolTx.tx = event.transaction.hash

src/mappings/poolFactory.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function handleNewPool(event: BPoolCreated): void {
1818
pool.datatoken = datatoken.id
1919

2020
pool.owner = event.params.registeredBy.toHex()
21-
21+
2222
pool.createdTimestamp = event.block.timestamp.toI32()
2323
pool.tx = event.transaction.hash
2424
pool.block = event.block.number.toI32()

src/mappings/utils/constants.ts

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
22

33
export const ENABLE_DEBUG = true
44

5-
export const enum PoolTransactionType {
6-
JOIN = 'join',
7-
EXIT = 'exit',
8-
SWAP = 'swap',
9-
SETUP = 'setup'
10-
}
11-
125
export namespace integer {
136
export const NEGATIVE_ONE = BigInt.fromI32(-1)
147
export const ZERO = BigInt.fromI32(0)
@@ -17,7 +10,7 @@ export namespace integer {
1710
export const ONE_BASE_18 = BigInt.fromI32(10).pow(18 as u8)
1811
}
1912

20-
export namespace deciaml {
13+
export namespace decimal {
2114
export const ZERO_BD = BigDecimal.fromString('0.0')
2215
export const MINUS_1_BD = BigDecimal.fromString('-1.0')
2316
export const ONE_BD = BigDecimal.fromString('1.0')

0 commit comments

Comments
 (0)