fix deploy

This commit is contained in:
mihaisc 2021-12-07 11:47:58 +02:00
parent 736c5bb5db
commit 271ea50672
11 changed files with 200 additions and 199 deletions

View File

@ -1,7 +1,7 @@
version: '3'
services:
graph-node:
image: oceanprotocol/graph-node:latest
image: graphprotocol/graph-node:v0.25.0
ports:
- '8000:8000'
- '8001:8001'
@ -17,7 +17,7 @@ services:
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: 'ipfs:5001'
ethereum: 'barge:http://172.15.0.3:8545'
ethereum: 'rinkeby:https://rinkeby.infura.io/v3/${INFURA_PROJECT_ID}'
RUST_LOG: info
ipfs:
image: ipfs/go-ipfs:v0.4.23

View File

@ -391,22 +391,20 @@ type PoolSnapshot @entity {
type GlobalStats @entity {
id: ID!
"total value locked represented in the base token , basically 2x liqudity for each base token"
totalValueLocked: [TokenValuePair!]
"total liquidity for each base token"
totalLiquidity: [TokenValuePair!]
totalLiquidity: [TokenValuePair!]!
"total swap volume for each base token. pools and fre"
totalSwapVolume: [TokenValuePair!]
totalSwapVolume: [TokenValuePair!]!
"number of total consumes, pools + fre"
orderCount: BigInt
"number of total consumes, pools + fre+ free"
orderCount: BigInt!
"number of pools for all factories"
"total nfts created"
nftCount: BigInt!
"total datatokens created"
datatokenCount:BigInt!
"number of pools"
poolCount: Int!
"number of finalized pools for all factories"
finalizedPoolCount: Int!
"probably remove due to inconsistencies and imposibility to calculate"
totalOrderVolume: BigDecimal
}

View File

@ -1,11 +1,8 @@
import { Order } from '../@types/schema'
import {
ConsumeMarketFees,
OrderStarted,
PublishMarketFees
} from '../@types/templates/ERC20Template/ERC20Template'
import { OrderStarted } from '../@types/templates/ERC20Template/ERC20Template'
import { integer } from './utils/constants'
import { weiToDecimal } from './utils/generic'
import { getGlobalStats } from './utils/globalUtils'
import { getToken } from './utils/tokenUtils'
import { getUser } from './utils/userUtils'
@ -53,6 +50,10 @@ export function handleOrderStarted(event: OrderStarted): void {
order.tx = event.transaction.hash.toHex()
order.block = event.block.number.toI32()
const globalStats = getGlobalStats()
globalStats.orderCount = globalStats.orderCount.plus(integer.ONE)
globalStats.save()
order.save()
token.save()
}

View File

@ -1,6 +1,7 @@
import { NFTCreated, TokenCreated } from '../@types/ERC721Factory/ERC721Factory'
import { Nft, Token } from '../@types/schema'
import { decimal } from './utils/constants'
import { decimal, integer } from './utils/constants'
import { getGlobalStats } from './utils/globalUtils'
import { getUser } from './utils/userUtils'
export function handleNftCreated(event: NFTCreated): void {
@ -15,6 +16,10 @@ export function handleNftCreated(event: NFTCreated): void {
nft.tx = event.transaction.hash.toHex()
nft.block = event.block.number.toI32()
const globalStats = getGlobalStats()
globalStats.nftCount = globalStats.nftCount.plus(integer.ONE)
globalStats.save()
nft.save()
}
@ -29,5 +34,10 @@ export function handleNewToken(event: TokenCreated): void {
token.name = event.params.name
token.decimals = 18
token.supply = decimal.ZERO
const globalStats = getGlobalStats()
globalStats.datatokenCount = globalStats.datatokenCount.plus(integer.ONE)
globalStats.save()
token.save()
}

View File

@ -1,5 +1,7 @@
import { Pool } from '../@types/schema'
import { BPoolCreated } from '../@types/templates/BFactory/BFactory'
import { integer } from './utils/constants'
import { getGlobalStats } from './utils/globalUtils'
import { getToken } from './utils/tokenUtils'
export function handleNewPool(event: BPoolCreated): void {
@ -17,5 +19,8 @@ export function handleNewPool(event: BPoolCreated): void {
pool.tx = event.transaction.hash.toHex()
pool.block = event.block.number.toI32()
const globalStats = getGlobalStats()
globalStats.poolCount = globalStats.poolCount + 1
globalStats.save()
pool.save()
}

View File

@ -5,7 +5,7 @@ const network = dataSource.network()
export function getOceanAddress(): string {
// switch is not working for some reason
if (network == 'ropsten') return '0x5e8dcb2afa23844bcc311b00ad1a0c30025aade9'
if (network == 'rinkeby') return '0x8967bcf84170c91b0d24d4302c2376283b0b3a07'
if (network == 'rinkeby') return '0x5e8DCB2AfA23844bcc311B00Ad1A0C30025aADE9'
if (network == 'polygon') return '0x282d8efce846a88b159800bd4130ad77443fa1a1'
if (network == 'moonbeamalpha')
return '0xf6410bf5d773c7a41ebff972f38e7463fa242477'
@ -24,6 +24,29 @@ export function getOceanAddress(): string {
return '0x967da4048cd07ab37855c090aaf366e4ce1b9f48'
}
export function getOpfCollectorAddress(): string {
// switch is not working for some reason
if (network == 'ropsten') return '0x5e8dcb2afa23844bcc311b00ad1a0c30025aade9'
if (network == 'rinkeby') return '0x2f311Ba88e2609D3A100822EdAC798eb0a8F4835'
if (network == 'polygon') return '0x282d8efce846a88b159800bd4130ad77443fa1a1'
if (network == 'moonbeamalpha')
return '0xf6410bf5d773c7a41ebff972f38e7463fa242477'
if (network == 'gaiaxtestnet')
return '0x80e63f73cac60c1662f27d2dfd2ea834acddbaa8'
if (network == 'catenaxtestnet')
return '0x80e63f73cac60c1662f27d2dfd2ea834acddbaa8'
if (network == 'mumbai') return '0xd8992ed72c445c35cb4a2be468568ed1079357c8'
if (network == 'bsc') return '0xdce07662ca8ebc241316a15b611c89711414dd1a'
if (network == 'celoalfajores')
return '0xd8992ed72c445c35cb4a2be468568ed1079357c8'
if (network == 'energyweb')
return '0x593122aae80a6fc3183b2ac0c4ab3336debee528'
if (network == 'moonriver')
return '0x99c409e5f62e4bd2ac142f17cafb6810b8f0baae'
return '0x967da4048cd07ab37855c090aaf366e4ce1b9f48'
}
export const OCEAN: string = getOceanAddress()
export function weiToDecimal(amount: BigDecimal, decimals: i32): BigDecimal {

View File

@ -1,3 +1,16 @@
const GLOBAL_ID = 1
import { BigDecimal } from '@graphprotocol/graph-ts'
import { GlobalStats } from '../../@types/schema'
export function getGlobalStats(): void {}
const GLOBAL_ID = '1'
export function getGlobalStats(): GlobalStats {
let globalStats = GlobalStats.load(GLOBAL_ID)
if (!globalStats) globalStats = new GlobalStats(GLOBAL_ID)
return globalStats
}
export function addSwap(tokenAddress: string, value: BigDecimal): void {
const globalStats = getGlobalStats()
globalStats.save()
}

View File

@ -6,7 +6,7 @@ import {
PoolTransaction
} from '../../@types/schema'
import { BPool } from '../../@types/templates/BPool/BPool'
import { DAY, decimal, PoolTransactionType } from './constants'
import { DAY, decimal } from './constants'
import { gweiToEth, weiToDecimal } from './generic'
export function getPoolSharesId(
@ -124,40 +124,3 @@ export function getPoolSnapshot(
return snapshot
}
// export function updatePoolSnapshotToken(
// poolAddress: string,
// timestamp: i32,
// poolTokenId: string,
// amount: BigDecimal,
// balance: BigDecimal,
// feeValue: BigDecimal
// ): void {
// log.warning('Start create Pool Snapshot Token: {} {}', [
// poolAddress,
// timestamp.toString()
// ])
// const dayTimestamp = timestamp - (timestamp % DAY) // Todays timestamp
// const snapshotId = poolAddress + '-' + dayTimestamp.toString()
// log.warning('Pool Snapshot Token: {} {} {} {}', [
// amount.toString(),
// balance.toString(),
// feeValue.toString(),
// snapshotId + '-' + poolTokenId
// ])
// const token = new PoolSnapshotTokenValue(snapshotId + '-' + poolTokenId)
// token.poolSnapshot = snapshotId
// token.value = amount
// token.tokenReserve = balance
// token.tokenAddress = poolTokenId
// token.feeValue = feeValue
// if (amount.lt(ZERO_BD)) {
// token.type = 'out'
// } else {
// token.type = 'in'
// }
// log.warning('Snapshot Token ID: {}', [token.id])
// token.save()
// }

View File

@ -1,6 +1,8 @@
import { Address } from '@graphprotocol/graph-ts'
import { Token } from '../../@types/schema'
import { ERC20 } from '../../@types/templates/ERC20Template/ERC20'
import { integer } from './constants'
import { getGlobalStats } from './globalUtils'
export function createToken(address: string): Token {
const token = new Token(address)
@ -10,6 +12,10 @@ export function createToken(address: string): Token {
token.address = address
token.isDatatoken = false
token.decimals = contract.decimals()
const globalStats = getGlobalStats()
globalStats.datatokenCount = globalStats.datatokenCount.plus(integer.ONE)
globalStats.save()
token.save()
return token
}

View File

@ -1,112 +1,70 @@
specVersion: 0.0.2
specVersion: 0.0.3
description: Ocean provides data sharing through IDOs
repository: https://github.com/oceanprotocol/ocean-subgraph
schema:
file: ./schema.graphql
dataSources:
- kind: ethereum/contract
name: Factory
name: ERC721Factory
network: rinkeby
source:
address: '0x53eDF9289B0898e1652Ce009AACf8D25fA9A42F8'
abi: Factory
startBlock: 7298806
address: '0xa15024b732A8f2146423D14209eFd074e61964F3'
abi: ERC721Factory
startBlock: 0
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/mappings/factory.ts
file: ./src/mappings/erc721Factory.ts
entities:
- PoolFactory
- ERC721Factory
abis:
- name: Factory
file: ./abis/BFactory.json
- name: ERC721Factory
file: ./abis/ERC721Factory.json
eventHandlers:
- event: BPoolRegistered(address,indexed address)
handler: handleNewPool
- kind: ethereum/contract
name: DTFactory
network: rinkeby
source:
address: '0x3fd7A00106038Fb5c802c6d63fa7147Fe429E83a'
abi: DTFactory
startBlock: 7298804
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/mappings/dtfactory.ts
entities:
- DatatokenFactory
abis:
- name: DTFactory
file: ./abis/DTFactory.json
eventHandlers:
- event: TokenRegistered(indexed address,string,string,uint256,indexed address,indexed string)
- event: NFTCreated(indexed address,indexed address,string,address,string,string)
handler: handleNftCreated
- event: TokenCreated(indexed address,indexed address,string,string,uint256,address)
handler: handleNewToken
- kind: ethereum/contract
name: Metadata
network: rinkeby
source:
address: '0xfd8a7b6297153397b7eb4356c47dbd381d58bff4'
abi: Metadata
startBlock: 7298808
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/mappings/metadata.ts
entities:
- Metadata
abis:
- name: Metadata
file: ./abis/Metadata.json
eventHandlers:
- event: MetadataCreated(indexed address,indexed address,bytes,bytes)
handler: handleMetadataCreated
- event: MetadataUpdated(indexed address,indexed address,bytes,bytes)
handler: handleMetadataUpdated
- kind: ethereum/contract
name: FixedRateExchange
network: rinkeby
source:
address: '0xeD1DfC5F3a589CfC4E8B91C1fbfC18FC6699Fbde'
address: '0x235C9bE4D23dCbd16c1Bf89ec839cb7C452FD9e9'
abi: FixedRateExchange
startBlock: 7298808
startBlock: 0
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/mappings/fixedrateexchange.ts
file: ./src/mappings/fixedRateExchange.ts
entities:
- FixedRateExchange
abis:
- name: FixedRateExchange
file: ./abis/FixedRateExchange.json
- name: ERC20
file: ./abis/ERC20.json
- name: ERC20SymbolBytes
file: ./abis/ERC20SymbolBytes.json
- name: ERC20NameBytes
file: ./abis/ERC20NameBytes.json
eventHandlers:
- event: ExchangeCreated(indexed bytes32,indexed address,indexed address,address,uint256)
handler: handleExchangeCreated
- event: ExchangeActivated(indexed bytes32,indexed address)
handler: handleExchangeActivated
- event: ExchangeDeactivated(indexed bytes32,indexed address)
handler: handleExchangeDeactivated
- event: ExchangeRateChanged(indexed bytes32,indexed address,uint256)
handler: handleExchangeRateChanged
- event: Swapped(indexed bytes32,indexed address,uint256,uint256)
handler: handleSwapped
handler: handleRateChange
- event: ExchangeMintStateChanged(indexed bytes32,indexed address,bool)
handler: handleMintStateChanged
- event: ExchangeActivated(indexed bytes32,indexed address)
handler: handleActivated
- event: ExchangeDeactivated(indexed bytes32,indexed address)
handler: handleDeactivated
- event: ExchangeAllowedSwapperChanged(indexed bytes32,indexed address)
handler: handleAllowedSwapperChanged
- event: Swapped(indexed bytes32,indexed address,uint256,uint256,address,uint256,uint256)
handler: handleSwap
- kind: ethereum/contract
name: Dispenser
network: rinkeby
source:
address: '0x623744Cd25Ed553d3b4722667697F926cf99658B'
address: '0x5FFE6649C7562F3bee1ca114c7c3316BF4B45b50'
abi: Dispenser
startBlock: 8554110
startBlock: 0
mapping:
kind: ethereum/events
apiVersion: 0.0.5
@ -118,96 +76,122 @@ dataSources:
- name: Dispenser
file: ./abis/Dispenser.json
eventHandlers:
- event: Activated(indexed address)
handler: handleDispenserActivated
- event: Deactivated(indexed address)
handler: handleDispenserDeactivated
- event: AcceptedMinter(indexed address)
handler: handleDispenserAcceptedMinter
- event: RemovedMinter(indexed address)
handler: handleDispenserRemovedMinter
- event: DispenserCreated(indexed address,indexed address,uint256,uint256,address)
handler: handleNewDispenser
- event: DispenserActivated(indexed address)
handler: handleActivate
- event: DispenserDeactivated(indexed address)
handler: handleDeactivate
- event: DispenserAllowedSwapperChanged(indexed address,indexed address)
handler: handleAllowedSwapperChanged
- event: TokensDispensed(indexed address,indexed address,uint256)
handler: handleDispenserTokensDispensed
handler: handleTokensDispensed
- event: OwnerWithdrawed(indexed address,indexed address,uint256)
handler: handleDispenserOwnerWithdrawed
handler: handleOwnerWinthdraw
templates:
- kind: ethereum/contract
name: Pool
- name: ERC20Template
kind: ethereum/contract
network: rinkeby
source:
abi: Pool
abi: ERC20Template
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/mappings/erc20Templates.ts
entities:
- ERC20Template
abis:
- name: ERC20Template
file: ./abis/ERC20Template.json
- name: ERC20TemplateEnterprise
file: ./abis/ERC20TemplateEnterprise.json
- name: ERC20
file: ./abis/ERC20.json
- name: ERC20Roles
file: ./abis/ERC20Roles.json
eventHandlers:
- event: OrderStarted(indexed address,address,uint256,uint256,uint256,indexed address,indexed address,uint256)
handler: handleOrderStarted
- event: NewPaymentCollector(indexed address,indexed address,uint256,uint256)
handler: handleNewPaymentCollector
- event: PublishMarketFees(indexed address,indexed address,uint256)
handler: handlePublishMarketFees
- event: ConsumeMarketFees(indexed address,indexed address,uint256)
handler: handleConsumeMarketFees
- kind: ethereum/contract
name: BFactory
network: rinkeby
source:
abi: BFactory
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/mappings/poolFactory.ts
entities:
- BFactory
abis:
- name: BFactory
file: ./abis/BFactory.json
eventHandlers:
- event: BPoolCreated(indexed address,indexed address,indexed address,address,address,address)
handler: handleNewPool
- kind: ethereum/contract
name: BPool
network: rinkeby
source:
abi: BPool
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/mappings/pool.ts
entities:
- Pool
- PoolFactory
- Swap
- BPool
abis:
- name: Pool
- name: BPool
file: ./abis/BPool.json
- name: BToken
file: ./abis/BToken.json
- name: ERC20
file: ./abis/ERC20.json
- name: ERC20SymbolBytes
file: ./abis/ERC20SymbolBytes.json
- name: ERC20NameBytes
file: ./abis/ERC20NameBytes.json
- name: BMath
file: ./abis/BMath.json
eventHandlers:
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x34e1990700000000000000000000000000000000000000000000000000000000'
handler: handleSetSwapFee
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x92eefe9b00000000000000000000000000000000000000000000000000000000'
handler: handleSetController
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x49b5955200000000000000000000000000000000000000000000000000000000'
handler: handleSetPublicSwap
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x4bb278f300000000000000000000000000000000000000000000000000000000'
handler: handleFinalize
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0xd1d7bc9100000000000000000000000000000000000000000000000000000000'
handler: handleSetup
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x3fdddaa200000000000000000000000000000000000000000000000000000000'
handler: handleRebind
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0xe4e1e53800000000000000000000000000000000000000000000000000000000'
handler: handleRebind
- event: LOG_CALL(indexed bytes4,indexed address,bytes)
topic0: '0x8c28cbe800000000000000000000000000000000000000000000000000000000'
handler: handleGulp
- event: LOG_JOIN(indexed address,indexed address,uint256)
handler: handleJoinPool
- event: LOG_EXIT(indexed address,indexed address,uint256)
handler: handleExitPool
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256)
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256,uint256)
handler: handleSwap
- event: LOG_JOIN(indexed address,indexed address,uint256,uint256)
handler: handleJoin
- event: LOG_EXIT(indexed address,indexed address,uint256,uint256)
handler: handleExit
- event: LOG_SETUP(indexed address,indexed address,uint256,uint256,indexed address,uint256,uint256)
handler: handleSetup
- event: LOG_BPT(uint256)
handler: handleBpt
- event: Transfer(indexed address,indexed address,uint256)
handler: handleTransfer
- kind: ethereum/contract
name: DataToken
handler: handlerBptTransfer
- name: ERC721Template
kind: ethereum/contract
network: rinkeby
source:
abi: DataToken
abi: ERC721Template
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
file: ./src/mappings/datatoken.ts
file: ./src/mappings/nftUpdate.ts
entities:
- DataToken
- DatatokenFactory
- ERC721Template
abis:
- name: DataToken
file: ./abis/DataTokenTemplate.json
- name: ERC721Template
file: ./abis/ERC721Template.json
eventHandlers:
- event: Transfer(indexed address,indexed address,uint256)
handler: handleTransfer
- event: OrderStarted(indexed address,indexed address,uint256,uint256,uint256,indexed address,uint256)
handler: handleOrderStarted
- event: MetadataCreated(indexed address,uint8,string,bytes,bytes,bytes,uint256,uint256)
handler: handleCreated
- event: MetadataUpdated(indexed address,uint8,string,bytes,bytes,bytes,uint256,uint256)
handler: handleUpdated
- event: MetadataState(indexed address,uint8,uint256,uint256)
handler: handleState
- event: TokenURIUpdate(indexed address,string,uint256,uint256,uint256)
handler: handleTokenUriUpdate
features:
- nonFatalErrors

View File

@ -169,8 +169,6 @@ templates:
handler: handleBpt
- event: Transfer(indexed address,indexed address,uint256)
handler: handlerBptTransfer
# - event: SWAP_FEES(uint,uint,uint,address)
# handler: handlerSwapFees
- name: ERC721Template
kind: ethereum/contract
network: barge