mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
another update
This commit is contained in:
parent
53e93861bc
commit
c708e8367b
328
abis/BFactory.json
Normal file
328
abis/BFactory.json
Normal file
@ -0,0 +1,328 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "BFactory",
|
||||
"sourceName": "contracts/pools/balancer/BFactory.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_bpoolTemplate",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_opfCollector",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address[]",
|
||||
"name": "_preCreatedPools",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "newBPoolAddress",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "registeredBy",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "datatokenAddress",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "basetokenAddress",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "bpoolTemplateAddress",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "ssAddress",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "BPoolCreated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "instance",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "InstanceDeployed",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "BONE",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "BPOW_PRECISION",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "EXIT_FEE",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "INIT_POOL_SUPPLY",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MAX_BOUND_TOKENS",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MAX_BPOW_BASE",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MAX_FEE",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MAX_IN_RATIO",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MAX_OUT_RATIO",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MAX_TOTAL_WEIGHT",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MAX_WEIGHT",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MIN_BALANCE",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MIN_BOUND_TOKENS",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MIN_BPOW_BASE",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MIN_FEE",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "MIN_WEIGHT",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "poolTemplate",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "isPoolTemplate",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "opfCollector",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x608060405234801561001057600080fd5b5060405161071938038061071983398101604081905261002f91610207565b6001600160a01b0383166100a05760405162461bcd60e51b815260206004820152602d60248201527f42466163746f72793a20696e76616c69642062706f6f6c2074656d706c61746560448201526c207a65726f206164647265737360981b60648201526084015b60405180910390fd5b6001600160a01b0382166100f65760405162461bcd60e51b815260206004820152601660248201527f42466163746f72793a207a65726f2061646472657373000000000000000000006044820152606401610097565b600080546001600160a01b0319166001600160a01b03841617905561013c836001600160a01b03166000908152600160208190526040909120805460ff19169091179055565b8051156101e35760005b81518110156101e15760006001600160a01b0316336001600160a01b03168383815181106101765761017661031f565b602090810291909101810151604080516000808252938101849052908101929092526001600160a01b0316907fbb6121447d29a04cc37bfd93cdf6a9dd08229f2d941116c1528f04698c4e790e9060600160405180910390a4806101d9816102f6565b915050610146565b505b50505061034b565b80516001600160a01b038116811461020257600080fd5b919050565b60008060006060848603121561021c57600080fd5b610225846101eb565b925060206102348186016101eb565b60408601519093506001600160401b038082111561025157600080fd5b818701915087601f83011261026557600080fd5b81518181111561027757610277610335565b8060051b604051601f19603f8301168101818110858211171561029c5761029c610335565b604052828152858101935084860182860187018c10156102bb57600080fd5b600095505b838610156102e5576102d1816101eb565b8552600195909501949386019386016102c0565b508096505050505050509250925092565b600060001982141561031857634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6103bf8061035a6000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063b7b800a4116100a2578063c07c00fe11610071578063c07c00fe146101b8578063c36596a61461013e578063c6580d12146101f4578063e4a28a521461011b578063ec093021146101fc57600080fd5b8063b7b800a414610198578063ba019dab146101a0578063bc063e1a146101a8578063bc694ea2146101b057600080fd5b8063867378c5116100e9578063867378c5146101555780639381cd2b1461015d578063992e2a9214610165578063a28f78f11461016d578063b0e0d1361461019857600080fd5b806309a3bbe41461011b578063189d00ca14610136578063218b53821461013e57806376c7a3c71461014d575b600080fd5b610123610204565b6040519081526020015b60405180910390f35b61012361021a565b610123670de0b6b3a764000081565b610123610231565b610123610246565b61012361025d565b610123610270565b600054610180906001600160a01b031681565b6040516001600160a01b03909116815260200161012d565b610123600281565b610123600181565b61012361028e565b6101236102a1565b6101e46101c63660046102d3565b6001600160a01b031660009081526001602052604090205460ff1690565b604051901515815260200161012d565b610123600081565b6101236102c0565b610217670de0b6b3a7640000603261033d565b81565b6102176402540be400670de0b6b3a764000061031b565b610217620f4240670de0b6b3a764000061031b565b61021764e8d4a51000670de0b6b3a764000061031b565b610217670de0b6b3a7640000606461033d565b6102836003670de0b6b3a764000061031b565b610217906001610303565b610217600a670de0b6b3a764000061031b565b60016102b6670de0b6b3a7640000600261033d565b610217919061035c565b6102176002670de0b6b3a764000061031b565b6000602082840312156102e557600080fd5b81356001600160a01b03811681146102fc57600080fd5b9392505050565b6000821982111561031657610316610373565b500190565b60008261033857634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561035757610357610373565b500290565b60008282101561036e5761036e610373565b500390565b634e487b7160e01b600052601160045260246000fdfea264697066735822122051baecb88b2e3924258c058b6adf28c8a64ed8675ac122a5a6e5e1267dbdf04f64736f6c63430008070033",
|
||||
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101165760003560e01c8063b7b800a4116100a2578063c07c00fe11610071578063c07c00fe146101b8578063c36596a61461013e578063c6580d12146101f4578063e4a28a521461011b578063ec093021146101fc57600080fd5b8063b7b800a414610198578063ba019dab146101a0578063bc063e1a146101a8578063bc694ea2146101b057600080fd5b8063867378c5116100e9578063867378c5146101555780639381cd2b1461015d578063992e2a9214610165578063a28f78f11461016d578063b0e0d1361461019857600080fd5b806309a3bbe41461011b578063189d00ca14610136578063218b53821461013e57806376c7a3c71461014d575b600080fd5b610123610204565b6040519081526020015b60405180910390f35b61012361021a565b610123670de0b6b3a764000081565b610123610231565b610123610246565b61012361025d565b610123610270565b600054610180906001600160a01b031681565b6040516001600160a01b03909116815260200161012d565b610123600281565b610123600181565b61012361028e565b6101236102a1565b6101e46101c63660046102d3565b6001600160a01b031660009081526001602052604090205460ff1690565b604051901515815260200161012d565b610123600081565b6101236102c0565b610217670de0b6b3a7640000603261033d565b81565b6102176402540be400670de0b6b3a764000061031b565b610217620f4240670de0b6b3a764000061031b565b61021764e8d4a51000670de0b6b3a764000061031b565b610217670de0b6b3a7640000606461033d565b6102836003670de0b6b3a764000061031b565b610217906001610303565b610217600a670de0b6b3a764000061031b565b60016102b6670de0b6b3a7640000600261033d565b610217919061035c565b6102176002670de0b6b3a764000061031b565b6000602082840312156102e557600080fd5b81356001600160a01b03811681146102fc57600080fd5b9392505050565b6000821982111561031657610316610373565b500190565b60008261033857634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561035757610357610373565b500290565b60008282101561036e5761036e610373565b500390565b634e487b7160e01b600052601160045260246000fdfea264697066735822122051baecb88b2e3924258c058b6adf28c8a64ed8675ac122a5a6e5e1267dbdf04f64736f6c63430008070033",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
1529
abis/BPool.json
Normal file
1529
abis/BPool.json
Normal file
File diff suppressed because one or more lines are too long
@ -16,7 +16,7 @@ type Token @entity {
|
||||
publishMarketFeeAmmount: BigDecimal # fee amount. Fixed value, expressed in wei in contracts, needs conversion in decimals.
|
||||
templateId: Int # template ID of the datatoken
|
||||
|
||||
holderCount: BigInt # Number of addresses holding a balance of datatoken
|
||||
holderCount: BigInt # Number of addresses holding a balance of datatoken , TODO: can we actually calculate this? what happens when users trade the dts
|
||||
orderCount: BigInt # Number of orders executed for this datatoken
|
||||
|
||||
createdTimestamp: Int # Block time datatoken was created
|
||||
@ -63,6 +63,8 @@ type Pool @entity {
|
||||
cap: BigDecimal # Maximum supply if any, converted from wei
|
||||
isActive: Boolean! # pool is active
|
||||
|
||||
baseToken: PoolToken! @derivedFrom(field: "pool")
|
||||
datatoken: PoolToken! @derivedFrom(field: "pool")
|
||||
poolFee: BigDecimal! # Pool Fee percent, fee goes to all liquidity providers : SWAP, JOIN , EXIT
|
||||
opfFee: BigDecimal! # OPF Fee percent, fee that goes to Ocean Protocol Foundation : SWAP
|
||||
marketFee: BigDecimal! # Market fee percent, fee that goes to the market where the pool was created : SWAP
|
||||
@ -88,8 +90,6 @@ type Pool @entity {
|
||||
tx: Bytes # Pool creation transaction id
|
||||
block: Int # Block number when it was created
|
||||
|
||||
# split in basetokne and datatoken like in fre
|
||||
tokens: [PoolToken!] @derivedFrom(field: "pool")
|
||||
shares: [PoolShare!] @derivedFrom(field: "pool")
|
||||
transactions: [PoolTransaction!] @derivedFrom(field: "pool")
|
||||
}
|
||||
@ -111,7 +111,7 @@ type PoolShare @entity {
|
||||
balance: BigDecimal!
|
||||
}
|
||||
|
||||
#check balancer v2 graph TX
|
||||
|
||||
type PoolTransaction @entity {
|
||||
id: ID! # tx + caller
|
||||
pool: Pool! # Pool related to this tx
|
||||
@ -124,15 +124,18 @@ type PoolTransaction @entity {
|
||||
opfFee: BigDecimal! # OPF Fee percent, fee that goes to Ocean Protocol Foundation : SWAP
|
||||
marketFee: BigDecimal!
|
||||
|
||||
event: String # TODO: what is this?
|
||||
|
||||
tx: Bytes!
|
||||
event: String
|
||||
block: Int!
|
||||
createdTimestamp: Int!
|
||||
gasUsed: BigDecimal!
|
||||
gasPrice: BigDecimal!
|
||||
timestamp: Int!
|
||||
|
||||
gasLimit: BigDecimal!
|
||||
gasPrice: BigDecimal! # in eth
|
||||
|
||||
# change to baseToken and dataToken
|
||||
tokens: [TokenValuePair!] # tokens transfered , if value is negative it means it was removed.
|
||||
baseToken: TokenValuePair # tokens transfered , if value is negative it means it was removed,
|
||||
datatoken: TokenValuePair
|
||||
}
|
||||
|
||||
type Order @entity { # renamed from TokenOrder to Order
|
||||
@ -242,7 +245,6 @@ type Dispenser @entity {
|
||||
datatoken: Token!
|
||||
|
||||
allowedSwapper: String
|
||||
withMint: Boolean # if the owner allowes the fre to mint
|
||||
isMinter: Boolean # if the fre has the minter role on the datatoken
|
||||
maxTokens: BigDecimal! # max tokens that can be dispensed
|
||||
maxBalance: BigDecimal! # max balance of requester. If the balance is higher, the dispense is rejected
|
||||
|
@ -4,26 +4,42 @@ var fs = require('fs')
|
||||
async function replaceContractAddresses() {
|
||||
// load barge addresses first
|
||||
try {
|
||||
const data = JSON.parse(
|
||||
fs.readFileSync(
|
||||
'/home/mihai/.ocean/ocean-contracts/artifacts/address.json',
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
const {
|
||||
DTFactory,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
ERC721Factory
|
||||
} = data.development
|
||||
let subgraph = fs.readFileSync('subgraph.yaml', 'utf8')
|
||||
if (!data) {
|
||||
return false
|
||||
}
|
||||
// const data = JSON.parse(
|
||||
// fs.readFileSync(
|
||||
// '/home/mihai/.ocean/ocean-contracts/artifacts/address.json',
|
||||
// 'utf8'
|
||||
// )
|
||||
// )
|
||||
// const {
|
||||
// DTFactory,
|
||||
// // eslint-disable-next-line no-unused-vars
|
||||
// ERC721Factory
|
||||
// } = data.development
|
||||
// let subgraph = fs.readFileSync('subgraph.yaml', 'utf8')
|
||||
// if (!data) {
|
||||
// return false
|
||||
// }
|
||||
|
||||
const ERC721Factory = '0x0599a4a2873B38D836E10302De1ca4834F7BDF4E'
|
||||
const FixedRateExchange = '0x2356DeCd8CFB6c6f2bf46b5ED4531818B4662337'
|
||||
const Dispenser = '0xb119b8895801111ff323ba63a77D4Fe78ED057a5'
|
||||
|
||||
// ERC721Factory
|
||||
subgraph = subgraph.replace(
|
||||
/0x17d55A3501999FFBF9b0623cDB258611419d01F5/g,
|
||||
/0x0599a4a2873B38D836E10302De1ca4834F7BDF4E/g,
|
||||
ERC721Factory
|
||||
)
|
||||
|
||||
subgraph = subgraph.replace(
|
||||
/0x2356DeCd8CFB6c6f2bf46b5ED4531818B4662337/g,
|
||||
FixedRateExchange
|
||||
)
|
||||
|
||||
subgraph = subgraph.replace(
|
||||
/0xb119b8895801111ff323ba63a77D4Fe78ED057a5/g,
|
||||
Dispenser
|
||||
)
|
||||
|
||||
// network
|
||||
subgraph = subgraph.replace(/network: mainnet/g, 'network: barge')
|
||||
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
} from '../@types/Dispenser/Dispenser'
|
||||
import { DispenserCreated } from '../@types/ERC721Factory/ERC721Factory'
|
||||
import { DispenserTransaction } from '../@types/schema'
|
||||
import { ZERO_BD } from '../helpers'
|
||||
import { ZERO_BD } from './utils/constants'
|
||||
import { createDispenser, getDispenser } from './utils/dispenserUtils'
|
||||
import { getUser } from './utils/userUtils'
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { NFTCreated, TokenCreated } from '../@types/ERC721Factory/ERC721Factory'
|
||||
import { Nft, Token } from '../@types/schema'
|
||||
import { ZERO_BD } from '../helpers'
|
||||
import { ZERO_BD } from './utils/constants'
|
||||
import { getUser } from './utils/userUtils'
|
||||
|
||||
export function handleNftCreated(event: NFTCreated): void {
|
||||
|
@ -1,11 +0,0 @@
|
||||
import { NewPool } from '../@types/ERC20Template/ERC20Template'
|
||||
import { Pool } from '../@types/schema'
|
||||
|
||||
export function handleNewPool(event: NewPool): void {
|
||||
const newPool = new Pool(event.params.poolAddress.toHex())
|
||||
|
||||
newPool.createdTimestamp = event.block.timestamp.toI32()
|
||||
newPool.tx = event.transaction.hash
|
||||
newPool.block = event.block.number.toI32()
|
||||
newPool.save()
|
||||
}
|
31
src/mappings/pool.ts
Normal file
31
src/mappings/pool.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { Pool, PoolTransaction } from '../@types/schema'
|
||||
import { LOG_JOIN } from '../@types/templates/BPool/BPool'
|
||||
import { integer, PoolTransactionType } from './utils/constants'
|
||||
import { gweiToEth } from './utils/generic'
|
||||
import { getUser } from './utils/userUtils'
|
||||
|
||||
export function handleJoin(event: LOG_JOIN): void {
|
||||
const pool = Pool.load(event.address.toHex())
|
||||
|
||||
// should we do something else here?
|
||||
if (pool === null || pool.isFinalized === true) return
|
||||
|
||||
pool.transactionCount = pool.transactionCount.plus(integer.ONE)
|
||||
pool.joinCount = pool.joinCount.plus(integer.ONE)
|
||||
|
||||
const poolTx = new PoolTransaction(event.transaction.hash.toHex())
|
||||
const user = getUser(event.params.caller.toHex())
|
||||
poolTx.user = user.id
|
||||
poolTx.pool = pool.id
|
||||
poolTx.type = PoolTransactionType.JOIN
|
||||
|
||||
poolTx.timestamp = event.block.timestamp.toI32()
|
||||
poolTx.tx = event.transaction.hash
|
||||
poolTx.block = event.block.number.toI32()
|
||||
|
||||
poolTx.gasPrice = gweiToEth(event.transaction.gasPrice.toBigDecimal())
|
||||
poolTx.gasLimit = event.transaction.gasLimit.toBigDecimal()
|
||||
|
||||
poolTx.save()
|
||||
pool.save()
|
||||
}
|
27
src/mappings/poolFactory.ts
Normal file
27
src/mappings/poolFactory.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { BPoolCreated } from '../@types/FactoryRouter/FactoryRouter'
|
||||
import { Pool } from '../@types/schema'
|
||||
import { getPoolToken } from './utils/poolUtils'
|
||||
|
||||
export function handleNewPool(event: BPoolCreated): void {
|
||||
const pool = new Pool(event.params.newBPoolAddress.toHex())
|
||||
|
||||
const baseToken = getPoolToken(
|
||||
event.params.newBPoolAddress.toHex(),
|
||||
event.params.basetokenAddress.toHex()
|
||||
)
|
||||
pool.baseToken = baseToken.id
|
||||
|
||||
const datatoken = getPoolToken(
|
||||
event.params.newBPoolAddress.toHex(),
|
||||
event.params.datatokenAddress.toHex()
|
||||
)
|
||||
pool.datatoken = datatoken.id
|
||||
|
||||
pool.owner = event.params.registeredBy.toHex()
|
||||
|
||||
pool.createdTimestamp = event.block.timestamp.toI32()
|
||||
pool.tx = event.transaction.hash
|
||||
pool.block = event.block.number.toI32()
|
||||
|
||||
pool.save()
|
||||
}
|
25
src/mappings/utils/constants.ts
Normal file
25
src/mappings/utils/constants.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { BigDecimal, BigInt } from '@graphprotocol/graph-ts'
|
||||
|
||||
export const ENABLE_DEBUG = true
|
||||
|
||||
export const enum PoolTransactionType {
|
||||
JOIN = 'join',
|
||||
EXIT = 'exit',
|
||||
SWAP = 'swap',
|
||||
SETUP = 'setup'
|
||||
}
|
||||
|
||||
export namespace integer {
|
||||
export const NEGATIVE_ONE = BigInt.fromI32(-1)
|
||||
export const ZERO = BigInt.fromI32(0)
|
||||
export const ONE = BigInt.fromI32(1)
|
||||
export const TWO = BigInt.fromI32(2)
|
||||
export const ONE_BASE_18 = BigInt.fromI32(10).pow(18 as u8)
|
||||
}
|
||||
|
||||
export namespace deciaml {
|
||||
export const ZERO_BD = BigDecimal.fromString('0.0')
|
||||
export const MINUS_1_BD = BigDecimal.fromString('-1.0')
|
||||
export const ONE_BD = BigDecimal.fromString('1.0')
|
||||
export const BONE = BigDecimal.fromString('1000000000000000000')
|
||||
}
|
38
src/mappings/utils/generic.ts
Normal file
38
src/mappings/utils/generic.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { BigDecimal, BigInt, dataSource } from '@graphprotocol/graph-ts'
|
||||
|
||||
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 == '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 tokenToDecimal(amount: BigDecimal, decimals: i32): BigDecimal {
|
||||
const scale = BigInt.fromI32(10)
|
||||
.pow(decimals as u8)
|
||||
.toBigDecimal()
|
||||
return amount.div(scale)
|
||||
}
|
||||
|
||||
export function gweiToEth(ammount: BigDecimal): BigDecimal {
|
||||
return ammount.div(BigDecimal.fromString('1.000.000.000'))
|
||||
}
|
21
src/mappings/utils/poolUtils.ts
Normal file
21
src/mappings/utils/poolUtils.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { PoolToken } from '../../@types/schema'
|
||||
|
||||
export function getPoolTokenId(
|
||||
poolAddress: string,
|
||||
tokenAddress: string
|
||||
): string {
|
||||
return `${poolAddress}-${tokenAddress}`
|
||||
}
|
||||
|
||||
export function getPoolToken(
|
||||
poolAddress: string,
|
||||
tokenAddress: string
|
||||
): PoolToken {
|
||||
let poolToken = PoolToken.load(getPoolTokenId(poolAddress, tokenAddress))
|
||||
if (poolToken === null) {
|
||||
poolToken = new PoolToken(getPoolTokenId(poolAddress, tokenAddress))
|
||||
// TODO: add data to pooltoken
|
||||
}
|
||||
|
||||
return poolToken
|
||||
}
|
@ -58,26 +58,6 @@ dataSources:
|
||||
handler: handleAllowedSwapperChanged
|
||||
- event: Swapped(indexed bytes32,indexed address,uint256,uint256,address,uint256,uint256)
|
||||
handler: handleSwap
|
||||
- kind: ethereum/contract
|
||||
name: FactoryRouter
|
||||
network: barge
|
||||
source:
|
||||
address: '0x5509dc151e25BdA96d508A5994654980b7574883'
|
||||
abi: FactoryRouter
|
||||
startBlock: 0
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.5
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/factoryRouter.ts
|
||||
entities:
|
||||
- FactoryRouter
|
||||
abis:
|
||||
- name: FactoryRouter
|
||||
file: ./abis/FactoryRouter.json
|
||||
eventHandlers:
|
||||
- event: NewPool(indexed address,bool)
|
||||
handler: handleNewPool
|
||||
- kind: ethereum/contract
|
||||
name: Dispenser
|
||||
network: barge
|
||||
@ -126,8 +106,62 @@ templates:
|
||||
file: ./abis/ERC20Template.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: MinterApproved(address,address)
|
||||
handler: handleMinterApproved
|
||||
- event: AddedMinter(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleAddMinter
|
||||
- event: RemovedMinter(indexed address,indexed address,uint256,uint256)
|
||||
handler: handleRemoveMinter
|
||||
- event: AddedFeeManager(indexed address,indexed address,uint256,uint256)
|
||||
handler: handlerAddFeeManager
|
||||
- event: RemovedFeeManager(indexed address,indexed address,uint256,uint256)
|
||||
handler: handlerRemoveFeeManager
|
||||
- event: CleanedPermissions(indexed address,uint256,uint256)
|
||||
handler: handleCleanPermissions
|
||||
- kind: ethereum/contract
|
||||
name: BFactory
|
||||
network: barge
|
||||
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: barge
|
||||
source:
|
||||
abi: BPool
|
||||
mapping:
|
||||
kind: ethereum/events
|
||||
apiVersion: 0.0.5
|
||||
language: wasm/assemblyscript
|
||||
file: ./src/mappings/pool.ts
|
||||
entities:
|
||||
- BPool
|
||||
abis:
|
||||
- name: BPool
|
||||
file: ./abis/BPool.json
|
||||
eventHandlers:
|
||||
- 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_BPT(uint256)
|
||||
handler: handleBpt
|
Loading…
Reference in New Issue
Block a user