mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
fix build
This commit is contained in:
parent
89b494c765
commit
f6a0a874a2
@ -30,19 +30,19 @@ type Token @entity {
|
||||
templateId: Int
|
||||
|
||||
"number of addresses holding a balance of datatoken , TODO: can we actually calculate this? what happens when users trade the dts"
|
||||
holderCount: BigInt
|
||||
holderCount: BigInt!
|
||||
|
||||
"number of orders executed for this datatoken"
|
||||
orderCount: BigInt
|
||||
orderCount: BigInt!
|
||||
|
||||
"block time datatoken was created"
|
||||
createdTimestamp: Int
|
||||
createdTimestamp: Int!
|
||||
|
||||
"datatoken creation transaction id"
|
||||
tx: String!
|
||||
|
||||
"block number when it was created"
|
||||
block: Int
|
||||
block: Int!
|
||||
}
|
||||
|
||||
"utility type"
|
||||
@ -194,7 +194,7 @@ type PoolTransaction @entity {
|
||||
pool: Pool!
|
||||
"user that initiates the tx"
|
||||
user: User!
|
||||
type: PoolTransactionType
|
||||
type: PoolTransactionType!
|
||||
|
||||
"number of shares transfered"
|
||||
sharesTransferAmount: BigDecimal
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { OrderStarted } from '../@types/ERC20Template/ERC20Template'
|
||||
import { Order } from '../@types/schema'
|
||||
import {
|
||||
ConsumeMarketFees,
|
||||
OrderStarted,
|
||||
PublishMarketFees
|
||||
} from '../@types/templates/ERC20Template/ERC20Template'
|
||||
import { integer } from './utils/constants'
|
||||
@ -9,7 +9,11 @@ import { weiToDecimal } from './utils/generic'
|
||||
import { getToken } from './utils/tokenUtils'
|
||||
import { getUser } from './utils/userUtils'
|
||||
|
||||
function getOrderId(tx: string, tokenAddress: string, fromAddress: string) {
|
||||
function getOrderId(
|
||||
tx: string,
|
||||
tokenAddress: string,
|
||||
fromAddress: string
|
||||
): string {
|
||||
return `${tx}-${tokenAddress}-${fromAddress}`
|
||||
}
|
||||
|
||||
@ -37,7 +41,7 @@ export function handleOrderStarted(event: OrderStarted): void {
|
||||
token.decimals
|
||||
)
|
||||
|
||||
order.serviceId = event.params.serviceId
|
||||
order.serviceId = event.params.serviceId.toI32()
|
||||
|
||||
const publishMarket = getUser(event.params.publishMarketAddress.toHex())
|
||||
order.publishingMarket = publishMarket.id
|
||||
@ -53,26 +57,26 @@ export function handleOrderStarted(event: OrderStarted): void {
|
||||
token.save()
|
||||
}
|
||||
|
||||
export function handlePublishMarketFees(event: PublishMarketFees): void {
|
||||
const order = Order.load(
|
||||
getOrderId(
|
||||
event.transaction.hash.toHex(),
|
||||
event.address.toHex(),
|
||||
event.transaction.from.toHex()
|
||||
)
|
||||
)
|
||||
// export function handlePublishMarketFees(event: PublishMarketFees): void {
|
||||
// const order = Order.load(
|
||||
// getOrderId(
|
||||
// event.transaction.hash.toHex(),
|
||||
// event.address.toHex(),
|
||||
// event.transaction.from.toHex()
|
||||
// )
|
||||
// )
|
||||
|
||||
order.save()
|
||||
}
|
||||
// order.save()
|
||||
// }
|
||||
|
||||
export function handleConsumeMarketFees(event: ConsumeMarketFees): void {
|
||||
const order = Order.load(
|
||||
getOrderId(
|
||||
event.transaction.hash.toHex(),
|
||||
event.address.toHex(),
|
||||
event.transaction.from.toHex()
|
||||
)
|
||||
)
|
||||
// export function handleConsumeMarketFees(event: ConsumeMarketFees): void {
|
||||
// const order = Order.load(
|
||||
// getOrderId(
|
||||
// event.transaction.hash.toHex(),
|
||||
// event.address.toHex(),
|
||||
// event.transaction.from.toHex()
|
||||
// )
|
||||
// )
|
||||
|
||||
order.save()
|
||||
}
|
||||
// order.save()
|
||||
// }
|
||||
|
@ -197,6 +197,11 @@ export function handleSetup(event: LOG_SETUP): void {
|
||||
)
|
||||
pool.spotPrice = spotPrice
|
||||
pool.isFinalized = true
|
||||
const poolTx = PoolTransaction.load(event.transaction.hash.toHex())
|
||||
if (poolTx) {
|
||||
poolTx.type = PoolTransactionType.SETUP
|
||||
poolTx.save()
|
||||
}
|
||||
|
||||
pool.save()
|
||||
datatoken.save()
|
||||
@ -211,17 +216,14 @@ export function handleBpt(event: LOG_BPT): void {
|
||||
|
||||
const decimalBpt = weiToDecimal(event.params.bptAmount.toBigDecimal(), 18)
|
||||
|
||||
switch (poolTx.type) {
|
||||
case PoolTransactionType.JOIN: {
|
||||
// for some reason switch is broken so reverting to good old if
|
||||
if (poolTx.type === PoolTransactionType.JOIN) {
|
||||
poolShares.shares = poolShares.shares.plus(decimalBpt)
|
||||
pool.totalShares.plus(decimalBpt)
|
||||
break
|
||||
}
|
||||
case PoolTransactionType.EXIT: {
|
||||
if (poolTx.type === PoolTransactionType.EXIT) {
|
||||
poolShares.shares = poolShares.shares.minus(decimalBpt)
|
||||
pool.totalShares.minus(decimalBpt)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
poolShares.shares = weiToDecimal(event.params.bptAmount.toBigDecimal(), 18)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { BPoolCreated } from '../@types/FactoryRouter/FactoryRouter'
|
||||
import { Pool } from '../@types/schema'
|
||||
import { BPoolCreated } from '../@types/templates/BFactory/BFactory'
|
||||
import { getToken } from './utils/tokenUtils'
|
||||
|
||||
export function handleNewPool(event: BPoolCreated): void {
|
||||
|
@ -19,16 +19,17 @@ export namespace decimal {
|
||||
export const BONE = BigDecimal.fromString('1000000000000000000')
|
||||
}
|
||||
|
||||
export enum PoolTransactionType {
|
||||
JOIN = 'JOIN',
|
||||
EXIT = 'EXIT',
|
||||
SWAP = 'SWAP',
|
||||
SETUP = 'SETUP'
|
||||
// string enums don't work in wasm so this was the alternative, not optimal
|
||||
export namespace PoolTransactionType {
|
||||
export const JOIN = 'JOIN'
|
||||
export const EXIT = 'EXIT'
|
||||
export const SWAP = 'SWAP'
|
||||
export const SETUP = 'SETUP'
|
||||
}
|
||||
|
||||
export enum NftUpdateType {
|
||||
METADATA_CREATED = 'METADATA_CREATED',
|
||||
METADATA_UPDATED = 'METADATA_UPDATED',
|
||||
STATE_UPDATED = 'STATE_UPDATED',
|
||||
TOKENURI_UPDATED = 'TOKENURI_UPDATED'
|
||||
export namespace NftUpdateType {
|
||||
export const METADATA_CREATED = 'METADATA_CREATED'
|
||||
export const METADATA_UPDATED = 'METADATA_UPDATED'
|
||||
export const STATE_UPDATED = 'STATE_UPDATED'
|
||||
export const TOKENURI_UPDATED = 'TOKENURI_UPDATED'
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ export function getPoolSharesId(
|
||||
export function getPoolTransaction(
|
||||
event: ethereum.Event,
|
||||
userAddress: string,
|
||||
type: PoolTransactionType
|
||||
type: string
|
||||
): PoolTransaction {
|
||||
let poolTx = PoolTransaction.load(event.transaction.hash.toHex())
|
||||
|
||||
@ -32,7 +32,7 @@ export function getPoolTransaction(
|
||||
poolTx.type = type
|
||||
|
||||
poolTx.timestamp = event.block.timestamp.toI32()
|
||||
poolTx.tx = event.transaction.hash
|
||||
poolTx.tx = event.transaction.hash.toHex()
|
||||
poolTx.block = event.block.number.toI32()
|
||||
|
||||
poolTx.gasPrice = gweiToEth(event.transaction.gasPrice.toBigDecimal())
|
||||
@ -73,8 +73,8 @@ export function calcSpotPrice(
|
||||
const weiPrice = poolContract.try_getSpotPrice(
|
||||
Address.fromString(baseTokenAddress),
|
||||
Address.fromString(datatokenAddress)
|
||||
).reverted
|
||||
const price = weiToDecimal(weiPrice, baseTokenDecimals)
|
||||
).value
|
||||
const price = weiToDecimal(weiPrice.toBigDecimal(), baseTokenDecimals)
|
||||
|
||||
return price
|
||||
}
|
||||
@ -93,7 +93,8 @@ export function createPoolSnapshot(
|
||||
): PoolSnapshot {
|
||||
const snapshotId = getPoolSnapshotId(poolAddress, timestamp)
|
||||
|
||||
const pool = Pool.load(poolAddress)
|
||||
const pool = getPool(poolAddress)
|
||||
|
||||
const snapshot = new PoolSnapshot(snapshotId)
|
||||
|
||||
snapshot.pool = poolAddress
|
||||
@ -102,7 +103,6 @@ export function createPoolSnapshot(
|
||||
snapshot.swapVolume = decimal.ZERO
|
||||
snapshot.swapFees = decimal.ZERO
|
||||
snapshot.baseToken = pool.baseToken
|
||||
//snapshot.baseTokenLiquidity = pool.baseToken
|
||||
snapshot.datatoken = pool.datatoken
|
||||
snapshot.datatokenLiquidity = decimal.ZERO
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user