ocean-subgraph/src/mappings/factory.ts

72 lines
2.0 KiB
TypeScript
Raw Normal View History

import { BigInt, BigDecimal, log } from '@graphprotocol/graph-ts'
import { BPoolRegistered } from '../@types/Factory/Factory'
import { PoolFactory, Pool, Global } from '../@types/schema'
import { Pool as PoolContract } from '../@types/templates'
import { ZERO_BD, getGlobalStats } from '../helpers'
export function handleNewPool(event: BPoolRegistered): void {
let factory = PoolFactory.load('1')
if (factory == null) {
factory = new PoolFactory('1')
factory.totalOceanLiquidity = ZERO_BD
factory.totalSwapVolume = ZERO_BD
factory.totalSwapFee = ZERO_BD
factory.totalValueLocked = ZERO_BD
factory.orderCount = BigInt.fromI32(0)
factory.poolCount = 0
factory.finalizedPoolCount = 0
}
const pool = new Pool(event.params.bpoolAddress.toHexString())
log.info('************************ handleNewPool: poolId {}', [
pool.id.toString()
])
pool.factoryID = event.address.toHexString()
pool.controller = event.params.registeredBy
pool.publicSwap = false
pool.finalized = false
pool.symbol = ''
pool.name = ''
// pool.cap =
pool.active = true
pool.swapFee = BigDecimal.fromString('0.000001')
pool.totalWeight = ZERO_BD
pool.totalShares = ZERO_BD
pool.totalSwapVolume = ZERO_BD
pool.totalSwapFee = ZERO_BD
pool.valueLocked = ZERO_BD
pool.datatokenReserve = ZERO_BD
pool.oceanReserve = ZERO_BD
pool.spotPrice = ZERO_BD // : BigDecimal!
pool.consumePrice = ZERO_BD // : BigDecimal!
pool.tokenCount = BigInt.fromI32(0)
pool.holderCount = BigInt.fromI32(0)
pool.joinCount = BigInt.fromI32(0)
pool.exitCount = BigInt.fromI32(0)
pool.swapCount = BigInt.fromI32(0)
pool.transactionCount = BigInt.fromI32(0)
pool.datatokenAddress = ''
pool.createTime = event.block.timestamp.toI32()
pool.tx = event.transaction.hash
pool.save()
factory.poolCount = factory.poolCount + 1
factory.save()
const gStats: Global | null = getGlobalStats()
Feature/bump libs (#255) * fix id (#214) * Bump eslint-plugin-prettier from 3.4.0 to 3.4.1 (#206) Bumps [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases) - [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-plugin-prettier/commits) --- updated-dependencies: - dependency-name: eslint-plugin-prettier dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump typescript from 4.3.5 to 4.4.2 (#211) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.5 to 4.4.2. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.3.5...v4.4.2) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @typescript-eslint/eslint-plugin from 4.29.1 to 4.29.3 (#209) Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.29.1 to 4.29.3. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.29.3/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump mocha from 9.0.3 to 9.1.1 (#210) Bumps [mocha](https://github.com/mochajs/mocha) from 9.0.3 to 9.1.1. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v9.0.3...v9.1.1) --- updated-dependencies: - dependency-name: mocha dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @typescript-eslint/parser from 4.29.0 to 4.30.0 (#215) Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.29.0 to 4.30.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.30.0/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump eslint-plugin-prettier from 3.4.1 to 4.0.0 (#217) Bumps [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) from 3.4.1 to 4.0.0. - [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases) - [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-plugin-prettier/commits/v4.0.0) --- updated-dependencies: - dependency-name: eslint-plugin-prettier dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump prettier from 2.3.2 to 2.4.0 (#220) Bumps [prettier](https://github.com/prettier/prettier) from 2.3.2 to 2.4.0. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.3.2...2.4.0) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @typescript-eslint/parser from 4.30.0 to 4.31.0 (#221) Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.30.0 to 4.31.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.31.0/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @oceanprotocol/lib from 0.17.1 to 0.17.3 (#216) Bumps [@oceanprotocol/lib](https://github.com/oceanprotocol/ocean.js) from 0.17.1 to 0.17.3. - [Release notes](https://github.com/oceanprotocol/ocean.js/releases) - [Changelog](https://github.com/oceanprotocol/ocean.js/blob/main/CHANGELOG.md) - [Commits](https://github.com/oceanprotocol/ocean.js/compare/v0.17.1...v0.17.3) --- updated-dependencies: - dependency-name: "@oceanprotocol/lib" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @typescript-eslint/eslint-plugin from 4.29.3 to 4.31.0 (#222) Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.29.3 to 4.31.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.31.0/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump typescript from 4.4.2 to 4.4.3 (#223) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.4.2 to 4.4.3. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.4.2...v4.4.3) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix gaia-x abi Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro> * add catenax & bump ocean.js (#227) * add catenax & bump ocean.js * fix typo * fix lint deps * add nr of sales for user (#231) * Bump @typescript-eslint/eslint-plugin from 4.31.1 to 4.32.0 (#242) Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.31.1 to 4.32.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.32.0/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump release-it from 14.11.5 to 14.11.6 (#244) Bumps [release-it](https://github.com/release-it/release-it) from 14.11.5 to 14.11.6. - [Release notes](https://github.com/release-it/release-it/releases) - [Changelog](https://github.com/release-it/release-it/blob/master/CHANGELOG.md) - [Commits](https://github.com/release-it/release-it/compare/14.11.5...14.11.6) --- updated-dependencies: - dependency-name: release-it dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @typescript-eslint/parser from 4.31.1 to 4.33.0 (#245) Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.31.1 to 4.33.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.33.0/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add EnergyWeb, Moonriver & Celo Alfajores (#239) * add EnergyWeb, Moonriver & Celo Alfajores * fix ocean address * add ERC20 abis * Bump mocha from 9.1.1 to 9.1.2 (#247) Bumps [mocha](https://github.com/mochajs/mocha) from 9.1.1 to 9.1.2. - [Release notes](https://github.com/mochajs/mocha/releases) - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md) - [Commits](https://github.com/mochajs/mocha/compare/v9.1.1...v9.1.2) --- updated-dependencies: - dependency-name: mocha dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @typescript-eslint/eslint-plugin from 4.32.0 to 4.33.0 (#248) Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.32.0 to 4.33.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.33.0/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump @oceanprotocol/lib from 0.17.4 to 0.19.2 (#246) Bumps [@oceanprotocol/lib](https://github.com/oceanprotocol/ocean.js) from 0.17.4 to 0.19.2. - [Release notes](https://github.com/oceanprotocol/ocean.js/releases) - [Changelog](https://github.com/oceanprotocol/ocean.js/blob/main/CHANGELOG.md) - [Commits](https://github.com/oceanprotocol/ocean.js/compare/v0.17.4...v0.19.2) --- updated-dependencies: - dependency-name: "@oceanprotocol/lib" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Release 1.2.0 * lib bumps, remove logs * more fixes * more fixes * bump other libs + fixes * more fixes! * remove unusued function, lint exceptions * downgrade eslint Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Alex Coseru <alex.coseru@gmail.com>
2021-10-28 18:43:50 +02:00
if (gStats) {
gStats.poolCount = factory.poolCount
gStats.save()
}
PoolContract.create(event.params.bpoolAddress)
}