From e96bbc2f1edfd231edd104612b66ef7107f21825 Mon Sep 17 00:00:00 2001 From: Harsh Date: Tue, 16 Jan 2024 21:43:51 +0530 Subject: [PATCH] Add balancer-v2 --- .gitignore | 1 + Cargo.lock | 32 ++ Cargo.toml | 1 + balancer-v2/Cargo.toml | 29 ++ balancer-v2/Makefile | 16 + balancer-v2/abi/vault.json | 597 ++++++++++++++++++++++++++++++++ balancer-v2/build.rs | 10 + balancer-v2/proto/vault.proto | 21 ++ balancer-v2/rust-toolchain.toml | 4 + balancer-v2/schema.graphql | 12 + balancer-v2/schema.sql | 12 + balancer-v2/src/abi.rs | 5 + balancer-v2/src/lib.rs | 96 +++++ balancer-v2/src/pb.rs | 9 + balancer-v2/subgraph.yaml | 17 + balancer-v2/substreams.sql.yaml | 57 +++ balancer-v2/substreams.yaml | 48 +++ 17 files changed, 967 insertions(+) create mode 100644 balancer-v2/Cargo.toml create mode 100644 balancer-v2/Makefile create mode 100644 balancer-v2/abi/vault.json create mode 100644 balancer-v2/build.rs create mode 100644 balancer-v2/proto/vault.proto create mode 100644 balancer-v2/rust-toolchain.toml create mode 100644 balancer-v2/schema.graphql create mode 100644 balancer-v2/schema.sql create mode 100644 balancer-v2/src/abi.rs create mode 100644 balancer-v2/src/lib.rs create mode 100644 balancer-v2/src/pb.rs create mode 100644 balancer-v2/subgraph.yaml create mode 100644 balancer-v2/substreams.sql.yaml create mode 100644 balancer-v2/substreams.yaml diff --git a/.gitignore b/.gitignore index e12b4ca6..e55809e6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ Reference/ ###################### **/target/ +**/sink-data/ **/build/ **/data/ **/*.spkg diff --git a/Cargo.lock b/Cargo.lock index 53aec903..8d5a161c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1107,6 +1107,27 @@ dependencies = [ "thiserror", ] +[[package]] +name = "substreams-balancer-v2" +version = "0.0.1" +dependencies = [ + "anyhow", + "ethabi", + "hex", + "hex-literal", + "num-bigint", + "num-traits", + "pad", + "prost 0.11.9", + "prost-types 0.11.9", + "substreams 0.5.10", + "substreams-common", + "substreams-database-change", + "substreams-entity-change 1.3.0", + "substreams-ethereum", + "substreams-helper", +] + [[package]] name = "substreams-common" version = "0.1.0" @@ -1118,6 +1139,17 @@ dependencies = [ "thiserror", ] +[[package]] +name = "substreams-database-change" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ea09c700498fea3e50eb9aab5b0637d8bfce888be899aa68f987132923e46cc" +dependencies = [ + "prost 0.11.9", + "prost-types 0.11.9", + "substreams 0.5.10", +] + [[package]] name = "substreams-entity-change" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index eedf6a7e..559e6293 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ members = [ "eth-supply", "synthetix", "aave-v2", + "balancer-v2", ] exclude = ["messari-cli"] diff --git a/balancer-v2/Cargo.toml b/balancer-v2/Cargo.toml new file mode 100644 index 00000000..3a55134a --- /dev/null +++ b/balancer-v2/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "substreams-balancer-v2" +edition = "2021" +version = "0.0.1" +description = "Messari's standardized substream for Balancer v2" +repository = "https://github.com/messari/substreams/" + +[lib] +name = "substreams" +crate-type = ["cdylib"] + +[dependencies] +pad = "0.1" +hex = "0.4.3" +ethabi = "17.0" +hex-literal = "0.3.4" +prost = "^0.11.0" +prost-types = "0.11" +num-bigint = "0.4" +num-traits = "0.2.15" +substreams-database-change = "1" +substreams-entity-change = "1.3.0" +substreams.workspace = true +substreams-ethereum.workspace = true +substreams-helper = { path = "../substreams-helper" } + +[build-dependencies] +anyhow = "1" +substreams-common = { path = "../common" } diff --git a/balancer-v2/Makefile b/balancer-v2/Makefile new file mode 100644 index 00000000..26b9b1ef --- /dev/null +++ b/balancer-v2/Makefile @@ -0,0 +1,16 @@ +.PHONY: build_all +build_all: + $(MAKE) -C ../erc20-price build + $(MAKE) -C ../erc20-price pack + cargo build --target wasm32-unknown-unknown --release + +.PHONY: build +build: + cargo build --target wasm32-unknown-unknown --release + +.PHONY: run +run: + substreams run substreams.yaml map_events -s 12274555 +.PHONY: pack +pack: + substreams pack ./substreams.yaml diff --git a/balancer-v2/abi/vault.json b/balancer-v2/abi/vault.json new file mode 100644 index 00000000..9c76bd39 --- /dev/null +++ b/balancer-v2/abi/vault.json @@ -0,0 +1,597 @@ +[ + { + "inputs": [ + { + "internalType": "contract IAuthorizer", + "name": "authorizer", + "type": "address" + }, + { "internalType": "contract IWETH", "name": "weth", "type": "address" }, + { + "internalType": "uint256", + "name": "pauseWindowDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bufferPeriodDuration", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IAuthorizer", + "name": "newAuthorizer", + "type": "address" + } + ], + "name": "AuthorizerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "ExternalBalanceTransfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IFlashLoanRecipient", + "name": "recipient", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + } + ], + "name": "FlashLoan", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "delta", + "type": "int256" + } + ], + "name": "InternalBalanceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "PausedStateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "liquidityProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "int256[]", + "name": "deltas", + "type": "int256[]" + }, + { + "indexed": false, + "internalType": "uint256[]", + "name": "protocolFeeAmounts", + "type": "uint256[]" + } + ], + "name": "PoolBalanceChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "assetManager", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "cashDelta", + "type": "int256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "managedDelta", + "type": "int256" + } + ], + "name": "PoolBalanceManaged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "poolAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "enum IVault.PoolSpecialization", + "name": "specialization", + "type": "uint8" + } + ], + "name": "PoolRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "relayer", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "RelayerApprovalChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "tokenIn", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20", + "name": "tokenOut", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "name": "Swap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "TokensDeregistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "assetManagers", + "type": "address[]" + } + ], + "name": "TokensRegistered", + "type": "event" + }, + { + "inputs": [], + "name": "WETH", + "outputs": [ + { "internalType": "contract IWETH", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "deregisterTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IFlashLoanRecipient", + "name": "recipient", + "type": "address" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "name": "flashLoan", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes4", "name": "selector", "type": "bytes4" } + ], + "name": "getActionId", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { "internalType": "contract IAuthorizer", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDomainSeparator", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + } + ], + "name": "getInternalBalance", + "outputs": [ + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" } + ], + "name": "getNextNonce", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPausedState", + "outputs": [ + { "internalType": "bool", "name": "paused", "type": "bool" }, + { + "internalType": "uint256", + "name": "pauseWindowEndTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bufferPeriodEndTime", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" } + ], + "name": "getPool", + "outputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { + "internalType": "enum IVault.PoolSpecialization", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "contract IERC20", "name": "token", "type": "address" } + ], + "name": "getPoolTokenInfo", + "outputs": [ + { "internalType": "uint256", "name": "cash", "type": "uint256" }, + { "internalType": "uint256", "name": "managed", "type": "uint256" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { "internalType": "address", "name": "assetManager", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" } + ], + "name": "getPoolTokens", + "outputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getProtocolFeesCollector", + "outputs": [ + { + "internalType": "contract ProtocolFeesCollector", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" }, + { "internalType": "address", "name": "relayer", "type": "address" } + ], + "name": "hasApprovedRelayer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IVault.PoolSpecialization", + "name": "specialization", + "type": "uint8" + } + ], + "name": "registerPool", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "assetManagers", + "type": "address[]" + } + ], + "name": "registerTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IAuthorizer", + "name": "newAuthorizer", + "type": "address" + } + ], + "name": "setAuthorizer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bool", "name": "paused", "type": "bool" }], + "name": "setPaused", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "relayer", "type": "address" }, + { "internalType": "bool", "name": "approved", "type": "bool" } + ], + "name": "setRelayerApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } +] diff --git a/balancer-v2/build.rs b/balancer-v2/build.rs new file mode 100644 index 00000000..fb321d31 --- /dev/null +++ b/balancer-v2/build.rs @@ -0,0 +1,10 @@ +use anyhow::{Ok, Result}; +use substreams_common::codegen; + +fn main() -> Result<(), anyhow::Error> { + println!("cargo:rerun-if-changed=proto"); + println!("cargo:rerun-if-changed=abi"); + codegen::generate(None)?; + + Ok(()) +} diff --git a/balancer-v2/proto/vault.proto b/balancer-v2/proto/vault.proto new file mode 100644 index 00000000..db333756 --- /dev/null +++ b/balancer-v2/proto/vault.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +import "google/protobuf/timestamp.proto"; + +package vault.v1; + +message Events { + repeated PoolRegistered pool_registrations = 1; +} + +message PoolRegistered { + string tx_hash = 1; + uint32 log_index = 2; + google.protobuf.Timestamp block_time = 3; + uint64 block_number = 4; + bytes pool_id = 5; + bytes pool_address = 6; + uint32 specialization = 7; + bytes from_address = 8; + bytes to_address = 9; +} diff --git a/balancer-v2/rust-toolchain.toml b/balancer-v2/rust-toolchain.toml new file mode 100644 index 00000000..0a0b90ae --- /dev/null +++ b/balancer-v2/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.64.0" +components = [ "rustfmt" ] +targets = [ "wasm32-unknown-unknown" ] diff --git a/balancer-v2/schema.graphql b/balancer-v2/schema.graphql new file mode 100644 index 00000000..2df0b5e4 --- /dev/null +++ b/balancer-v2/schema.graphql @@ -0,0 +1,12 @@ +type pool_registrations @entity { + id: ID! + tx_hash: String! + log_index: BigInt! + block_time: String! + block_number: BigInt! + pool_id: String! + pool_address: String! + specialization: BigInt! + from_address: String! + to_address: String! +} \ No newline at end of file diff --git a/balancer-v2/schema.sql b/balancer-v2/schema.sql new file mode 100644 index 00000000..591ef13c --- /dev/null +++ b/balancer-v2/schema.sql @@ -0,0 +1,12 @@ +CREATE TABLE IF NOT EXISTS pool_registrations ( + "tx_hash" VARCHAR(64), + "log_index" INT, + "block_time" TIMESTAMP, + "block_number" DECIMAL, + "pool_id" VARCHAR(64), + "pool_address" VARCHAR(64), + "specialization" INT, + "from_address" VARCHAR(64), + "to_address" VARCHAR(64), + PRIMARY KEY(tx_hash, log_index) +); \ No newline at end of file diff --git a/balancer-v2/src/abi.rs b/balancer-v2/src/abi.rs new file mode 100644 index 00000000..2b34f5c7 --- /dev/null +++ b/balancer-v2/src/abi.rs @@ -0,0 +1,5 @@ +// DO NOT EDIT - the file is generated by build script +#[rustfmt::skip] +#[allow(unused_imports)] +#[path = "../target/abi/vault.rs"] +pub mod vault; diff --git a/balancer-v2/src/lib.rs b/balancer-v2/src/lib.rs new file mode 100644 index 00000000..65a3c5d8 --- /dev/null +++ b/balancer-v2/src/lib.rs @@ -0,0 +1,96 @@ +mod abi; +mod pb; +use substreams::Hex; +use hex_literal::hex; +use pb::vault::v1 as vault; +use substreams_ethereum::Event; +use substreams_ethereum::pb::eth::v2 as eth; + +use substreams_database_change::pb::database::DatabaseChanges; +use substreams_database_change::tables::Tables as DatabaseChangeTables; + +use substreams_entity_change::pb::entity::EntityChanges; +use substreams_entity_change::tables::Tables as EntityChangesTables; + + +const TRACKED_CONTRACT: [u8; 20] = hex!("ba12222222228d8ba445958a75a0704d566bf2c8"); + +substreams_ethereum::init!(); + +#[substreams::handlers::map] +fn map_events(blk: eth::Block) -> Result { + Ok(vault::Events { + pool_registrations: blk + .receipts() + .flat_map(|view| { + view.receipt.logs + .iter() + .filter(|log| log.address == TRACKED_CONTRACT) + .filter_map(|log| { + if + let Some(event) = + abi::vault::events::PoolRegistered::match_and_decode(log) + { + return Some(vault::PoolRegistered { + tx_hash: Hex(&view.transaction.hash).to_string(), + log_index: log.block_index, + block_time: Some( + blk.header.as_ref().unwrap().timestamp.as_ref().unwrap().to_owned() + ), + block_number: blk.number, + pool_id: event.pool_id.to_vec(), + pool_address: event.pool_address, + specialization: event.specialization.to_i32() as u32, + from_address: view.transaction.clone().from, + to_address: view.transaction.clone().to, + }); + } + + None + }) + }) + .collect(), + }) +} + +#[substreams::handlers::map] +fn db_out(events: vault::Events) -> Result { + // Initialize changes container + let mut tables = DatabaseChangeTables::new(); + + // Loop over all the abis events to create changes + events.pool_registrations.into_iter().for_each(|evt: vault::PoolRegistered| { + tables + .create_row("pool_registrations", [("tx_hash", evt.clone().tx_hash), ("log_index", evt.clone().log_index.to_string())]) + .set("block_time", evt.block_time.as_ref().unwrap()) + .set("block_number", evt.block_number) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("pool_address", Hex(&evt.pool_address).to_string()) + .set("specialization", evt.clone().specialization) + .set("from_address", Hex(&evt.from_address).to_string()) + .set("to_address", Hex(&evt.to_address).to_string()); + }); + + Ok(tables.to_database_changes()) +} + +#[substreams::handlers::map] +fn graph_out(events: vault::Events) -> Result { + // Initialize changes container + let mut tables = EntityChangesTables::new(); + + // Loop over all the abis events to create changes + events.pool_registrations.into_iter().for_each(|evt: vault::PoolRegistered| { + tables + .create_row("pool_registrations", format!("{}-{}", evt.tx_hash, evt.log_index)) + .set("block_time", evt.block_time.as_ref().unwrap()) + .set("block_number", evt.block_number) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("pool_address", Hex(&evt.pool_address).to_string()) + .set("specialization", evt.clone().specialization) + .set("from_address", Hex(&evt.from_address).to_string()) + .set("to_address", Hex(&evt.to_address).to_string()); + }); + + Ok(tables.to_entity_changes()) +} diff --git a/balancer-v2/src/pb.rs b/balancer-v2/src/pb.rs new file mode 100644 index 00000000..30156977 --- /dev/null +++ b/balancer-v2/src/pb.rs @@ -0,0 +1,9 @@ +#[rustfmt::skip] +#[path = "../target/pb/vault.v1.rs"] +pub(in crate::pb) mod vault_v1; + +pub mod vault { + pub mod v1 { + pub use super::super::vault_v1::*; + } +} diff --git a/balancer-v2/subgraph.yaml b/balancer-v2/subgraph.yaml new file mode 100644 index 00000000..6a7ebdea --- /dev/null +++ b/balancer-v2/subgraph.yaml @@ -0,0 +1,17 @@ +specVersion: 0.0.6 +description: Balancer v2 powered by substreams +repository: https://github.com/messari/substreams +schema: + file: ./schema.graphql + +dataSources: + - kind: substreams + name: balancer_v2 + network: mainnet + source: + package: + moduleName: graph_out + file: balancer-v2-v0.0.1.spkg + mapping: + kind: substreams/graph-entities + apiVersion: 0.0.5 diff --git a/balancer-v2/substreams.sql.yaml b/balancer-v2/substreams.sql.yaml new file mode 100644 index 00000000..3fe7fd5a --- /dev/null +++ b/balancer-v2/substreams.sql.yaml @@ -0,0 +1,57 @@ +specVersion: v0.1.0 +package: + name: balancer_v2 + version: v0.1.0 + +imports: + entity: https://github.com/streamingfast/substreams-entity-change/releases/download/v1.1.0/substreams-entity-change-v1.1.0.spkg + sql: https://github.com/streamingfast/substreams-sink-sql/releases/download/protodefs-v1.0.7/substreams-sink-sql-protodefs-v1.0.7.spkg + graph: https://github.com/streamingfast/substreams-sink-subgraph/releases/download/v0.1.0/substreams-sink-subgraph-protodefs-v0.1.0.spkg + database_change: https://github.com/streamingfast/substreams-sink-database-changes/releases/download/v1.2.1/substreams-database-change-v1.2.1.spkg + +binaries: + default: + type: wasm/rust-v1 + file: "../target/wasm32-unknown-unknown/release/substreams.wasm" + +protobuf: + files: + - vault.proto + importPaths: + - ./proto + +modules: + - name: map_events + kind: map + initialBlock: 12272146 + inputs: + - source: sf.ethereum.type.v2.Block + output: + type: proto:vault.v1.Events + + - name: db_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + output: + type: proto:sf.substreams.sink.database.v1.DatabaseChanges + + - name: graph_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + output: + type: proto:sf.substreams.entity.v1.EntityChanges + +network: mainnet + +sink: + module: db_out + type: sf.substreams.sink.sql.v1.Service + config: + schema: "./schema.sql" + engine: postgres + postgraphile_frontend: + enabled: true diff --git a/balancer-v2/substreams.yaml b/balancer-v2/substreams.yaml new file mode 100644 index 00000000..9519bdc5 --- /dev/null +++ b/balancer-v2/substreams.yaml @@ -0,0 +1,48 @@ +specVersion: v0.1.0 +package: + name: balancer_v2 + version: v0.1.0 + +imports: + entity: https://github.com/streamingfast/substreams-entity-change/releases/download/v1.1.0/substreams-entity-change-v1.1.0.spkg + sql: https://github.com/streamingfast/substreams-sink-sql/releases/download/protodefs-v1.0.7/substreams-sink-sql-protodefs-v1.0.7.spkg + graph: https://github.com/streamingfast/substreams-sink-subgraph/releases/download/v0.1.0/substreams-sink-subgraph-protodefs-v0.1.0.spkg + database_change: https://github.com/streamingfast/substreams-sink-database-changes/releases/download/v1.2.1/substreams-database-change-v1.2.1.spkg + +binaries: + default: + type: wasm/rust-v1 + file: "../target/wasm32-unknown-unknown/release/substreams.wasm" + +protobuf: + files: + - vault.proto + importPaths: + - ./proto + +modules: + - name: map_events + kind: map + initialBlock: 12272146 + inputs: + - source: sf.ethereum.type.v2.Block + output: + type: proto:vault.v1.Events + + - name: db_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + output: + type: proto:sf.substreams.sink.database.v1.DatabaseChanges + + - name: graph_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + output: + type: proto:sf.substreams.entity.v1.EntityChanges + +network: mainnet