mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
testing
This commit is contained in:
parent
4353b15391
commit
449e71f75b
6849
package-lock.json
generated
6849
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -33,7 +33,7 @@
|
|||||||
"changelog": "auto-changelog -p"
|
"changelog": "auto-changelog -p"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@graphprotocol/graph-cli": "^0.33.0",
|
"@graphprotocol/graph-cli": "^0.29.0",
|
||||||
"@graphprotocol/graph-ts": "^0.27.0",
|
"@graphprotocol/graph-ts": "^0.27.0",
|
||||||
"@types/chai": "^4.3.1",
|
"@types/chai": "^4.3.1",
|
||||||
"@types/chai-spies": "^1.0.3",
|
"@types/chai-spies": "^1.0.3",
|
||||||
@ -48,20 +48,18 @@
|
|||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-prettier": "^4.2.1",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"eslint-plugin-standard": "^5.0.0",
|
"eslint-plugin-standard": "^5.0.0",
|
||||||
"mocha": "^10.0.0",
|
"mocha": "^10.0.0",
|
||||||
"mock-local-storage": "^1.1.21",
|
"mock-local-storage": "^1.1.21",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"release-it": "^15.1.4",
|
"release-it": "^15.1.0",
|
||||||
"source-map-support": "^0.5.21",
|
"source-map-support": "^0.5.21",
|
||||||
"ts-node": "^10.9.1",
|
|
||||||
"ts-node-dev": "^2.0.0",
|
|
||||||
"ts-node-register": "^1.0.0",
|
"ts-node-register": "^1.0.0",
|
||||||
"typescript": "^4.7.4"
|
"typescript": "^4.6.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@oceanprotocol/lib": "^1.1.6",
|
"@oceanprotocol/lib": "^1.1.3",
|
||||||
"cross-fetch": "^3.1.4"
|
"cross-fetch": "^3.1.4"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -120,7 +120,7 @@ type Pool @entity {
|
|||||||
id: ID!
|
id: ID!
|
||||||
|
|
||||||
"owner address, pool controller"
|
"owner address, pool controller"
|
||||||
controller: String
|
controller: String!
|
||||||
|
|
||||||
"only finalized pools are relevant to us"
|
"only finalized pools are relevant to us"
|
||||||
isFinalized: Boolean!
|
isFinalized: Boolean!
|
||||||
@ -207,7 +207,7 @@ type PoolShare @entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PoolTransaction @entity {
|
type PoolTransaction @entity {
|
||||||
"tx address + eventIndex"
|
"tx address + caller address"
|
||||||
id: ID!
|
id: ID!
|
||||||
"pool related to this tx"
|
"pool related to this tx"
|
||||||
pool: Pool!
|
pool: Pool!
|
||||||
@ -222,7 +222,6 @@ type PoolTransaction @entity {
|
|||||||
timestamp: Int!
|
timestamp: Int!
|
||||||
"pool creation transaction id"
|
"pool creation transaction id"
|
||||||
tx: String!
|
tx: String!
|
||||||
eventIndex: BigInt
|
|
||||||
"block number when it was created"
|
"block number when it was created"
|
||||||
block: Int
|
block: Int
|
||||||
|
|
||||||
@ -247,11 +246,9 @@ type OrderReuse @entity {
|
|||||||
id: ID!
|
id: ID!
|
||||||
order: Order!
|
order: Order!
|
||||||
caller: String!
|
caller: String!
|
||||||
createdTimestamp: Int!
|
createdTimestamp: BigInt!
|
||||||
tx: String!
|
tx: String!
|
||||||
block: Int!
|
block: BigInt!
|
||||||
providerFee: String
|
|
||||||
providerFeeValidUntil: BigInt
|
|
||||||
}
|
}
|
||||||
type Order @entity {
|
type Order @entity {
|
||||||
"transaction hash - token address - from address"
|
"transaction hash - token address - from address"
|
||||||
@ -268,8 +265,6 @@ type Order @entity {
|
|||||||
publishingMarket: User
|
publishingMarket: User
|
||||||
publishingMarketToken: Token #
|
publishingMarketToken: Token #
|
||||||
publishingMarketAmmount: BigDecimal #call contract to get fee amount
|
publishingMarketAmmount: BigDecimal #call contract to get fee amount
|
||||||
providerFee: String
|
|
||||||
providerFeeValidUntil: BigInt
|
|
||||||
|
|
||||||
consumerMarket: User
|
consumerMarket: User
|
||||||
consumerMarketToken: Token #
|
consumerMarketToken: Token #
|
||||||
@ -502,19 +497,6 @@ type GlobalStatistic @entity {
|
|||||||
version: String
|
version: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type OPC @entity {
|
|
||||||
id: ID!
|
|
||||||
"fee in percent for swaps involving OPC approved tokens"
|
|
||||||
swapOceanFee: BigDecimal
|
|
||||||
"fee in percent for swaps involving non OPC approved tokens"
|
|
||||||
swapNonOceanFee: BigDecimal
|
|
||||||
"fee in percent taken by OPC from orderFees"
|
|
||||||
orderFee: BigDecimal
|
|
||||||
"fee in percent taken by OPC from providerFees"
|
|
||||||
providerFee: BigDecimal
|
|
||||||
approvedTokens: [Token!]
|
|
||||||
}
|
|
||||||
|
|
||||||
enum NftUpdateType {
|
enum NftUpdateType {
|
||||||
METADATA_CREATED,
|
METADATA_CREATED,
|
||||||
METADATA_UPDATED,
|
METADATA_UPDATED,
|
||||||
@ -552,4 +534,3 @@ type Template @entity{
|
|||||||
ssTemplates: [String!]
|
ssTemplates: [String!]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,8 +10,7 @@ import {
|
|||||||
RemovedMinter,
|
RemovedMinter,
|
||||||
RemovedPaymentManager,
|
RemovedPaymentManager,
|
||||||
CleanedPermissions,
|
CleanedPermissions,
|
||||||
OrderReused,
|
OrderReused
|
||||||
ProviderFee
|
|
||||||
} from '../@types/templates/ERC20Template/ERC20Template'
|
} from '../@types/templates/ERC20Template/ERC20Template'
|
||||||
|
|
||||||
import { integer } from './utils/constants'
|
import { integer } from './utils/constants'
|
||||||
@ -19,7 +18,14 @@ import { weiToDecimal } from './utils/generic'
|
|||||||
import { addOrder } from './utils/globalUtils'
|
import { addOrder } from './utils/globalUtils'
|
||||||
import { getToken, getUSDValue } from './utils/tokenUtils'
|
import { getToken, getUSDValue } from './utils/tokenUtils'
|
||||||
import { getUser } from './utils/userUtils'
|
import { getUser } from './utils/userUtils'
|
||||||
import { getOrderId } from './utils/orderUtils'
|
|
||||||
|
function getOrderId(
|
||||||
|
tx: string,
|
||||||
|
tokenAddress: string,
|
||||||
|
fromAddress: string
|
||||||
|
): string {
|
||||||
|
return `${tx}-${tokenAddress}-${fromAddress}`
|
||||||
|
}
|
||||||
|
|
||||||
export function handleOrderStarted(event: OrderStarted): void {
|
export function handleOrderStarted(event: OrderStarted): void {
|
||||||
const order = new Order(
|
const order = new Order(
|
||||||
@ -93,9 +99,9 @@ export function handlerOrderReused(event: OrderReused): void {
|
|||||||
const reuseOrder = new OrderReuse(event.transaction.hash.toHex())
|
const reuseOrder = new OrderReuse(event.transaction.hash.toHex())
|
||||||
reuseOrder.order = orderId
|
reuseOrder.order = orderId
|
||||||
reuseOrder.caller = event.params.caller.toHexString()
|
reuseOrder.caller = event.params.caller.toHexString()
|
||||||
reuseOrder.createdTimestamp = event.params.timestamp.toI32()
|
reuseOrder.createdTimestamp = event.params.timestamp
|
||||||
reuseOrder.tx = event.transaction.hash.toHex()
|
reuseOrder.tx = event.transaction.hash.toHex()
|
||||||
reuseOrder.block = event.params.number.toI32()
|
reuseOrder.block = event.params.number
|
||||||
|
|
||||||
reuseOrder.save()
|
reuseOrder.save()
|
||||||
}
|
}
|
||||||
@ -198,43 +204,26 @@ export function handleNewPaymentCollector(event: NewPaymentCollector): void {
|
|||||||
token.save()
|
token.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleProviderFee(event: ProviderFee): void {
|
// export function handlePublishMarketFees(event: PublishMarketFees): void {
|
||||||
const providerFee: string = `{"providerFeeAddress": "${event.params.providerFeeAddress.toHex()}", "providerFeeToken": "${event.params.providerFeeToken.toHex()}", "providerFeeAmount": "${
|
// const order = Order.load(
|
||||||
event.params.providerFeeAmount
|
// getOrderId(
|
||||||
}", "providerData": "${event.params.providerData.toHexString()}", "v": "${
|
// event.transaction.hash.toHex(),
|
||||||
event.params.v
|
// event.address.toHex(),
|
||||||
}", "r": "${event.params.r.toHexString()}", "s": "${event.params.s.toHexString()}", "validUntil": "${
|
// event.transaction.from.toHex()
|
||||||
event.params.validUntil
|
// )
|
||||||
}"}`
|
// )
|
||||||
|
|
||||||
const orderId = getOrderId(
|
// order.save()
|
||||||
event.transaction.hash.toHex(),
|
// }
|
||||||
event.address.toHex(),
|
|
||||||
event.transaction.from.toHex()
|
|
||||||
)
|
|
||||||
const order = Order.load(orderId)
|
|
||||||
|
|
||||||
if (order) {
|
// export function handleConsumeMarketFees(event: ConsumeMarketFees): void {
|
||||||
order.providerFee = providerFee
|
// const order = Order.load(
|
||||||
order.providerFeeValidUntil = event.params.validUntil
|
// getOrderId(
|
||||||
order.save()
|
// event.transaction.hash.toHex(),
|
||||||
return
|
// event.address.toHex(),
|
||||||
}
|
// event.transaction.from.toHex()
|
||||||
|
// )
|
||||||
|
// )
|
||||||
|
|
||||||
let orderReuse = OrderReuse.load(event.transaction.hash.toHex())
|
// order.save()
|
||||||
if (orderReuse) {
|
// }
|
||||||
orderReuse.providerFee = providerFee
|
|
||||||
orderReuse.providerFeeValidUntil = event.params.validUntil
|
|
||||||
orderReuse.save()
|
|
||||||
} else {
|
|
||||||
orderReuse = new OrderReuse(event.transaction.hash.toHex())
|
|
||||||
orderReuse.providerFee = providerFee
|
|
||||||
orderReuse.providerFeeValidUntil = event.params.validUntil
|
|
||||||
orderReuse.order = orderId
|
|
||||||
orderReuse.createdTimestamp = event.block.timestamp.toI32()
|
|
||||||
orderReuse.tx = event.transaction.hash.toHex()
|
|
||||||
orderReuse.block = event.block.number.toI32()
|
|
||||||
orderReuse.caller = event.transaction.from.toHex()
|
|
||||||
orderReuse.save()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
|
import { log } from '@graphprotocol/graph-ts'
|
||||||
import {
|
import {
|
||||||
NewPool,
|
NewPool,
|
||||||
TokenAdded,
|
|
||||||
TokenRemoved,
|
|
||||||
OPCFeeChanged,
|
|
||||||
FactoryRouter,
|
|
||||||
SSContractAdded,
|
SSContractAdded,
|
||||||
SSContractRemoved,
|
SSContractRemoved,
|
||||||
FixedRateContractAdded,
|
FixedRateContractAdded,
|
||||||
@ -11,95 +8,19 @@ import {
|
|||||||
DispenserContractAdded,
|
DispenserContractAdded,
|
||||||
DispenserContractRemoved
|
DispenserContractRemoved
|
||||||
} from '../@types/FactoryRouter/FactoryRouter'
|
} from '../@types/FactoryRouter/FactoryRouter'
|
||||||
import { BigInt } from '@graphprotocol/graph-ts'
|
|
||||||
import { Pool } from '../@types/schema'
|
import { Pool } from '../@types/schema'
|
||||||
import { BPool, FixedRateExchange, Dispenser } from '../@types/templates'
|
import { BPool, FixedRateExchange, Dispenser } from '../@types/templates'
|
||||||
import { addPool, getOPC, getTemplates } from './utils/globalUtils'
|
import { addPool, getTemplates } from './utils/globalUtils'
|
||||||
import { weiToDecimal } from './utils/generic'
|
|
||||||
import { getToken } from './utils/tokenUtils'
|
|
||||||
|
|
||||||
export function handleNewPool(event: NewPool): void {
|
export function handleNewPool(event: NewPool): void {
|
||||||
BPool.create(event.params.poolAddress)
|
BPool.create(event.params.poolAddress)
|
||||||
|
log.error('POOL START CREATE', [])
|
||||||
const pool = new Pool(event.params.poolAddress.toHexString())
|
const pool = new Pool(event.params.poolAddress.toHexString())
|
||||||
pool.save()
|
pool.save()
|
||||||
|
log.error('POOL CREATED', [])
|
||||||
addPool()
|
addPool()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleOPCFeeChanged(event: OPCFeeChanged): void {
|
|
||||||
const opc = getOPC()
|
|
||||||
const decimals = BigInt.fromI32(18).toI32()
|
|
||||||
opc.swapOceanFee = weiToDecimal(
|
|
||||||
event.params.newSwapOceanFee.toBigDecimal(),
|
|
||||||
decimals
|
|
||||||
)
|
|
||||||
opc.swapNonOceanFee = weiToDecimal(
|
|
||||||
event.params.newSwapNonOceanFee.toBigDecimal(),
|
|
||||||
decimals
|
|
||||||
)
|
|
||||||
opc.orderFee = weiToDecimal(
|
|
||||||
event.params.newConsumeFee.toBigDecimal(),
|
|
||||||
decimals
|
|
||||||
)
|
|
||||||
opc.providerFee = weiToDecimal(
|
|
||||||
event.params.newProviderFee.toBigDecimal(),
|
|
||||||
decimals
|
|
||||||
)
|
|
||||||
opc.save()
|
|
||||||
}
|
|
||||||
|
|
||||||
export function handleTokenAdded(event: TokenAdded): void {
|
|
||||||
const contract = FactoryRouter.bind(event.address)
|
|
||||||
const oceanFees = contract.try_getOPCFees()
|
|
||||||
if (oceanFees.reverted) return
|
|
||||||
|
|
||||||
const opc = getOPC()
|
|
||||||
const decimals = BigInt.fromI32(18).toI32()
|
|
||||||
opc.swapOceanFee = weiToDecimal(
|
|
||||||
oceanFees.value.value0.toBigDecimal(),
|
|
||||||
decimals
|
|
||||||
)
|
|
||||||
opc.swapNonOceanFee = weiToDecimal(
|
|
||||||
oceanFees.value.value1.toBigDecimal(),
|
|
||||||
decimals
|
|
||||||
)
|
|
||||||
|
|
||||||
const newOrderFee = contract.try_getOPCConsumeFee()
|
|
||||||
if (newOrderFee.reverted) return
|
|
||||||
|
|
||||||
const newProviderFee = contract.try_getOPCProviderFee()
|
|
||||||
if (newProviderFee.reverted) return
|
|
||||||
opc.orderFee = weiToDecimal(newOrderFee.value.toBigDecimal(), decimals)
|
|
||||||
opc.providerFee = weiToDecimal(newProviderFee.value.toBigDecimal(), decimals)
|
|
||||||
|
|
||||||
// add token to approvedTokens
|
|
||||||
let existingTokens: string[]
|
|
||||||
if (!opc.approvedTokens) existingTokens = []
|
|
||||||
else existingTokens = opc.approvedTokens as string[]
|
|
||||||
if (!existingTokens.includes(event.params.token.toHexString())) {
|
|
||||||
const newToken = getToken(event.params.token, false)
|
|
||||||
existingTokens.push(newToken.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
opc.approvedTokens = existingTokens
|
|
||||||
|
|
||||||
opc.save()
|
|
||||||
}
|
|
||||||
|
|
||||||
export function handleTokenRemoved(event: TokenRemoved): void {
|
|
||||||
const opc = getOPC()
|
|
||||||
const newList: string[] = []
|
|
||||||
let existingTokens: string[]
|
|
||||||
if (!opc.approvedTokens) existingTokens = []
|
|
||||||
else existingTokens = opc.approvedTokens as string[]
|
|
||||||
if (!existingTokens || existingTokens.length < 1) return
|
|
||||||
while (existingTokens.length > 0) {
|
|
||||||
const role = existingTokens.shift().toString()
|
|
||||||
if (!role) break
|
|
||||||
if (role !== event.params.token.toHexString()) newList.push(role)
|
|
||||||
}
|
|
||||||
opc.approvedTokens = newList
|
|
||||||
opc.save()
|
|
||||||
}
|
|
||||||
export function handleSSContractAdded(event: SSContractAdded): void {
|
export function handleSSContractAdded(event: SSContractAdded): void {
|
||||||
// add token to approvedTokens
|
// add token to approvedTokens
|
||||||
const templates = getTemplates()
|
const templates = getTemplates()
|
||||||
|
@ -32,12 +32,7 @@ import { getUser } from './utils/userUtils'
|
|||||||
export function handleJoin(event: LOG_JOIN): void {
|
export function handleJoin(event: LOG_JOIN): void {
|
||||||
const pool = getPool(event.address.toHex())
|
const pool = getPool(event.address.toHex())
|
||||||
const user = getUser(event.params.caller.toHex())
|
const user = getUser(event.params.caller.toHex())
|
||||||
const poolTx = getPoolTransaction(
|
const poolTx = getPoolTransaction(event, user.id, PoolTransactionType.JOIN)
|
||||||
event,
|
|
||||||
user.id,
|
|
||||||
PoolTransactionType.JOIN,
|
|
||||||
event.logIndex
|
|
||||||
)
|
|
||||||
|
|
||||||
pool.transactionCount = pool.transactionCount.plus(integer.ONE)
|
pool.transactionCount = pool.transactionCount.plus(integer.ONE)
|
||||||
pool.joinCount = pool.joinCount.plus(integer.ONE)
|
pool.joinCount = pool.joinCount.plus(integer.ONE)
|
||||||
@ -77,12 +72,7 @@ export function handleJoin(event: LOG_JOIN): void {
|
|||||||
export function handleExit(event: LOG_EXIT): void {
|
export function handleExit(event: LOG_EXIT): void {
|
||||||
const pool = getPool(event.address.toHex())
|
const pool = getPool(event.address.toHex())
|
||||||
const user = getUser(event.params.caller.toHex())
|
const user = getUser(event.params.caller.toHex())
|
||||||
const poolTx = getPoolTransaction(
|
const poolTx = getPoolTransaction(event, user.id, PoolTransactionType.EXIT)
|
||||||
event,
|
|
||||||
user.id,
|
|
||||||
PoolTransactionType.EXIT,
|
|
||||||
event.logIndex
|
|
||||||
)
|
|
||||||
|
|
||||||
pool.transactionCount = pool.transactionCount.plus(integer.ONE)
|
pool.transactionCount = pool.transactionCount.plus(integer.ONE)
|
||||||
pool.joinCount = pool.joinCount.plus(integer.ONE)
|
pool.joinCount = pool.joinCount.plus(integer.ONE)
|
||||||
@ -119,12 +109,7 @@ export function handleExit(event: LOG_EXIT): void {
|
|||||||
export function handleSwap(event: LOG_SWAP): void {
|
export function handleSwap(event: LOG_SWAP): void {
|
||||||
const pool = getPool(event.address.toHex())
|
const pool = getPool(event.address.toHex())
|
||||||
const user = getUser(event.params.caller.toHex())
|
const user = getUser(event.params.caller.toHex())
|
||||||
const poolTx = getPoolTransaction(
|
const poolTx = getPoolTransaction(event, user.id, PoolTransactionType.SWAP)
|
||||||
event,
|
|
||||||
user.id,
|
|
||||||
PoolTransactionType.SWAP,
|
|
||||||
event.logIndex
|
|
||||||
)
|
|
||||||
|
|
||||||
pool.transactionCount = pool.transactionCount.plus(integer.ONE)
|
pool.transactionCount = pool.transactionCount.plus(integer.ONE)
|
||||||
pool.joinCount = pool.joinCount.plus(integer.ONE)
|
pool.joinCount = pool.joinCount.plus(integer.ONE)
|
||||||
@ -242,8 +227,7 @@ export function handleSetup(event: LOG_SETUP): void {
|
|||||||
const poolTx = getPoolTransaction(
|
const poolTx = getPoolTransaction(
|
||||||
event,
|
event,
|
||||||
fromUser.id,
|
fromUser.id,
|
||||||
PoolTransactionType.SETUP,
|
PoolTransactionType.SETUP
|
||||||
event.logIndex
|
|
||||||
)
|
)
|
||||||
poolTx.type = PoolTransactionType.SETUP
|
poolTx.type = PoolTransactionType.SETUP
|
||||||
poolTx.baseToken = token.id
|
poolTx.baseToken = token.id
|
||||||
@ -275,12 +259,7 @@ export function handlerBptTransfer(event: Transfer): void {
|
|||||||
const toAddress = event.params.dst.toHexString()
|
const toAddress = event.params.dst.toHexString()
|
||||||
const poolAddress = event.address.toHex()
|
const poolAddress = event.address.toHex()
|
||||||
const caller = getUser(event.transaction.from.toHex())
|
const caller = getUser(event.transaction.from.toHex())
|
||||||
const poolTx = getPoolTransaction(
|
const poolTx = getPoolTransaction(event, caller.id, PoolTransactionType.SWAP)
|
||||||
event,
|
|
||||||
caller.id,
|
|
||||||
PoolTransactionType.SWAP,
|
|
||||||
event.logIndex
|
|
||||||
)
|
|
||||||
|
|
||||||
// btoken has 18 decimals
|
// btoken has 18 decimals
|
||||||
const ammount = weiToDecimal(event.params.amt.toBigDecimal(), 18)
|
const ammount = weiToDecimal(event.params.amt.toBigDecimal(), 18)
|
||||||
|
@ -4,7 +4,6 @@ import {
|
|||||||
GlobalTotalFixedSwapPair,
|
GlobalTotalFixedSwapPair,
|
||||||
GlobalTotalLiquidityPair,
|
GlobalTotalLiquidityPair,
|
||||||
GlobalTotalPoolSwapPair,
|
GlobalTotalPoolSwapPair,
|
||||||
OPC,
|
|
||||||
Template
|
Template
|
||||||
} from '../../@types/schema'
|
} from '../../@types/schema'
|
||||||
|
|
||||||
@ -26,15 +25,6 @@ export function getGlobalStats(): GlobalStatistic {
|
|||||||
return globalStats
|
return globalStats
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOPC(): OPC {
|
|
||||||
let globalStats = OPC.load(GLOBAL_ID)
|
|
||||||
if (!globalStats) {
|
|
||||||
globalStats = new OPC(GLOBAL_ID)
|
|
||||||
globalStats.save()
|
|
||||||
}
|
|
||||||
return globalStats
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getTemplates(): Template {
|
export function getTemplates(): Template {
|
||||||
let templates = Template.load(GLOBAL_ID)
|
let templates = Template.load(GLOBAL_ID)
|
||||||
if (!templates) {
|
if (!templates) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Address, BigDecimal, BigInt, ethereum } from '@graphprotocol/graph-ts'
|
import { Address, BigDecimal, ethereum } from '@graphprotocol/graph-ts'
|
||||||
import {
|
import {
|
||||||
Pool,
|
Pool,
|
||||||
PoolShare,
|
PoolShare,
|
||||||
@ -19,20 +19,19 @@ export function getPoolShareId(
|
|||||||
|
|
||||||
export function getPoolTransactionId(
|
export function getPoolTransactionId(
|
||||||
txHash: string,
|
txHash: string,
|
||||||
eventIndex: BigInt
|
userAddress: string
|
||||||
): string {
|
): string {
|
||||||
return `${txHash}-` + eventIndex.toString()
|
return `${txHash}-${userAddress}`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPoolTransaction(
|
export function getPoolTransaction(
|
||||||
event: ethereum.Event,
|
event: ethereum.Event,
|
||||||
userAddress: string,
|
userAddress: string,
|
||||||
type: string,
|
type: string
|
||||||
eventIndex: BigInt
|
|
||||||
): PoolTransaction {
|
): PoolTransaction {
|
||||||
const txId = getPoolTransactionId(
|
const txId = getPoolTransactionId(
|
||||||
event.transaction.hash.toHexString(),
|
event.transaction.hash.toHexString(),
|
||||||
eventIndex
|
userAddress
|
||||||
)
|
)
|
||||||
let poolTx = PoolTransaction.load(txId)
|
let poolTx = PoolTransaction.load(txId)
|
||||||
|
|
||||||
@ -46,7 +45,6 @@ export function getPoolTransaction(
|
|||||||
|
|
||||||
poolTx.timestamp = event.block.timestamp.toI32()
|
poolTx.timestamp = event.block.timestamp.toI32()
|
||||||
poolTx.tx = event.transaction.hash.toHex()
|
poolTx.tx = event.transaction.hash.toHex()
|
||||||
poolTx.eventIndex = eventIndex
|
|
||||||
poolTx.block = event.block.number.toI32()
|
poolTx.block = event.block.number.toI32()
|
||||||
|
|
||||||
poolTx.gasPrice = gweiToEth(event.transaction.gasPrice.toBigDecimal())
|
poolTx.gasPrice = gweiToEth(event.transaction.gasPrice.toBigDecimal())
|
||||||
|
@ -51,12 +51,6 @@ dataSources:
|
|||||||
eventHandlers:
|
eventHandlers:
|
||||||
- event: NewPool(indexed address,bool)
|
- event: NewPool(indexed address,bool)
|
||||||
handler: handleNewPool
|
handler: handleNewPool
|
||||||
- event: TokenAdded(indexed address,indexed address)
|
|
||||||
handler: handleTokenAdded
|
|
||||||
- event: TokenRemoved(indexed address,indexed address)
|
|
||||||
handler: handleTokenRemoved
|
|
||||||
- event: OPCFeeChanged(indexed address,uint256,uint256,uint256,uint256)
|
|
||||||
handler: handleOPCFeeChanged
|
|
||||||
- event: SSContractAdded(indexed address,indexed address)
|
- event: SSContractAdded(indexed address,indexed address)
|
||||||
handler: handleSSContractAdded
|
handler: handleSSContractAdded
|
||||||
- event: SSContractRemoved(indexed address,indexed address)
|
- event: SSContractRemoved(indexed address,indexed address)
|
||||||
@ -113,8 +107,6 @@ templates:
|
|||||||
handler: handleRemovedPaymentManager
|
handler: handleRemovedPaymentManager
|
||||||
- event: CleanedPermissions(indexed address,uint256,uint256)
|
- event: CleanedPermissions(indexed address,uint256,uint256)
|
||||||
handler: handleCleanedPermissions
|
handler: handleCleanedPermissions
|
||||||
- event: ProviderFee(indexed address,indexed address,uint256,bytes,uint8,bytes32,bytes32,uint256)
|
|
||||||
handler: handleProviderFee
|
|
||||||
|
|
||||||
- name: BPool
|
- name: BPool
|
||||||
kind: ethereum/contract
|
kind: ethereum/contract
|
||||||
|
Loading…
Reference in New Issue
Block a user