diff --git a/.gitignore b/.gitignore index f78c572..926e026 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +sink-data/* .vscode/ .idea/ Reference/ diff --git a/Cargo.lock b/Cargo.lock index 1521502..dbcf1a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ dependencies = [ "ethabi", "hex-literal", "prost 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-ethereum 0.8.0", + "substreams-ethereum", "substreams-helper", ] @@ -58,6 +58,25 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "balancer_v2" +version = "0.0.1" +dependencies = [ + "anyhow", + "ethabi", + "getrandom", + "hex-literal", + "num-bigint", + "num-traits", + "prost 0.11.9", + "prost-types 0.11.9", + "regex", + "substreams 0.5.12", + "substreams-database-change", + "substreams-entity-change 1.3.1", + "substreams-ethereum", +] + [[package]] name = "base64" version = "0.13.1" @@ -179,9 +198,9 @@ dependencies = [ "ethabi", "num-bigint", "prost 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-ethereum 0.8.0", + "substreams-ethereum", "tiny-keccak", ] @@ -247,9 +266,9 @@ dependencies = [ "hex-literal", "prost 0.11.9", "serde_json", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-ethereum 0.8.0", + "substreams-ethereum", "substreams-helper", "tiny-keccak", ] @@ -269,9 +288,9 @@ dependencies = [ "hex-literal", "lazy_static", "prost 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-ethereum 0.8.0", + "substreams-ethereum", "substreams-helper", ] @@ -283,9 +302,9 @@ dependencies = [ "ethabi", "hex-literal", "prost 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-ethereum 0.8.0", + "substreams-ethereum", "substreams-helper", ] @@ -319,9 +338,9 @@ dependencies = [ "hex-literal", "num-bigint", "prost 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-ethereum 0.8.0", + "substreams-ethereum", "substreams-helper", ] @@ -335,10 +354,10 @@ dependencies = [ "hex-literal", "num-bigint", "prost 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", "substreams-entity-change 0.3.0", - "substreams-ethereum 0.8.0", + "substreams-ethereum", "substreams-helper", ] @@ -623,9 +642,9 @@ dependencies = [ "hex-literal", "prost 0.11.9", "prost-types 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-ethereum 0.8.0", + "substreams-ethereum", "substreams-helper", "thiserror", ] @@ -1089,21 +1108,22 @@ dependencies = [ [[package]] name = "substreams" -version = "0.5.10" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af972e374502cdfc9998132f5343848d1c58f27a295dc061a89804371f408a46" +checksum = "6e3524a4e2931ff6cd58783e62adbd7e44f461752eca0c423793cfb462351f24" dependencies = [ "anyhow", "bigdecimal", "hex", "hex-literal", "num-bigint", + "num-integer", "num-traits", "pad", "prost 0.11.9", "prost-build 0.11.9", "prost-types 0.11.9", - "substreams-macro 0.5.10", + "substreams-macro 0.5.12", "thiserror", ] @@ -1113,20 +1133,20 @@ version = "0.1.0" dependencies = [ "prost 0.11.9", "regex", - "substreams 0.5.10", - "substreams-ethereum 0.8.0", + "substreams 0.5.12", + "substreams-ethereum", "thiserror", ] [[package]] name = "substreams-database-change" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ea09c700498fea3e50eb9aab5b0637d8bfce888be899aa68f987132923e46cc" +checksum = "ed32ca6fc7fa4b7a684d3abd5bb0545aadd2df82402e7336443cdbb6f8b350c3" dependencies = [ "prost 0.11.9", "prost-types 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", ] [[package]] @@ -1138,19 +1158,19 @@ dependencies = [ "base64", "prost 0.11.9", "prost-types 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", ] [[package]] name = "substreams-entity-change" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d423d0c12a9284a3d6d4ec288dbc9bfec3d55f9056098ba91a6dcfa64fb3889e" +checksum = "e07421917bd53518cb65b03e03671ecda0653995c71e5a2be815c3c755ea23c0" dependencies = [ "base64", "prost 0.11.9", "prost-types 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", ] [[package]] @@ -1162,9 +1182,9 @@ dependencies = [ "getrandom", "hex-literal", "prost 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-ethereum 0.8.0", + "substreams-ethereum", "substreams-helper", ] @@ -1176,22 +1196,9 @@ dependencies = [ "ethabi", "hex-literal", "prost 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-ethereum 0.8.0", -] - -[[package]] -name = "substreams-ethereum" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a426822f6032fa28145cb2cb7661e70554da839a40ee08b6348f1479a44e1b" -dependencies = [ - "getrandom", - "substreams 0.5.10", - "substreams-ethereum-abigen 0.8.0", - "substreams-ethereum-core 0.8.0", - "substreams-ethereum-derive 0.8.0", + "substreams-ethereum", ] [[package]] @@ -1202,27 +1209,10 @@ checksum = "48f45dc04be50b7ca08d6d5c4560ee3eeba16ccaa1c124d0361bb30b5b84e28b" dependencies = [ "getrandom", "num-bigint", - "substreams 0.5.10", - "substreams-ethereum-abigen 0.9.9", - "substreams-ethereum-core 0.9.9", - "substreams-ethereum-derive 0.9.9", -] - -[[package]] -name = "substreams-ethereum-abigen" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd2ba34bc4d19288e7487aa2b13ee75955222809d2dab48c9dad33230a6f4732" -dependencies = [ - "anyhow", - "ethabi", - "heck", - "hex", - "prettyplease", - "proc-macro2", - "quote", - "substreams-ethereum-core 0.8.0", - "syn 1.0.109", + "substreams 0.5.12", + "substreams-ethereum-abigen", + "substreams-ethereum-core", + "substreams-ethereum-derive", ] [[package]] @@ -1238,26 +1228,10 @@ dependencies = [ "prettyplease", "proc-macro2", "quote", - "substreams-ethereum-core 0.9.9", + "substreams-ethereum-core", "syn 1.0.109", ] -[[package]] -name = "substreams-ethereum-core" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f680a56fc8df55dfd0b3465af2ed6f0eb471b4a0b5a9e0e56c13377911104b01" -dependencies = [ - "bigdecimal", - "ethabi", - "getrandom", - "num-bigint", - "prost 0.11.9", - "prost-build 0.11.9", - "prost-types 0.11.9", - "substreams 0.5.10", -] - [[package]] name = "substreams-ethereum-core" version = "0.9.9" @@ -1271,22 +1245,7 @@ dependencies = [ "prost 0.11.9", "prost-build 0.11.9", "prost-types 0.11.9", - "substreams 0.5.10", -] - -[[package]] -name = "substreams-ethereum-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40d3bcb83759b62c2ed372b582be8ba46fc844362a7f7a35fa0269590066118" -dependencies = [ - "ethabi", - "heck", - "hex", - "proc-macro2", - "quote", - "substreams-ethereum-abigen 0.8.0", - "syn 1.0.109", + "substreams 0.5.12", ] [[package]] @@ -1301,7 +1260,7 @@ dependencies = [ "num-bigint", "proc-macro2", "quote", - "substreams-ethereum-abigen 0.9.9", + "substreams-ethereum-abigen", "syn 1.0.109", ] @@ -1320,10 +1279,10 @@ dependencies = [ "pad", "prost 0.11.9", "prost-types 0.10.1", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-entity-change 1.3.0", - "substreams-ethereum 0.8.0", + "substreams-entity-change 1.3.1", + "substreams-ethereum", "thiserror", "tiny-keccak", ] @@ -1354,9 +1313,9 @@ dependencies = [ [[package]] name = "substreams-macro" -version = "0.5.10" +version = "0.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6521ccd011a4c3f52cd3c31fc7400733e4feba2094e0e0e6354adca25b2b3f37" +checksum = "63c2b15adf5b4d7a6d1a73c73df951a6b2df6fbb4f0b41304dc28c5550ce0ed0" dependencies = [ "proc-macro2", "quote", @@ -1386,10 +1345,10 @@ dependencies = [ "hex-literal", "pad", "prost 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-entity-change 1.3.0", - "substreams-ethereum 0.8.0", + "substreams-entity-change 1.3.1", + "substreams-ethereum", "substreams-helper", ] @@ -1425,10 +1384,10 @@ dependencies = [ "hex-literal", "num-bigint", "prost 0.11.9", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-common", - "substreams-entity-change 1.3.0", - "substreams-ethereum 0.8.0", + "substreams-entity-change 1.3.1", + "substreams-ethereum", "substreams-helper", ] @@ -1551,10 +1510,10 @@ dependencies = [ "prost 0.11.9", "prost-types 0.11.9", "regex", - "substreams 0.5.10", + "substreams 0.5.12", "substreams-database-change", - "substreams-entity-change 1.3.0", - "substreams-ethereum 0.9.9", + "substreams-entity-change 1.3.1", + "substreams-ethereum", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 9392ff7..2ddac00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,12 +16,13 @@ members = [ "synthetix", "aave-v2", "sql/uniswap_v2", + "sql/balancer_v2", ] exclude = ["messari-cli"] [workspace.dependencies] substreams = "0.5.0" -substreams-ethereum = "0.8.0" +substreams-ethereum = "0.9.0" substreams-solana = "0.1.0" [build] diff --git a/sql/balancer_v2/Cargo.toml b/sql/balancer_v2/Cargo.toml new file mode 100644 index 0000000..c189039 --- /dev/null +++ b/sql/balancer_v2/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "balancer_v2" +version = "0.0.1" +edition = "2021" + +[lib] +name = "substreams" +crate-type = ["cdylib"] + +[dependencies] +ethabi = "17" +hex-literal = "0.3.4" +num-bigint = "0.4" +num-traits = "0.2.15" +prost = "0.11" +prost-types = "0.11" +substreams = "0.5.12" +substreams-ethereum = "0.9.9" +substreams-database-change = "1.3.1" +substreams-entity-change = "1.3.1" + +# Required so that ethabi > ethereum-types build correctly under wasm32-unknown-unknown +[target.wasm32-unknown-unknown.dependencies] +getrandom = { version = "0.2", features = ["custom"] } + +[build-dependencies] +anyhow = "1" +substreams-ethereum = "0.9" +regex = "1.8" diff --git a/sql/balancer_v2/Makefile b/sql/balancer_v2/Makefile new file mode 100644 index 0000000..168d701 --- /dev/null +++ b/sql/balancer_v2/Makefile @@ -0,0 +1,26 @@ +CARGO_VERSION := $(shell cargo version 2>/dev/null) + +.PHONY: build +build: +ifdef CARGO_VERSION + cargo build --target wasm32-unknown-unknown --release +else + @echo "Building substreams target using Docker. To speed up this step, install a Rust development environment." + docker run --rm -ti --init -v ${PWD}:/usr/src --workdir /usr/src/ rust:bullseye cargo build --target wasm32-unknown-unknown --release +endif + +.PHONY: run +run: build + substreams run substreams.yaml $(if $(MODULE),$(MODULE),map_events) $(if $(START_BLOCK),-s $(START_BLOCK)) $(if $(STOP_BLOCK),-t $(STOP_BLOCK)) + +.PHONY: gui +gui: build + substreams gui substreams.yaml $(if $(MODULE),$(MODULE),map_events) $(if $(START_BLOCK),-s $(START_BLOCK)) $(if $(STOP_BLOCK),-t $(STOP_BLOCK)) + +.PHONY: protogen +protogen: + substreams protogen ./substreams.yaml --exclude-paths="sf/substreams,google" + +.PHONY: pack +pack: build + substreams pack substreams.yaml diff --git a/sql/balancer_v2/abi/pools_contract.abi.json b/sql/balancer_v2/abi/pools_contract.abi.json new file mode 100644 index 0000000..49505d2 --- /dev/null +++ b/sql/balancer_v2/abi/pools_contract.abi.json @@ -0,0 +1,886 @@ +[ + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IVault", + "name": "vault", + "type": "address" + }, + { + "internalType": "contract IProtocolFeePercentagesProvider", + "name": "protocolFeeProvider", + "type": "address" + }, + { "internalType": "string", "name": "name", "type": "string" }, + { "internalType": "string", "name": "symbol", "type": "string" }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "contract IRateProvider[]", + "name": "rateProviders", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "tokenRateCacheDurations", + "type": "uint256[]" + }, + { + "internalType": "bool", + "name": "exemptFromYieldProtocolFeeFlag", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "amplificationParameter", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pauseWindowDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bufferPeriodDuration", + "type": "uint256" + }, + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "string", "name": "version", "type": "string" } + ], + "internalType": "struct ComposableStablePool.NewPoolParams", + "name": "params", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "startValue", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "endValue", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "startTime", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "endTime", + "type": "uint256" + } + ], + "name": "AmpUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "currentValue", + "type": "uint256" + } + ], + "name": "AmpUpdateStopped", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "PausedStateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "feeType", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "protocolFeePercentage", + "type": "uint256" + } + ], + "name": "ProtocolFeePercentageCacheUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "enabled", + "type": "bool" + } + ], + "name": "RecoveryModeStateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "name": "SwapFeePercentageChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenIndex", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "TokenRateCacheUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenIndex", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "contract IRateProvider", + "name": "provider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "cacheDuration", + "type": "uint256" + } + ], + "name": "TokenRateProviderSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "decreaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "disableRecoveryMode", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "enableRecoveryMode", + "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": "getActualSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAmplificationParameter", + "outputs": [ + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "bool", "name": "isUpdating", "type": "bool" }, + { "internalType": "uint256", "name": "precision", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { "internalType": "contract IAuthorizer", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBptIndex", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDomainSeparator", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLastJoinExitData", + "outputs": [ + { + "internalType": "uint256", + "name": "lastJoinExitAmplification", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "lastPostJoinExitInvariant", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMinimumBpt", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "getNextNonce", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOwner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "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": [], + "name": "getPoolId", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "feeType", "type": "uint256" } + ], + "name": "getProtocolFeePercentageCache", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getProtocolFeesCollector", + "outputs": [ + { + "internalType": "contract IProtocolFeesCollector", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getProtocolSwapFeeDelegation", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRateProviders", + "outputs": [ + { + "internalType": "contract IRateProvider[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getScalingFactors", + "outputs": [ + { "internalType": "uint256[]", "name": "", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSwapFeePercentage", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "contract IERC20", "name": "token", "type": "address" } + ], + "name": "getTokenRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "contract IERC20", "name": "token", "type": "address" } + ], + "name": "getTokenRateCache", + "outputs": [ + { "internalType": "uint256", "name": "rate", "type": "uint256" }, + { "internalType": "uint256", "name": "oldRate", "type": "uint256" }, + { "internalType": "uint256", "name": "duration", "type": "uint256" }, + { "internalType": "uint256", "name": "expires", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVault", + "outputs": [ + { "internalType": "contract IVault", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "inRecoveryMode", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "addedValue", "type": "uint256" } + ], + "name": "increaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isExemptFromYieldProtocolFee", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "contract IERC20", "name": "token", "type": "address" } + ], + "name": "isTokenExemptFromYieldProtocolFee", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" } + ], + "name": "nonces", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "name": "onExitPool", + "outputs": [ + { "internalType": "uint256[]", "name": "", "type": "uint256[]" }, + { "internalType": "uint256[]", "name": "", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "name": "onJoinPool", + "outputs": [ + { "internalType": "uint256[]", "name": "", "type": "uint256[]" }, + { "internalType": "uint256[]", "name": "", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum IVault.SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "contract IERC20", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "tokenOut", + "type": "address" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "internalType": "struct IPoolSwapStructs.SwapRequest", + "name": "swapRequest", + "type": "tuple" + }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { "internalType": "uint256", "name": "indexIn", "type": "uint256" }, + { "internalType": "uint256", "name": "indexOut", "type": "uint256" } + ], + "name": "onSwap", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "name": "queryExit", + "outputs": [ + { "internalType": "uint256", "name": "bptIn", "type": "uint256" }, + { "internalType": "uint256[]", "name": "amountsOut", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256[]", "name": "balances", "type": "uint256[]" }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "name": "queryJoin", + "outputs": [ + { "internalType": "uint256", "name": "bptOut", "type": "uint256" }, + { "internalType": "uint256[]", "name": "amountsIn", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "contract IERC20", "name": "token", "type": "address" }, + { "internalType": "bytes", "name": "poolConfig", "type": "bytes" } + ], + "name": "setAssetManagerPoolConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "name": "setSwapFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "contract IERC20", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "duration", "type": "uint256" } + ], + "name": "setTokenRateCacheDuration", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "rawEndValue", "type": "uint256" }, + { "internalType": "uint256", "name": "endTime", "type": "uint256" } + ], + "name": "startAmplificationParameterUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "stopAmplificationParameterUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateProtocolFeePercentageCache", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "contract IERC20", "name": "token", "type": "address" } + ], + "name": "updateTokenRateCache", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "version", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/sql/balancer_v2/abi/vault_contract.abi.json b/sql/balancer_v2/abi/vault_contract.abi.json new file mode 100644 index 0000000..03668f9 --- /dev/null +++ b/sql/balancer_v2/abi/vault_contract.abi.json @@ -0,0 +1,918 @@ +[ + { + "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": "enum IVault.SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "components": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "uint256", + "name": "assetInIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "assetOutIndex", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "internalType": "struct IVault.BatchSwapStep[]", + "name": "swaps", + "type": "tuple[]" + }, + { + "internalType": "contract IAsset[]", + "name": "assets", + "type": "address[]" + }, + { + "components": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { + "internalType": "bool", + "name": "fromInternalBalance", + "type": "bool" + }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bool", + "name": "toInternalBalance", + "type": "bool" + } + ], + "internalType": "struct IVault.FundManagement", + "name": "funds", + "type": "tuple" + }, + { "internalType": "int256[]", "name": "limits", "type": "int256[]" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "batchSwap", + "outputs": [ + { "internalType": "int256[]", "name": "assetDeltas", "type": "int256[]" } + ], + "stateMutability": "payable", + "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": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "components": [ + { + "internalType": "contract IAsset[]", + "name": "assets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "minAmountsOut", + "type": "uint256[]" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" }, + { + "internalType": "bool", + "name": "toInternalBalance", + "type": "bool" + } + ], + "internalType": "struct IVault.ExitPoolRequest", + "name": "request", + "type": "tuple" + } + ], + "name": "exitPool", + "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": "bytes32", "name": "poolId", "type": "bytes32" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { + "components": [ + { + "internalType": "contract IAsset[]", + "name": "assets", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "maxAmountsIn", + "type": "uint256[]" + }, + { "internalType": "bytes", "name": "userData", "type": "bytes" }, + { + "internalType": "bool", + "name": "fromInternalBalance", + "type": "bool" + } + ], + "internalType": "struct IVault.JoinPoolRequest", + "name": "request", + "type": "tuple" + } + ], + "name": "joinPool", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum IVault.PoolBalanceOpKind", + "name": "kind", + "type": "uint8" + }, + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "internalType": "struct IVault.PoolBalanceOp[]", + "name": "ops", + "type": "tuple[]" + } + ], + "name": "managePoolBalance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum IVault.UserBalanceOpKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "contract IAsset", + "name": "asset", + "type": "address" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "address", "name": "sender", "type": "address" }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + } + ], + "internalType": "struct IVault.UserBalanceOp[]", + "name": "ops", + "type": "tuple[]" + } + ], + "name": "manageUserBalance", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IVault.SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "components": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "uint256", + "name": "assetInIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "assetOutIndex", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "internalType": "struct IVault.BatchSwapStep[]", + "name": "swaps", + "type": "tuple[]" + }, + { + "internalType": "contract IAsset[]", + "name": "assets", + "type": "address[]" + }, + { + "components": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { + "internalType": "bool", + "name": "fromInternalBalance", + "type": "bool" + }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bool", + "name": "toInternalBalance", + "type": "bool" + } + ], + "internalType": "struct IVault.FundManagement", + "name": "funds", + "type": "tuple" + } + ], + "name": "queryBatchSwap", + "outputs": [{ "internalType": "int256[]", "name": "", "type": "int256[]" }], + "stateMutability": "nonpayable", + "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" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "bytes32", "name": "poolId", "type": "bytes32" }, + { + "internalType": "enum IVault.SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "contract IAsset", + "name": "assetIn", + "type": "address" + }, + { + "internalType": "contract IAsset", + "name": "assetOut", + "type": "address" + }, + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "bytes", "name": "userData", "type": "bytes" } + ], + "internalType": "struct IVault.SingleSwap", + "name": "singleSwap", + "type": "tuple" + }, + { + "components": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { + "internalType": "bool", + "name": "fromInternalBalance", + "type": "bool" + }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bool", + "name": "toInternalBalance", + "type": "bool" + } + ], + "internalType": "struct IVault.FundManagement", + "name": "funds", + "type": "tuple" + }, + { "internalType": "uint256", "name": "limit", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swap", + "outputs": [ + { + "internalType": "uint256", + "name": "amountCalculated", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } +] diff --git a/sql/balancer_v2/build.rs b/sql/balancer_v2/build.rs new file mode 100644 index 0000000..a8c899d --- /dev/null +++ b/sql/balancer_v2/build.rs @@ -0,0 +1,33 @@ +use anyhow::{Ok, Result}; +use regex::Regex; +use substreams_ethereum::Abigen; +use std::fs; + +fn main() -> Result<(), anyhow::Error> { + let file_names = [ + "abi/vault_contract.abi.json", + "abi/pools_contract.abi.json", + ]; + let file_output_names = [ + "src/abi/vault_contract.rs", + "src/abi/pools_contract.rs", + ]; + + let mut i = 0; + for f in file_names { + let contents = fs::read_to_string(f) + .expect("Should have been able to read the file"); + + // sanitize fields and attributes starting with an underscore + let regex = Regex::new(r#"("\w+"\s?:\s?")_(\w+")"#).unwrap(); + let sanitized_abi_file = regex.replace_all(contents.as_str(), "${1}u_${2}"); + + Abigen::from_bytes("Contract", sanitized_abi_file.as_bytes())? + .generate()? + .write_to_file(file_output_names[i])?; + + i = i+1; + } + + Ok(()) +} diff --git a/sql/balancer_v2/proto/contract.proto b/sql/balancer_v2/proto/contract.proto new file mode 100644 index 0000000..8cd7ae8 --- /dev/null +++ b/sql/balancer_v2/proto/contract.proto @@ -0,0 +1,708 @@ +syntax = "proto3"; + +import "google/protobuf/timestamp.proto"; + +package contract.v1; + +message Events { + repeated vault_AuthorizerChanged vault_authorizer_changeds = 1; + repeated vault_ExternalBalanceTransfer vault_external_balance_transfers = 2; + repeated vault_FlashLoan vault_flash_loans = 3; + repeated vault_InternalBalanceChanged vault_internal_balance_changeds = 4; + repeated vault_PausedStateChanged vault_paused_state_changeds = 5; + repeated vault_PoolBalanceChanged vault_pool_balance_changeds = 6; + repeated vault_PoolBalanceManaged vault_pool_balance_manageds = 7; + repeated vault_PoolRegistered vault_pool_registereds = 8; + repeated vault_RelayerApprovalChanged vault_relayer_approval_changeds = 9; + repeated vault_Swap vault_swaps = 10; + repeated vault_TokensDeregistered vault_tokens_deregistereds = 11; + repeated vault_TokensRegistered vault_tokens_registereds = 12; + repeated pools_AmpUpdateStarted pools_amp_update_starteds = 13; + repeated pools_AmpUpdateStopped pools_amp_update_stoppeds = 14; + repeated pools_Approval pools_approvals = 15; + repeated pools_PausedStateChanged pools_paused_state_changeds = 16; + repeated pools_ProtocolFeePercentageCacheUpdated pools_protocol_fee_percentage_cache_updateds = 17; + repeated pools_RecoveryModeStateChanged pools_recovery_mode_state_changeds = 18; + repeated pools_SwapFeePercentageChanged pools_swap_fee_percentage_changeds = 19; + repeated pools_TokenRateCacheUpdated pools_token_rate_cache_updateds = 20; + repeated pools_TokenRateProviderSet pools_token_rate_provider_sets = 21; + repeated pools_Transfer pools_transfers = 22; +} + +message Calls { + repeated vault_BatchSwapCall vault_call_batch_swaps = 1; + repeated vault_DeregisterTokensCall vault_call_deregister_tokens = 2; + repeated vault_ExitPoolCall vault_call_exit_pools = 3; + repeated vault_FlashLoanCall vault_call_flash_loans = 4; + repeated vault_JoinPoolCall vault_call_join_pools = 5; + repeated vault_ManagePoolBalanceCall vault_call_manage_pool_balances = 6; + repeated vault_ManageUserBalanceCall vault_call_manage_user_balances = 7; + repeated vault_QueryBatchSwapCall vault_call_query_batch_swaps = 8; + repeated vault_RegisterPoolCall vault_call_register_pools = 9; + repeated vault_RegisterTokensCall vault_call_register_tokens = 10; + repeated vault_SetAuthorizerCall vault_call_set_authorizers = 11; + repeated vault_SetPausedCall vault_call_set_pauseds = 12; + repeated vault_SetRelayerApprovalCall vault_call_set_relayer_approvals = 13; + repeated vault_SwapCall vault_call_swaps = 14; + repeated pools_ApproveCall pools_call_approves = 15; + repeated pools_DecreaseAllowanceCall pools_call_decrease_allowances = 16; + repeated pools_DisableRecoveryModeCall pools_call_disable_recovery_modes = 17; + repeated pools_EnableRecoveryModeCall pools_call_enable_recovery_modes = 18; + repeated pools_IncreaseAllowanceCall pools_call_increase_allowances = 19; + repeated pools_OnExitPoolCall pools_call_on_exit_pools = 20; + repeated pools_OnJoinPoolCall pools_call_on_join_pools = 21; + repeated pools_OnSwapCall pools_call_on_swaps = 22; + repeated pools_PauseCall pools_call_pauses = 23; + repeated pools_PermitCall pools_call_permits = 24; + repeated pools_QueryExitCall pools_call_query_exits = 25; + repeated pools_QueryJoinCall pools_call_query_joins = 26; + repeated pools_SetAssetManagerPoolConfigCall pools_call_set_asset_manager_pool_configs = 27; + repeated pools_SetSwapFeePercentageCall pools_call_set_swap_fee_percentages = 28; + repeated pools_SetTokenRateCacheDurationCall pools_call_set_token_rate_cache_durations = 29; + repeated pools_StartAmplificationParameterUpdateCall pools_call_start_amplification_parameter_updates = 30; + repeated pools_StopAmplificationParameterUpdateCall pools_call_stop_amplification_parameter_updates = 31; + repeated pools_TransferCall pools_call_transfers = 32; + repeated pools_TransferFromCall pools_call_transfer_froms = 33; + repeated pools_UnpauseCall pools_call_unpauses = 34; + repeated pools_UpdateProtocolFeePercentageCacheCall pools_call_update_protocol_fee_percentage_caches = 35; + repeated pools_UpdateTokenRateCacheCall pools_call_update_token_rate_caches = 36; +} + + +message vault_AuthorizerChanged { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes new_authorizer = 5; +} + +message vault_ExternalBalanceTransfer { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes token = 5; + bytes sender = 6; + bytes recipient = 7; + string amount = 8; +} + +message vault_FlashLoan { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes recipient = 5; + bytes token = 6; + string amount = 7; + string fee_amount = 8; +} + +message vault_InternalBalanceChanged { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes user = 5; + bytes token = 6; + string delta = 7; +} + +message vault_PausedStateChanged { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bool paused = 5; +} + +message vault_PoolBalanceChanged { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes pool_id = 5; + bytes liquidity_provider = 6; + repeated bytes tokens = 7; + repeated string deltas = 8; + repeated string protocol_fee_amounts = 9; +} + +message vault_PoolBalanceManaged { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes pool_id = 5; + bytes asset_manager = 6; + bytes token = 7; + string cash_delta = 8; + string managed_delta = 9; +} + +message vault_PoolRegistered { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes pool_id = 5; + bytes pool_address = 6; + uint64 specialization = 7; +} + +message vault_RelayerApprovalChanged { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes relayer = 5; + bytes sender = 6; + bool approved = 7; +} + +message vault_Swap { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes pool_id = 5; + bytes token_in = 6; + bytes token_out = 7; + string amount_in = 8; + string amount_out = 9; +} + +message vault_TokensDeregistered { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes pool_id = 5; + repeated bytes tokens = 6; +} + +message vault_TokensRegistered { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + bytes pool_id = 5; + repeated bytes tokens = 6; + repeated bytes asset_managers = 7; +} + +message vault_BatchSwapCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + uint64 kind = 6; + repeated bytes assets = 7; + repeated string limits = 8; + string deadline = 9; + repeated string output_asset_deltas = 10; +} + +message vault_DeregisterTokensCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + bytes pool_id = 6; + repeated bytes tokens = 7; +} + +message vault_ExitPoolCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + bytes pool_id = 6; + bytes sender = 7; + bytes recipient = 8; +} + +message vault_FlashLoanCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + bytes recipient = 6; + repeated bytes tokens = 7; + repeated string amounts = 8; + bytes user_data = 9; +} + +message vault_JoinPoolCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + bytes pool_id = 6; + bytes sender = 7; + bytes recipient = 8; +} + +message vault_ManagePoolBalanceCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; +} + +message vault_ManageUserBalanceCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; +} + +message vault_QueryBatchSwapCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + uint64 kind = 6; + repeated bytes assets = 7; + repeated string output_param0 = 8; +} + +message vault_RegisterPoolCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + uint64 specialization = 6; + bytes output_param0 = 7; +} + +message vault_RegisterTokensCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + bytes pool_id = 6; + repeated bytes tokens = 7; + repeated bytes asset_managers = 8; +} + +message vault_SetAuthorizerCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + bytes new_authorizer = 6; +} + +message vault_SetPausedCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + bool paused = 6; +} + +message vault_SetRelayerApprovalCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + bytes sender = 6; + bytes relayer = 7; + bool approved = 8; +} + +message vault_SwapCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string limit = 6; + string deadline = 7; + string output_amount_calculated = 8; +} + +message pools_AmpUpdateStarted { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + string evt_address = 5; + string start_value = 6; + string end_value = 7; + string start_time = 8; + string end_time = 9; +} + +message pools_AmpUpdateStopped { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + string evt_address = 5; + string current_value = 6; +} + +message pools_Approval { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + string evt_address = 5; + bytes owner = 6; + bytes spender = 7; + string value = 8; +} + +message pools_PausedStateChanged { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + string evt_address = 5; + bool paused = 6; +} + +message pools_ProtocolFeePercentageCacheUpdated { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + string evt_address = 5; + string fee_type = 6; + string protocol_fee_percentage = 7; +} + +message pools_RecoveryModeStateChanged { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + string evt_address = 5; + bool enabled = 6; +} + +message pools_SwapFeePercentageChanged { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + string evt_address = 5; + string swap_fee_percentage = 6; +} + +message pools_TokenRateCacheUpdated { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + string evt_address = 5; + string token_index = 6; + string rate = 7; +} + +message pools_TokenRateProviderSet { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + string evt_address = 5; + string token_index = 6; + bytes provider = 7; + string cache_duration = 8; +} + +message pools_Transfer { + string evt_tx_hash = 1; + uint32 evt_index = 2; + google.protobuf.Timestamp evt_block_time = 3; + uint64 evt_block_number = 4; + string evt_address = 5; + bytes from = 6; + bytes to = 7; + string value = 8; +} + +message pools_ApproveCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes spender = 7; + string amount = 8; + bool output_param0 = 9; +} + +message pools_DecreaseAllowanceCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes spender = 7; + string amount = 8; + bool output_param0 = 9; +} + +message pools_DisableRecoveryModeCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; +} + +message pools_EnableRecoveryModeCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; +} + +message pools_IncreaseAllowanceCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes spender = 7; + string added_value = 8; + bool output_param0 = 9; +} + +message pools_OnExitPoolCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes pool_id = 7; + bytes sender = 8; + bytes recipient = 9; + repeated string balances = 10; + string last_change_block = 11; + string protocol_swap_fee_percentage = 12; + bytes user_data = 13; + repeated string output_param0 = 14; + repeated string output_param1 = 15; +} + +message pools_OnJoinPoolCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes pool_id = 7; + bytes sender = 8; + bytes recipient = 9; + repeated string balances = 10; + string last_change_block = 11; + string protocol_swap_fee_percentage = 12; + bytes user_data = 13; + repeated string output_param0 = 14; + repeated string output_param1 = 15; +} + +message pools_OnSwapCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + repeated string balances = 7; + string index_in = 8; + string index_out = 9; + string output_param0 = 10; +} + +message pools_PauseCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; +} + +message pools_PermitCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes owner = 7; + bytes spender = 8; + string value = 9; + string deadline = 10; + uint64 v = 11; + bytes r = 12; + bytes s = 13; +} + +message pools_QueryExitCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes pool_id = 7; + bytes sender = 8; + bytes recipient = 9; + repeated string balances = 10; + string last_change_block = 11; + string protocol_swap_fee_percentage = 12; + bytes user_data = 13; + string output_bpt_in = 14; + repeated string output_amounts_out = 15; +} + +message pools_QueryJoinCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes pool_id = 7; + bytes sender = 8; + bytes recipient = 9; + repeated string balances = 10; + string last_change_block = 11; + string protocol_swap_fee_percentage = 12; + bytes user_data = 13; + string output_bpt_out = 14; + repeated string output_amounts_in = 15; +} + +message pools_SetAssetManagerPoolConfigCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes token = 7; + bytes pool_config = 8; +} + +message pools_SetSwapFeePercentageCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + string swap_fee_percentage = 7; +} + +message pools_SetTokenRateCacheDurationCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes token = 7; + string duration = 8; +} + +message pools_StartAmplificationParameterUpdateCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + string raw_end_value = 7; + string end_time = 8; +} + +message pools_StopAmplificationParameterUpdateCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; +} + +message pools_TransferCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes recipient = 7; + string amount = 8; + bool output_param0 = 9; +} + +message pools_TransferFromCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes sender = 7; + bytes recipient = 8; + string amount = 9; + bool output_param0 = 10; +} + +message pools_UnpauseCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; +} + +message pools_UpdateProtocolFeePercentageCacheCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; +} + +message pools_UpdateTokenRateCacheCall { + string call_tx_hash = 1; + google.protobuf.Timestamp call_block_time = 2; + uint64 call_block_number = 3; + uint64 call_ordinal = 4; + bool call_success = 5; + string call_address = 6; + bytes token = 7; +} diff --git a/sql/balancer_v2/rust-toolchain.toml b/sql/balancer_v2/rust-toolchain.toml new file mode 100644 index 0000000..ec334c0 --- /dev/null +++ b/sql/balancer_v2/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.65" +components = [ "rustfmt" ] +targets = [ "wasm32-unknown-unknown" ] \ No newline at end of file diff --git a/sql/balancer_v2/schema.clickhouse.sql b/sql/balancer_v2/schema.clickhouse.sql new file mode 100644 index 0000000..01d0d8c --- /dev/null +++ b/sql/balancer_v2/schema.clickhouse.sql @@ -0,0 +1,581 @@ +CREATE TABLE IF NOT EXISTS vault_authorizer_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "new_authorizer" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_external_balance_transfer ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "amount" UInt256, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + "token" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_flash_loan ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "amount" UInt256, + "fee_amount" UInt256, + "recipient" VARCHAR(40), + "token" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_internal_balance_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "delta" Int256, + "token" VARCHAR(40), + "user" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_paused_state_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "paused" BOOL +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_pool_balance_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "deltas" Array(Int256), + "liquidity_provider" VARCHAR(40), + "pool_id" TEXT, + "protocol_fee_amounts" Array(UInt256), + "tokens" Array(VARCHAR(40)) +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_pool_balance_managed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "asset_manager" VARCHAR(40), + "cash_delta" Int256, + "managed_delta" Int256, + "pool_id" TEXT, + "token" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_pool_registered ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "pool_address" VARCHAR(40), + "pool_id" TEXT, + "specialization" UInt8 +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_relayer_approval_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "approved" BOOL, + "relayer" VARCHAR(40), + "sender" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_swap ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "amount_in" UInt256, + "amount_out" UInt256, + "pool_id" TEXT, + "token_in" VARCHAR(40), + "token_out" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_tokens_deregistered ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "pool_id" TEXT, + "tokens" Array(VARCHAR(40)) +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS vault_tokens_registered ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "asset_managers" Array(VARCHAR(40)), + "pool_id" TEXT, + "tokens" Array(VARCHAR(40)) +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); + +CREATE TABLE IF NOT EXISTS vault_call_batch_swap ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "assets" Array(VARCHAR(40)), + "deadline" UInt256, + "kind" UInt8, + "limits" Array(Int256), + "output_asset_deltas" Array(Int256) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_deregister_tokens ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "pool_id" TEXT, + "tokens" Array(VARCHAR(40)) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_exit_pool ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "pool_id" TEXT, + "recipient" VARCHAR(40), + "sender" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_flash_loan ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "amounts" Array(UInt256), + "recipient" VARCHAR(40), + "tokens" Array(VARCHAR(40)), + "user_data" TEXT +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_join_pool ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "pool_id" TEXT, + "recipient" VARCHAR(40), + "sender" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_manage_pool_balance ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_manage_user_balance ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_query_batch_swap ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "assets" Array(VARCHAR(40)), + "kind" UInt8, + "output_param0" Array(Int256) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_register_pool ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "output_param0" TEXT, + "specialization" UInt8 +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_register_tokens ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "asset_managers" Array(VARCHAR(40)), + "pool_id" TEXT, + "tokens" Array(VARCHAR(40)) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_set_authorizer ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "new_authorizer" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_set_paused ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "paused" BOOL +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_set_relayer_approval ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "approved" BOOL, + "relayer" VARCHAR(40), + "sender" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS vault_call_swap ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "deadline" UInt256, + "limit" UInt256, + "output_amount_calculated" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_amp_update_started ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "evt_address" VARCHAR(40), + "end_time" UInt256, + "end_value" UInt256, + "start_time" UInt256, + "start_value" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS pools_amp_update_stopped ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "evt_address" VARCHAR(40), + "current_value" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS pools_approval ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "evt_address" VARCHAR(40), + "owner" VARCHAR(40), + "spender" VARCHAR(40), + "value" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS pools_paused_state_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "evt_address" VARCHAR(40), + "paused" BOOL +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS pools_protocol_fee_percentage_cache_updated ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "evt_address" VARCHAR(40), + "fee_type" UInt256, + "protocol_fee_percentage" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS pools_recovery_mode_state_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "evt_address" VARCHAR(40), + "enabled" BOOL +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS pools_swap_fee_percentage_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "evt_address" VARCHAR(40), + "swap_fee_percentage" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS pools_token_rate_cache_updated ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "evt_address" VARCHAR(40), + "rate" UInt256, + "token_index" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS pools_token_rate_provider_set ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "evt_address" VARCHAR(40), + "cache_duration" UInt256, + "provider" VARCHAR(40), + "token_index" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS pools_transfer ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" UInt64, + "evt_address" VARCHAR(40), + "from" VARCHAR(40), + "to" VARCHAR(40), + "value" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("evt_tx_hash","evt_index"); +CREATE TABLE IF NOT EXISTS pools_call_approve ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "amount" UInt256, + "output_param0" BOOL, + "spender" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_decrease_allowance ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "amount" UInt256, + "output_param0" BOOL, + "spender" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_disable_recovery_mode ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_enable_recovery_mode ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_increase_allowance ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "added_value" UInt256, + "output_param0" BOOL, + "spender" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_on_exit_pool ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "balances" Array(UInt256), + "last_change_block" UInt256, + "output_param0" Array(UInt256), + "output_param1" Array(UInt256), + "pool_id" TEXT, + "protocol_swap_fee_percentage" UInt256, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + "user_data" TEXT +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_on_join_pool ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "balances" Array(UInt256), + "last_change_block" UInt256, + "output_param0" Array(UInt256), + "output_param1" Array(UInt256), + "pool_id" TEXT, + "protocol_swap_fee_percentage" UInt256, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + "user_data" TEXT +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_on_swap ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "balances" Array(UInt256), + "index_in" UInt256, + "index_out" UInt256, + "output_param0" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_pause ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_permit ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "deadline" UInt256, + "owner" VARCHAR(40), + "r" TEXT, + "s" TEXT, + "spender" VARCHAR(40), + "v" UInt8, + "value" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_query_exit ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "balances" Array(UInt256), + "last_change_block" UInt256, + "output_amounts_out" Array(UInt256), + "output_bpt_in" UInt256, + "pool_id" TEXT, + "protocol_swap_fee_percentage" UInt256, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + "user_data" TEXT +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_query_join ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "balances" Array(UInt256), + "last_change_block" UInt256, + "output_amounts_in" Array(UInt256), + "output_bpt_out" UInt256, + "pool_id" TEXT, + "protocol_swap_fee_percentage" UInt256, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + "user_data" TEXT +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_set_asset_manager_pool_config ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "pool_config" TEXT, + "token" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_set_swap_fee_percentage ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "swap_fee_percentage" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_set_token_rate_cache_duration ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "duration" UInt256, + "token" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_start_amplification_parameter_update ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "end_time" UInt256, + "raw_end_value" UInt256 +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_stop_amplification_parameter_update ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_transfer ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "amount" UInt256, + "output_param0" BOOL, + "recipient" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_transfer_from ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "amount" UInt256, + "output_param0" BOOL, + "recipient" VARCHAR(40), + "sender" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_unpause ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_update_protocol_fee_percentage_cache ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); +CREATE TABLE IF NOT EXISTS pools_call_update_token_rate_cache ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" UInt64, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "token" VARCHAR(40) +) ENGINE = MergeTree PRIMARY KEY ("call_tx_hash","call_ordinal"); diff --git a/sql/balancer_v2/schema.graphql b/sql/balancer_v2/schema.graphql new file mode 100644 index 0000000..b82da1b --- /dev/null +++ b/sql/balancer_v2/schema.graphql @@ -0,0 +1,644 @@ +type vault_authorizer_changed @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + new_authorizer: String! +} +type vault_external_balance_transfer @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + amount: BigDecimal! + recipient: String! + sender: String! + token: String! +} +type vault_flash_loan @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + amount: BigDecimal! + fee_amount: BigDecimal! + recipient: String! + token: String! +} +type vault_internal_balance_changed @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + delta: BigDecimal! + token: String! + user: String! +} +type vault_paused_state_changed @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + paused: Boolean! +} +type vault_pool_balance_changed @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + deltas: [BigDecimal!]! + liquidity_provider: String! + pool_id: String! + protocol_fee_amounts: [BigDecimal!]! + tokens: [String!]! +} +type vault_pool_balance_managed @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + asset_manager: String! + cash_delta: BigDecimal! + managed_delta: BigDecimal! + pool_id: String! + token: String! +} +type vault_pool_registered @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + pool_address: String! + pool_id: String! + specialization: Int! +} +type vault_relayer_approval_changed @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + approved: Boolean! + relayer: String! + sender: String! +} +type vault_swap @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + amount_in: BigDecimal! + amount_out: BigDecimal! + pool_id: String! + token_in: String! + token_out: String! +} +type vault_tokens_deregistered @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + pool_id: String! + tokens: [String!]! +} +type vault_tokens_registered @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + asset_managers: [String!]! + pool_id: String! + tokens: [String!]! +} +type vault_call_batch_swap @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + assets: [String!]! + deadline: BigDecimal! + kind: Int! + limits: [BigDecimal!]! + output_asset_deltas: [BigDecimal!]! + swaps: [skip]! +} +type vault_call_deregister_tokens @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + pool_id: String! + tokens: [String!]! +} +type vault_call_exit_pool @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + pool_id: String! + recipient: String! + sender: String! +} +type vault_call_flash_loan @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + amounts: [BigDecimal!]! + recipient: String! + tokens: [String!]! + user_data: String! +} +type vault_call_join_pool @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + pool_id: String! + recipient: String! + sender: String! +} +type vault_call_manage_pool_balance @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + ops: [skip]! +} +type vault_call_manage_user_balance @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + ops: [skip]! +} +type vault_call_query_batch_swap @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + assets: [String!]! + kind: Int! + output_param0: [BigDecimal!]! + swaps: [skip]! +} +type vault_call_register_pool @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + output_param0: String! + specialization: Int! +} +type vault_call_register_tokens @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + asset_managers: [String!]! + pool_id: String! + tokens: [String!]! +} +type vault_call_set_authorizer @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + new_authorizer: String! +} +type vault_call_set_paused @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + paused: Boolean! +} +type vault_call_set_relayer_approval @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + approved: Boolean! + relayer: String! + sender: String! +} +type vault_call_swap @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + deadline: BigDecimal! + limit: BigDecimal! + output_amount_calculated: BigDecimal! +} + + +type pools_amp_update_started @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + evt_address: String! + end_time: BigDecimal! + end_value: BigDecimal! + start_time: BigDecimal! + start_value: BigDecimal! +} +type pools_amp_update_stopped @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + evt_address: String! + current_value: BigDecimal! +} +type pools_approval @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + evt_address: String! + owner: String! + spender: String! + value: BigDecimal! +} +type pools_paused_state_changed @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + evt_address: String! + paused: Boolean! +} +type pools_protocol_fee_percentage_cache_updated @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + evt_address: String! + fee_type: BigDecimal! + protocol_fee_percentage: BigDecimal! +} +type pools_recovery_mode_state_changed @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + evt_address: String! + enabled: Boolean! +} +type pools_swap_fee_percentage_changed @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + evt_address: String! + swap_fee_percentage: BigDecimal! +} +type pools_token_rate_cache_updated @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + evt_address: String! + rate: BigDecimal! + token_index: BigDecimal! +} +type pools_token_rate_provider_set @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + evt_address: String! + cache_duration: BigDecimal! + provider: String! + token_index: BigDecimal! +} +type pools_transfer @entity { + id: ID! + evt_tx_hash: String! + evt_index: BigInt! + evt_block_time: String! + evt_block_number: BigInt! + evt_address: String! + from: String! + to: String! + value: BigDecimal! +}type pools_call_approve @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + amount: BigDecimal! + output_param0: Boolean! + spender: String! +} +type pools_call_decrease_allowance @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + amount: BigDecimal! + output_param0: Boolean! + spender: String! +} +type pools_call_disable_recovery_mode @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! +} +type pools_call_enable_recovery_mode @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! +} +type pools_call_increase_allowance @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + added_value: BigDecimal! + output_param0: Boolean! + spender: String! +} +type pools_call_on_exit_pool @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + balances: [BigDecimal!]! + last_change_block: BigDecimal! + output_param0: [BigDecimal!]! + output_param1: [BigDecimal!]! + pool_id: String! + protocol_swap_fee_percentage: BigDecimal! + recipient: String! + sender: String! + user_data: String! +} +type pools_call_on_join_pool @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + balances: [BigDecimal!]! + last_change_block: BigDecimal! + output_param0: [BigDecimal!]! + output_param1: [BigDecimal!]! + pool_id: String! + protocol_swap_fee_percentage: BigDecimal! + recipient: String! + sender: String! + user_data: String! +} +type pools_call_on_swap @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + balances: [BigDecimal!]! + index_in: BigDecimal! + index_out: BigDecimal! + output_param0: BigDecimal! +} +type pools_call_pause @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! +} +type pools_call_permit @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + deadline: BigDecimal! + owner: String! + r: String! + s: String! + spender: String! + v: Int! + value: BigDecimal! +} +type pools_call_query_exit @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + balances: [BigDecimal!]! + last_change_block: BigDecimal! + output_amounts_out: [BigDecimal!]! + output_bpt_in: BigDecimal! + pool_id: String! + protocol_swap_fee_percentage: BigDecimal! + recipient: String! + sender: String! + user_data: String! +} +type pools_call_query_join @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + balances: [BigDecimal!]! + last_change_block: BigDecimal! + output_amounts_in: [BigDecimal!]! + output_bpt_out: BigDecimal! + pool_id: String! + protocol_swap_fee_percentage: BigDecimal! + recipient: String! + sender: String! + user_data: String! +} +type pools_call_set_asset_manager_pool_config @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + pool_config: String! + token: String! +} +type pools_call_set_swap_fee_percentage @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + swap_fee_percentage: BigDecimal! +} +type pools_call_set_token_rate_cache_duration @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + duration: BigDecimal! + token: String! +} +type pools_call_start_amplification_parameter_update @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + end_time: BigDecimal! + raw_end_value: BigDecimal! +} +type pools_call_stop_amplification_parameter_update @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! +} +type pools_call_transfer @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + amount: BigDecimal! + output_param0: Boolean! + recipient: String! +} +type pools_call_transfer_from @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + amount: BigDecimal! + output_param0: Boolean! + recipient: String! + sender: String! +} +type pools_call_unpause @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! +} +type pools_call_update_protocol_fee_percentage_cache @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! +} +type pools_call_update_token_rate_cache @entity { + id: ID! + call_tx_hash: String! + call_block_time: String! + call_block_number: BigInt! + call_ordinal: BigInt! + call_success: Bool! + call_address: String! + token: String! +} + diff --git a/sql/balancer_v2/schema.sql b/sql/balancer_v2/schema.sql new file mode 100644 index 0000000..ea8f7b2 --- /dev/null +++ b/sql/balancer_v2/schema.sql @@ -0,0 +1,641 @@ +CREATE TABLE IF NOT EXISTS vault_authorizer_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "new_authorizer" VARCHAR(40), + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_external_balance_transfer ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "amount" DECIMAL, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + "token" VARCHAR(40), + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_flash_loan ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "amount" DECIMAL, + "fee_amount" DECIMAL, + "recipient" VARCHAR(40), + "token" VARCHAR(40), + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_internal_balance_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "delta" DECIMAL, + "token" VARCHAR(40), + "user" VARCHAR(40), + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_paused_state_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "paused" BOOL, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_pool_balance_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "deltas" DECIMAL[], + "liquidity_provider" VARCHAR(40), + "pool_id" TEXT, + "protocol_fee_amounts" DECIMAL[], + "tokens" VARCHAR(40)[], + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_pool_balance_managed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "asset_manager" VARCHAR(40), + "cash_delta" DECIMAL, + "managed_delta" DECIMAL, + "pool_id" TEXT, + "token" VARCHAR(40), + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_pool_registered ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "pool_address" VARCHAR(40), + "pool_id" TEXT, + "specialization" INT, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_relayer_approval_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "approved" BOOL, + "relayer" VARCHAR(40), + "sender" VARCHAR(40), + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_swap ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "amount_in" DECIMAL, + "amount_out" DECIMAL, + "pool_id" TEXT, + "token_in" VARCHAR(40), + "token_out" VARCHAR(40), + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_tokens_deregistered ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "pool_id" TEXT, + "tokens" VARCHAR(40)[], + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_tokens_registered ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "asset_managers" VARCHAR(40)[], + "pool_id" TEXT, + "tokens" VARCHAR(40)[], + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS vault_call_batch_swap ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "assets" VARCHAR(40)[], + "deadline" DECIMAL, + "kind" INT, + "limits" DECIMAL[], + "output_asset_deltas" DECIMAL[], + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_deregister_tokens ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "pool_id" TEXT, + "tokens" VARCHAR(40)[], + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_exit_pool ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "pool_id" TEXT, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_flash_loan ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "amounts" DECIMAL[], + "recipient" VARCHAR(40), + "tokens" VARCHAR(40)[], + "user_data" TEXT, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_join_pool ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "pool_id" TEXT, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_manage_pool_balance ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_manage_user_balance ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_query_batch_swap ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "assets" VARCHAR(40)[], + "kind" INT, + "output_param0" DECIMAL[], + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_register_pool ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "output_param0" TEXT, + "specialization" INT, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_register_tokens ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "asset_managers" VARCHAR(40)[], + "pool_id" TEXT, + "tokens" VARCHAR(40)[], + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_set_authorizer ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "new_authorizer" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_set_paused ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "paused" BOOL, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_set_relayer_approval ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "approved" BOOL, + "relayer" VARCHAR(40), + "sender" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS vault_call_swap ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "deadline" DECIMAL, + "limit" DECIMAL, + "output_amount_calculated" DECIMAL, + PRIMARY KEY(call_tx_hash,call_ordinal) +); + + +CREATE TABLE IF NOT EXISTS pools_amp_update_started ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "evt_address" VARCHAR(40), + "end_time" DECIMAL, + "end_value" DECIMAL, + "start_time" DECIMAL, + "start_value" DECIMAL, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS pools_amp_update_stopped ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "evt_address" VARCHAR(40), + "current_value" DECIMAL, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS pools_approval ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "evt_address" VARCHAR(40), + "owner" VARCHAR(40), + "spender" VARCHAR(40), + "value" DECIMAL, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS pools_paused_state_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "evt_address" VARCHAR(40), + "paused" BOOL, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS pools_protocol_fee_percentage_cache_updated ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "evt_address" VARCHAR(40), + "fee_type" DECIMAL, + "protocol_fee_percentage" DECIMAL, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS pools_recovery_mode_state_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "evt_address" VARCHAR(40), + "enabled" BOOL, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS pools_swap_fee_percentage_changed ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "evt_address" VARCHAR(40), + "swap_fee_percentage" DECIMAL, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS pools_token_rate_cache_updated ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "evt_address" VARCHAR(40), + "rate" DECIMAL, + "token_index" DECIMAL, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS pools_token_rate_provider_set ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "evt_address" VARCHAR(40), + "cache_duration" DECIMAL, + "provider" VARCHAR(40), + "token_index" DECIMAL, + PRIMARY KEY(evt_tx_hash,evt_index) +); +CREATE TABLE IF NOT EXISTS pools_transfer ( + "evt_tx_hash" VARCHAR(64), + "evt_index" INT, + "evt_block_time" TIMESTAMP, + "evt_block_number" DECIMAL, + "evt_address" VARCHAR(40), + "from" VARCHAR(40), + "to" VARCHAR(40), + "value" DECIMAL, + PRIMARY KEY(evt_tx_hash,evt_index) +);CREATE TABLE IF NOT EXISTS pools_call_approve ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "amount" DECIMAL, + "output_param0" BOOL, + "spender" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_decrease_allowance ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "amount" DECIMAL, + "output_param0" BOOL, + "spender" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_disable_recovery_mode ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_enable_recovery_mode ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_increase_allowance ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "added_value" DECIMAL, + "output_param0" BOOL, + "spender" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_on_exit_pool ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "balances" DECIMAL[], + "last_change_block" DECIMAL, + "output_param0" DECIMAL[], + "output_param1" DECIMAL[], + "pool_id" TEXT, + "protocol_swap_fee_percentage" DECIMAL, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + "user_data" TEXT, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_on_join_pool ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "balances" DECIMAL[], + "last_change_block" DECIMAL, + "output_param0" DECIMAL[], + "output_param1" DECIMAL[], + "pool_id" TEXT, + "protocol_swap_fee_percentage" DECIMAL, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + "user_data" TEXT, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_on_swap ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "balances" DECIMAL[], + "index_in" DECIMAL, + "index_out" DECIMAL, + "output_param0" DECIMAL, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_pause ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_permit ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "deadline" DECIMAL, + "owner" VARCHAR(40), + "r" TEXT, + "s" TEXT, + "spender" VARCHAR(40), + "v" INT, + "value" DECIMAL, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_query_exit ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "balances" DECIMAL[], + "last_change_block" DECIMAL, + "output_amounts_out" DECIMAL[], + "output_bpt_in" DECIMAL, + "pool_id" TEXT, + "protocol_swap_fee_percentage" DECIMAL, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + "user_data" TEXT, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_query_join ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "balances" DECIMAL[], + "last_change_block" DECIMAL, + "output_amounts_in" DECIMAL[], + "output_bpt_out" DECIMAL, + "pool_id" TEXT, + "protocol_swap_fee_percentage" DECIMAL, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + "user_data" TEXT, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_set_asset_manager_pool_config ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "pool_config" TEXT, + "token" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_set_swap_fee_percentage ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "swap_fee_percentage" DECIMAL, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_set_token_rate_cache_duration ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "duration" DECIMAL, + "token" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_start_amplification_parameter_update ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "end_time" DECIMAL, + "raw_end_value" DECIMAL, + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_stop_amplification_parameter_update ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_transfer ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "amount" DECIMAL, + "output_param0" BOOL, + "recipient" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_transfer_from ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "amount" DECIMAL, + "output_param0" BOOL, + "recipient" VARCHAR(40), + "sender" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_unpause ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_update_protocol_fee_percentage_cache ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); +CREATE TABLE IF NOT EXISTS pools_call_update_token_rate_cache ( + "call_tx_hash" VARCHAR(64), + "call_block_time" TIMESTAMP, + "call_block_number" DECIMAL, + "call_ordinal" INT, + "call_success" BOOL, + "call_address" VARCHAR(40), + "token" VARCHAR(40), + PRIMARY KEY(call_tx_hash,call_ordinal) +); + + diff --git a/sql/balancer_v2/src/abi/mod.rs b/sql/balancer_v2/src/abi/mod.rs new file mode 100644 index 0000000..5195e50 --- /dev/null +++ b/sql/balancer_v2/src/abi/mod.rs @@ -0,0 +1,3 @@ + +pub mod vault_contract; +pub mod pools_contract; \ No newline at end of file diff --git a/sql/balancer_v2/src/abi/pools_contract.rs b/sql/balancer_v2/src/abi/pools_contract.rs new file mode 100644 index 0000000..709e07f --- /dev/null +++ b/sql/balancer_v2/src/abi/pools_contract.rs @@ -0,0 +1,7546 @@ + const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error"; + /// Contract's functions. + #[allow(dead_code, unused_imports, unused_variables)] + pub mod functions { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct DelegateProtocolSwapFeesSentinel {} + impl DelegateProtocolSwapFeesSentinel { + const METHOD_ID: [u8; 4] = [221u8, 244u8, 98u8, 123u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for DelegateProtocolSwapFeesSentinel { + const NAME: &'static str = "DELEGATE_PROTOCOL_SWAP_FEES_SENTINEL"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for DelegateProtocolSwapFeesSentinel { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DomainSeparator {} + impl DomainSeparator { + const METHOD_ID: [u8; 4] = [54u8, 68u8, 229u8, 21u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for DomainSeparator { + const NAME: &'static str = "DOMAIN_SEPARATOR"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for DomainSeparator { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Allowance { + pub owner: Vec, + pub spender: Vec, + } + impl Allowance { + const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.spender), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Allowance { + const NAME: &'static str = "allowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Allowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approve { + pub spender: Vec, + pub amount: substreams::scalar::BigInt, + } + impl Approve { + const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.spender), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Approve { + const NAME: &'static str = "approve"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Approve { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BalanceOf { + pub account: Vec, + } + impl BalanceOf { + const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.account))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for BalanceOf { + const NAME: &'static str = "balanceOf"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for BalanceOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Decimals {} + impl Decimals { + const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(8usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Decimals { + const NAME: &'static str = "decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Decimals { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DecreaseAllowance { + pub spender: Vec, + pub amount: substreams::scalar::BigInt, + } + impl DecreaseAllowance { + const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.spender), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for DecreaseAllowance { + const NAME: &'static str = "decreaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DisableRecoveryMode {} + impl DisableRecoveryMode { + const METHOD_ID: [u8; 4] = [183u8, 184u8, 20u8, 252u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for DisableRecoveryMode { + const NAME: &'static str = "disableRecoveryMode"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct EnableRecoveryMode {} + impl EnableRecoveryMode { + const METHOD_ID: [u8; 4] = [84u8, 168u8, 68u8, 186u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for EnableRecoveryMode { + const NAME: &'static str = "enableRecoveryMode"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetActionId { + pub selector: [u8; 4usize], + } + impl GetActionId { + const METHOD_ID: [u8; 4] = [133u8, 28u8, 27u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(4usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + selector: { + let mut result = [0u8; 4]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::FixedBytes(self.selector.as_ref().to_vec())], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetActionId { + const NAME: &'static str = "getActionId"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for GetActionId { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetActualSupply {} + impl GetActualSupply { + const METHOD_ID: [u8; 4] = [135u8, 111u8, 48u8, 59u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetActualSupply { + const NAME: &'static str = "getActualSupply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetActualSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAmplificationParameter {} + impl GetAmplificationParameter { + const METHOD_ID: [u8; 4] = [109u8, 172u8, 207u8, 250u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + (substreams::scalar::BigInt, bool, substreams::scalar::BigInt), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + (substreams::scalar::BigInt, bool, substreams::scalar::BigInt), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + values.pop().expect(INTERNAL_ERR).into_bool().expect(INTERNAL_ERR), + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option<(substreams::scalar::BigInt, bool, substreams::scalar::BigInt)> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetAmplificationParameter { + const NAME: &'static str = "getAmplificationParameter"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (substreams::scalar::BigInt, bool, substreams::scalar::BigInt), + > for GetAmplificationParameter { + fn output( + data: &[u8], + ) -> Result< + (substreams::scalar::BigInt, bool, substreams::scalar::BigInt), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAuthorizer {} + impl GetAuthorizer { + const METHOD_ID: [u8; 4] = [170u8, 171u8, 173u8, 197u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetAuthorizer { + const NAME: &'static str = "getAuthorizer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GetAuthorizer { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBptIndex {} + impl GetBptIndex { + const METHOD_ID: [u8; 4] = [130u8, 104u8, 122u8, 86u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetBptIndex { + const NAME: &'static str = "getBptIndex"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetBptIndex { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDomainSeparator {} + impl GetDomainSeparator { + const METHOD_ID: [u8; 4] = [237u8, 36u8, 145u8, 29u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetDomainSeparator { + const NAME: &'static str = "getDomainSeparator"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> + for GetDomainSeparator { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLastJoinExitData {} + impl GetLastJoinExitData { + const METHOD_ID: [u8; 4] = [60u8, 151u8, 93u8, 81u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + (substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + (substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt)> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetLastJoinExitData { + const NAME: &'static str = "getLastJoinExitData"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (substreams::scalar::BigInt, substreams::scalar::BigInt), + > for GetLastJoinExitData { + fn output( + data: &[u8], + ) -> Result< + (substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMinimumBpt {} + impl GetMinimumBpt { + const METHOD_ID: [u8; 4] = [4u8, 132u8, 45u8, 76u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetMinimumBpt { + const NAME: &'static str = "getMinimumBpt"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetMinimumBpt { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNextNonce { + pub account: Vec, + } + impl GetNextNonce { + const METHOD_ID: [u8; 4] = [144u8, 25u8, 59u8, 124u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.account))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetNextNonce { + const NAME: &'static str = "getNextNonce"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetNextNonce { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetOwner {} + impl GetOwner { + const METHOD_ID: [u8; 4] = [137u8, 61u8, 32u8, 232u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetOwner { + const NAME: &'static str = "getOwner"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GetOwner { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPausedState {} + impl GetPausedState { + const METHOD_ID: [u8; 4] = [28u8, 13u8, 224u8, 81u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + (bool, substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + (bool, substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Bool, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + values.pop().expect(INTERNAL_ERR).into_bool().expect(INTERNAL_ERR), + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option<(bool, substreams::scalar::BigInt, substreams::scalar::BigInt)> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetPausedState { + const NAME: &'static str = "getPausedState"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (bool, substreams::scalar::BigInt, substreams::scalar::BigInt), + > for GetPausedState { + fn output( + data: &[u8], + ) -> Result< + (bool, substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolId {} + impl GetPoolId { + const METHOD_ID: [u8; 4] = [56u8, 255u8, 242u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetPoolId { + const NAME: &'static str = "getPoolId"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for GetPoolId { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeePercentageCache { + pub fee_type: substreams::scalar::BigInt, + } + impl GetProtocolFeePercentageCache { + const METHOD_ID: [u8; 4] = [112u8, 70u8, 64u8, 22u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + fee_type: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.fee_type.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetProtocolFeePercentageCache { + const NAME: &'static str = "getProtocolFeePercentageCache"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetProtocolFeePercentageCache { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeesCollector {} + impl GetProtocolFeesCollector { + const METHOD_ID: [u8; 4] = [210u8, 148u8, 108u8, 43u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetProtocolFeesCollector { + const NAME: &'static str = "getProtocolFeesCollector"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> + for GetProtocolFeesCollector { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolSwapFeeDelegation {} + impl GetProtocolSwapFeeDelegation { + const METHOD_ID: [u8; 4] = [21u8, 176u8, 1u8, 91u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetProtocolSwapFeeDelegation { + const NAME: &'static str = "getProtocolSwapFeeDelegation"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetProtocolSwapFeeDelegation { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRate {} + impl GetRate { + const METHOD_ID: [u8; 4] = [103u8, 154u8, 239u8, 206u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetRate { + const NAME: &'static str = "getRate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetRate { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRateProviders {} + impl GetRateProviders { + const METHOD_ID: [u8; 4] = [35u8, 138u8, 45u8, 89u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result>, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result>, String> { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option>> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetRateProviders { + const NAME: &'static str = "getRateProviders"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable>> for GetRateProviders { + fn output(data: &[u8]) -> Result>, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetScalingFactors {} + impl GetScalingFactors { + const METHOD_ID: [u8; 4] = [29u8, 215u8, 70u8, 234u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result, String> { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetScalingFactors { + const NAME: &'static str = "getScalingFactors"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> + for GetScalingFactors { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetSwapFeePercentage {} + impl GetSwapFeePercentage { + const METHOD_ID: [u8; 4] = [85u8, 198u8, 118u8, 40u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetSwapFeePercentage { + const NAME: &'static str = "getSwapFeePercentage"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetSwapFeePercentage { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetTokenRate { + pub token: Vec, + } + impl GetTokenRate { + const METHOD_ID: [u8; 4] = [84u8, 222u8, 160u8, 10u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.token))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetTokenRate { + const NAME: &'static str = "getTokenRate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetTokenRate { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetTokenRateCache { + pub token: Vec, + } + impl GetTokenRateCache { + const METHOD_ID: [u8; 4] = [127u8, 18u8, 96u8, 209u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.token))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetTokenRateCache { + const NAME: &'static str = "getTokenRateCache"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > for GetTokenRateCache { + fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetVault {} + impl GetVault { + const METHOD_ID: [u8; 4] = [141u8, 146u8, 138u8, 248u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetVault { + const NAME: &'static str = "getVault"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GetVault { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InRecoveryMode {} + impl InRecoveryMode { + const METHOD_ID: [u8; 4] = [179u8, 80u8, 86u8, 184u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for InRecoveryMode { + const NAME: &'static str = "inRecoveryMode"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for InRecoveryMode { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IncreaseAllowance { + pub spender: Vec, + pub added_value: substreams::scalar::BigInt, + } + impl IncreaseAllowance { + const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + added_value: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.spender), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.added_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for IncreaseAllowance { + const NAME: &'static str = "increaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsExemptFromYieldProtocolFee {} + impl IsExemptFromYieldProtocolFee { + const METHOD_ID: [u8; 4] = [119u8, 21u8, 27u8, 238u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for IsExemptFromYieldProtocolFee { + const NAME: &'static str = "isExemptFromYieldProtocolFee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IsExemptFromYieldProtocolFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsTokenExemptFromYieldProtocolFee { + pub token: Vec, + } + impl IsTokenExemptFromYieldProtocolFee { + const METHOD_ID: [u8; 4] = [171u8, 119u8, 89u8, 241u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.token))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for IsTokenExemptFromYieldProtocolFee { + const NAME: &'static str = "isTokenExemptFromYieldProtocolFee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IsTokenExemptFromYieldProtocolFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Name {} + impl Name { + const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::String], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Name { + const NAME: &'static str = "name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Name { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Nonces { + pub owner: Vec, + } + impl Nonces { + const METHOD_ID: [u8; 4] = [126u8, 206u8, 190u8, 0u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.owner))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Nonces { + const NAME: &'static str = "nonces"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Nonces { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OnExitPool { + pub pool_id: [u8; 32usize], + pub sender: Vec, + pub recipient: Vec, + pub balances: Vec, + pub last_change_block: substreams::scalar::BigInt, + pub protocol_swap_fee_percentage: substreams::scalar::BigInt, + pub user_data: Vec, + } + impl OnExitPool { + const METHOD_ID: [u8; 4] = [116u8, 243u8, 176u8, 9u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bytes, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + sender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + balances: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + last_change_block: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + protocol_swap_fee_percentage: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + user_data: values + .pop() + .expect(INTERNAL_ERR) + .into_bytes() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec()), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.sender), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.recipient), + ), + { + let v = self + .balances + .iter() + .map(|inner| ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match inner.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + )) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.last_change_block.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self + .protocol_swap_fee_percentage + .clone() + .to_bytes_be() + { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bytes(self.user_data.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + (Vec, Vec), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + (Vec, Vec), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option< + (Vec, Vec), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for OnExitPool { + const NAME: &'static str = "onExitPool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (Vec, Vec), + > for OnExitPool { + fn output( + data: &[u8], + ) -> Result< + (Vec, Vec), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OnJoinPool { + pub pool_id: [u8; 32usize], + pub sender: Vec, + pub recipient: Vec, + pub balances: Vec, + pub last_change_block: substreams::scalar::BigInt, + pub protocol_swap_fee_percentage: substreams::scalar::BigInt, + pub user_data: Vec, + } + impl OnJoinPool { + const METHOD_ID: [u8; 4] = [213u8, 192u8, 150u8, 196u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bytes, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + sender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + balances: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + last_change_block: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + protocol_swap_fee_percentage: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + user_data: values + .pop() + .expect(INTERNAL_ERR) + .into_bytes() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec()), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.sender), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.recipient), + ), + { + let v = self + .balances + .iter() + .map(|inner| ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match inner.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + )) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.last_change_block.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self + .protocol_swap_fee_percentage + .clone() + .to_bytes_be() + { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bytes(self.user_data.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + (Vec, Vec), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + (Vec, Vec), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option< + (Vec, Vec), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for OnJoinPool { + const NAME: &'static str = "onJoinPool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (Vec, Vec), + > for OnJoinPool { + fn output( + data: &[u8], + ) -> Result< + (Vec, Vec), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OnSwap { + pub swap_request: ( + substreams::scalar::BigInt, + Vec, + Vec, + substreams::scalar::BigInt, + [u8; 32usize], + substreams::scalar::BigInt, + Vec, + Vec, + Vec, + ), + pub balances: Vec, + pub index_in: substreams::scalar::BigInt, + pub index_out: substreams::scalar::BigInt, + } + impl OnSwap { + const METHOD_ID: [u8; 4] = [1u8, 236u8, 149u8, 74u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::Uint(8usize), ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, ethabi::ParamType::Address, + ethabi::ParamType::Bytes + ], + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + swap_request: { + let tuple_elements = values + .pop() + .expect(INTERNAL_ERR) + .into_tuple() + .expect(INTERNAL_ERR); + ( + { + let mut v = [0 as u8; 32]; + tuple_elements[0usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tuple_elements[1usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[2usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + { + let mut v = [0 as u8; 32]; + tuple_elements[3usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut result = [0u8; 32]; + let v = tuple_elements[4usize] + .clone() + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + { + let mut v = [0 as u8; 32]; + tuple_elements[5usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tuple_elements[6usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[7usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[8usize] + .clone() + .into_bytes() + .expect(INTERNAL_ERR), + ) + }, + balances: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + index_in: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + index_out: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Tuple( + vec![ + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self + .swap_request.0.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), + ethabi::Token::Address(ethabi::Address::from_slice(& self + .swap_request.1)), + ethabi::Token::Address(ethabi::Address::from_slice(& self + .swap_request.2)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self + .swap_request.3.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), ethabi::Token::FixedBytes(self.swap_request + .4.as_ref().to_vec()), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self + .swap_request.5.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), + ethabi::Token::Address(ethabi::Address::from_slice(& self + .swap_request.6)), + ethabi::Token::Address(ethabi::Address::from_slice(& self + .swap_request.7)), ethabi::Token::Bytes(self.swap_request.8 + .clone()) + ], + ), + { + let v = self + .balances + .iter() + .map(|inner| ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match inner.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + )) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.index_in.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.index_out.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for OnSwap { + const NAME: &'static str = "onSwap"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for OnSwap { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Pause {} + impl Pause { + const METHOD_ID: [u8; 4] = [132u8, 86u8, 203u8, 89u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for Pause { + const NAME: &'static str = "pause"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Permit { + pub owner: Vec, + pub spender: Vec, + pub value: substreams::scalar::BigInt, + pub deadline: substreams::scalar::BigInt, + pub v: substreams::scalar::BigInt, + pub r: [u8; 32usize], + pub s: [u8; 32usize], + } + impl Permit { + const METHOD_ID: [u8; 4] = [213u8, 5u8, 172u8, 207u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(8usize), + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::FixedBytes(32usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + deadline: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + v: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + r: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + s: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.spender), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.deadline.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.v.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::FixedBytes(self.r.as_ref().to_vec()), + ethabi::Token::FixedBytes(self.s.as_ref().to_vec()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for Permit { + const NAME: &'static str = "permit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct QueryExit { + pub pool_id: [u8; 32usize], + pub sender: Vec, + pub recipient: Vec, + pub balances: Vec, + pub last_change_block: substreams::scalar::BigInt, + pub protocol_swap_fee_percentage: substreams::scalar::BigInt, + pub user_data: Vec, + } + impl QueryExit { + const METHOD_ID: [u8; 4] = [96u8, 40u8, 191u8, 212u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bytes, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + sender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + balances: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + last_change_block: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + protocol_swap_fee_percentage: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + user_data: values + .pop() + .expect(INTERNAL_ERR) + .into_bytes() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec()), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.sender), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.recipient), + ), + { + let v = self + .balances + .iter() + .map(|inner| ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match inner.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + )) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.last_change_block.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self + .protocol_swap_fee_percentage + .clone() + .to_bytes_be() + { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bytes(self.user_data.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + (substreams::scalar::BigInt, Vec), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + (substreams::scalar::BigInt, Vec), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option<(substreams::scalar::BigInt, Vec)> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for QueryExit { + const NAME: &'static str = "queryExit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (substreams::scalar::BigInt, Vec), + > for QueryExit { + fn output( + data: &[u8], + ) -> Result< + (substreams::scalar::BigInt, Vec), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct QueryJoin { + pub pool_id: [u8; 32usize], + pub sender: Vec, + pub recipient: Vec, + pub balances: Vec, + pub last_change_block: substreams::scalar::BigInt, + pub protocol_swap_fee_percentage: substreams::scalar::BigInt, + pub user_data: Vec, + } + impl QueryJoin { + const METHOD_ID: [u8; 4] = [135u8, 236u8, 104u8, 23u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bytes, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + sender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + balances: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + last_change_block: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + protocol_swap_fee_percentage: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + user_data: values + .pop() + .expect(INTERNAL_ERR) + .into_bytes() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec()), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.sender), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.recipient), + ), + { + let v = self + .balances + .iter() + .map(|inner| ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match inner.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + )) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.last_change_block.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self + .protocol_swap_fee_percentage + .clone() + .to_bytes_be() + { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bytes(self.user_data.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + (substreams::scalar::BigInt, Vec), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + (substreams::scalar::BigInt, Vec), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option<(substreams::scalar::BigInt, Vec)> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for QueryJoin { + const NAME: &'static str = "queryJoin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (substreams::scalar::BigInt, Vec), + > for QueryJoin { + fn output( + data: &[u8], + ) -> Result< + (substreams::scalar::BigInt, Vec), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetAssetManagerPoolConfig { + pub token: Vec, + pub pool_config: Vec, + } + impl SetAssetManagerPoolConfig { + const METHOD_ID: [u8; 4] = [80u8, 221u8, 110u8, 217u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Bytes], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + pool_config: values + .pop() + .expect(INTERNAL_ERR) + .into_bytes() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.token)), + ethabi::Token::Bytes(self.pool_config.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for SetAssetManagerPoolConfig { + const NAME: &'static str = "setAssetManagerPoolConfig"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetSwapFeePercentage { + pub swap_fee_percentage: substreams::scalar::BigInt, + } + impl SetSwapFeePercentage { + const METHOD_ID: [u8; 4] = [56u8, 233u8, 146u8, 46u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + swap_fee_percentage: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.swap_fee_percentage.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for SetSwapFeePercentage { + const NAME: &'static str = "setSwapFeePercentage"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetTokenRateCacheDuration { + pub token: Vec, + pub duration: substreams::scalar::BigInt, + } + impl SetTokenRateCacheDuration { + const METHOD_ID: [u8; 4] = [244u8, 183u8, 150u8, 77u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + duration: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.token)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.duration.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for SetTokenRateCacheDuration { + const NAME: &'static str = "setTokenRateCacheDuration"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct StartAmplificationParameterUpdate { + pub raw_end_value: substreams::scalar::BigInt, + pub end_time: substreams::scalar::BigInt, + } + impl StartAmplificationParameterUpdate { + const METHOD_ID: [u8; 4] = [47u8, 26u8, 11u8, 201u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + raw_end_value: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + end_time: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.raw_end_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.end_time.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for StartAmplificationParameterUpdate { + const NAME: &'static str = "startAmplificationParameterUpdate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct StopAmplificationParameterUpdate {} + impl StopAmplificationParameterUpdate { + const METHOD_ID: [u8; 4] = [235u8, 15u8, 36u8, 214u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for StopAmplificationParameterUpdate { + const NAME: &'static str = "stopAmplificationParameterUpdate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Symbol {} + impl Symbol { + const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::String], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Symbol { + const NAME: &'static str = "symbol"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Symbol { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TotalSupply {} + impl TotalSupply { + const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for TotalSupply { + const NAME: &'static str = "totalSupply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub recipient: Vec, + pub amount: substreams::scalar::BigInt, + } + impl Transfer { + const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.recipient), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Transfer { + const NAME: &'static str = "transfer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Transfer { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferFrom { + pub sender: Vec, + pub recipient: Vec, + pub amount: substreams::scalar::BigInt, + } + impl TransferFrom { + const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + sender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.sender), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.recipient), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for TransferFrom { + const NAME: &'static str = "transferFrom"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Unpause {} + impl Unpause { + const METHOD_ID: [u8; 4] = [63u8, 75u8, 168u8, 58u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for Unpause { + const NAME: &'static str = "unpause"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateProtocolFeePercentageCache {} + impl UpdateProtocolFeePercentageCache { + const METHOD_ID: [u8; 4] = [13u8, 160u8, 102u8, 156u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for UpdateProtocolFeePercentageCache { + const NAME: &'static str = "updateProtocolFeePercentageCache"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateTokenRateCache { + pub token: Vec, + } + impl UpdateTokenRateCache { + const METHOD_ID: [u8; 4] = [45u8, 242u8, 199u8, 192u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.token))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for UpdateTokenRateCache { + const NAME: &'static str = "updateTokenRateCache"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Version {} + impl Version { + const METHOD_ID: [u8; 4] = [84u8, 253u8, 77u8, 80u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::String], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Version { + const NAME: &'static str = "version"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Version { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + } + /// Contract's events. + #[allow(dead_code, unused_imports, unused_variables)] + pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct AmpUpdateStarted { + pub start_value: substreams::scalar::BigInt, + pub end_value: substreams::scalar::BigInt, + pub start_time: substreams::scalar::BigInt, + pub end_time: substreams::scalar::BigInt, + } + impl AmpUpdateStarted { + const TOPIC_ID: [u8; 32] = [ + 24u8, + 53u8, + 136u8, + 46u8, + 231u8, + 163u8, + 74u8, + 193u8, + 148u8, + 247u8, + 23u8, + 163u8, + 94u8, + 9u8, + 187u8, + 29u8, + 36u8, + 200u8, + 42u8, + 59u8, + 157u8, + 133u8, + 74u8, + 182u8, + 201u8, + 116u8, + 149u8, + 37u8, + 183u8, + 20u8, + 205u8, + 242u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 128usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + start_value: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + end_value: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + start_time: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + end_time: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for AmpUpdateStarted { + const NAME: &'static str = "AmpUpdateStarted"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AmpUpdateStopped { + pub current_value: substreams::scalar::BigInt, + } + impl AmpUpdateStopped { + const TOPIC_ID: [u8; 32] = [ + 160u8, + 208u8, + 21u8, + 147u8, + 228u8, + 126u8, + 105u8, + 208u8, + 126u8, + 12u8, + 205u8, + 135u8, + 190u8, + 206u8, + 9u8, + 65u8, + 30u8, + 7u8, + 221u8, + 30u8, + 212u8, + 12u8, + 168u8, + 242u8, + 231u8, + 175u8, + 41u8, + 118u8, + 84u8, + 42u8, + 2u8, + 51u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + current_value: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for AmpUpdateStopped { + const NAME: &'static str = "AmpUpdateStopped"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approval { + pub owner: Vec, + pub spender: Vec, + pub value: substreams::scalar::BigInt, + } + impl Approval { + const TOPIC_ID: [u8; 32] = [ + 140u8, + 91u8, + 225u8, + 229u8, + 235u8, + 236u8, + 125u8, + 91u8, + 209u8, + 79u8, + 113u8, + 66u8, + 125u8, + 30u8, + 132u8, + 243u8, + 221u8, + 3u8, + 20u8, + 192u8, + 247u8, + 178u8, + 41u8, + 30u8, + 91u8, + 32u8, + 10u8, + 200u8, + 199u8, + 195u8, + 185u8, + 37u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + owner: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'owner' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + spender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'spender' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Approval { + const NAME: &'static str = "Approval"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PausedStateChanged { + pub paused: bool, + } + impl PausedStateChanged { + const TOPIC_ID: [u8; 32] = [ + 158u8, + 58u8, + 94u8, + 55u8, + 34u8, + 69u8, + 50u8, + 222u8, + 166u8, + 123u8, + 137u8, + 250u8, + 206u8, + 24u8, + 87u8, + 3u8, + 115u8, + 138u8, + 34u8, + 138u8, + 110u8, + 138u8, + 35u8, + 222u8, + 229u8, + 70u8, + 150u8, + 1u8, + 128u8, + 211u8, + 190u8, + 100u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + paused: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + } + impl substreams_ethereum::Event for PausedStateChanged { + const NAME: &'static str = "PausedStateChanged"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ProtocolFeePercentageCacheUpdated { + pub fee_type: substreams::scalar::BigInt, + pub protocol_fee_percentage: substreams::scalar::BigInt, + } + impl ProtocolFeePercentageCacheUpdated { + const TOPIC_ID: [u8; 32] = [ + 107u8, + 251u8, + 104u8, + 149u8, + 40u8, + 250u8, + 150u8, + 236u8, + 26u8, + 214u8, + 112u8, + 173u8, + 109u8, + 96u8, + 100u8, + 190u8, + 26u8, + 233u8, + 107u8, + 253u8, + 93u8, + 46u8, + 227u8, + 92u8, + 131u8, + 127u8, + 208u8, + 254u8, + 12u8, + 17u8, + 149u8, + 154u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + fee_type: { + let mut v = [0 as u8; 32]; + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'fee_type' from topic of type 'uint256': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + protocol_fee_percentage: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for ProtocolFeePercentageCacheUpdated { + const NAME: &'static str = "ProtocolFeePercentageCacheUpdated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RecoveryModeStateChanged { + pub enabled: bool, + } + impl RecoveryModeStateChanged { + const TOPIC_ID: [u8; 32] = [ + 239u8, + 243u8, + 212u8, + 210u8, + 21u8, + 180u8, + 43u8, + 240u8, + 150u8, + 11u8, + 233u8, + 198u8, + 213u8, + 224u8, + 92u8, + 34u8, + 203u8, + 164u8, + 223u8, + 102u8, + 39u8, + 163u8, + 165u8, + 35u8, + 226u8, + 172u8, + 238u8, + 115u8, + 59u8, + 88u8, + 84u8, + 200u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + enabled: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + } + impl substreams_ethereum::Event for RecoveryModeStateChanged { + const NAME: &'static str = "RecoveryModeStateChanged"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SwapFeePercentageChanged { + pub swap_fee_percentage: substreams::scalar::BigInt, + } + impl SwapFeePercentageChanged { + const TOPIC_ID: [u8; 32] = [ + 169u8, + 186u8, + 63u8, + 254u8, + 11u8, + 108u8, + 54u8, + 107u8, + 129u8, + 35u8, + 44u8, + 170u8, + 179u8, + 134u8, + 5u8, + 160u8, + 105u8, + 154u8, + 213u8, + 57u8, + 141u8, + 108u8, + 206u8, + 118u8, + 249u8, + 30u8, + 232u8, + 9u8, + 227u8, + 34u8, + 218u8, + 252u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + swap_fee_percentage: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for SwapFeePercentageChanged { + const NAME: &'static str = "SwapFeePercentageChanged"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TokenRateCacheUpdated { + pub token_index: substreams::scalar::BigInt, + pub rate: substreams::scalar::BigInt, + } + impl TokenRateCacheUpdated { + const TOPIC_ID: [u8; 32] = [ + 183u8, + 122u8, + 131u8, + 32u8, + 76u8, + 162u8, + 130u8, + 224u8, + 141u8, + 195u8, + 166u8, + 91u8, + 10u8, + 28u8, + 163u8, + 46u8, + 164u8, + 230u8, + 135u8, + 92u8, + 56u8, + 239u8, + 11u8, + 245u8, + 191u8, + 117u8, + 229u8, + 42u8, + 103u8, + 53u8, + 79u8, + 172u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + token_index: { + let mut v = [0 as u8; 32]; + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'token_index' from topic of type 'uint256': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + rate: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for TokenRateCacheUpdated { + const NAME: &'static str = "TokenRateCacheUpdated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TokenRateProviderSet { + pub token_index: substreams::scalar::BigInt, + pub provider: Vec, + pub cache_duration: substreams::scalar::BigInt, + } + impl TokenRateProviderSet { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 109u8, + 28u8, + 155u8, + 173u8, + 179u8, + 70u8, + 222u8, + 105u8, + 37u8, + 179u8, + 88u8, + 164u8, + 114u8, + 201u8, + 55u8, + 180u8, + 22u8, + 152u8, + 210u8, + 99u8, + 38u8, + 150u8, + 117u8, + 158u8, + 67u8, + 253u8, + 101u8, + 39u8, + 254u8, + 238u8, + 196u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + token_index: { + let mut v = [0 as u8; 32]; + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'token_index' from topic of type 'uint256': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + cache_duration: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for TokenRateProviderSet { + const NAME: &'static str = "TokenRateProviderSet"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub from: Vec, + pub to: Vec, + pub value: substreams::scalar::BigInt, + } + impl Transfer { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 242u8, + 82u8, + 173u8, + 27u8, + 226u8, + 200u8, + 155u8, + 105u8, + 194u8, + 176u8, + 104u8, + 252u8, + 55u8, + 141u8, + 170u8, + 149u8, + 43u8, + 167u8, + 241u8, + 99u8, + 196u8, + 161u8, + 22u8, + 40u8, + 245u8, + 90u8, + 77u8, + 245u8, + 35u8, + 179u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + from: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'from' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'to' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Transfer { + const NAME: &'static str = "Transfer"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + } \ No newline at end of file diff --git a/sql/balancer_v2/src/abi/vault_contract.rs b/sql/balancer_v2/src/abi/vault_contract.rs new file mode 100644 index 0000000..ec00beb --- /dev/null +++ b/sql/balancer_v2/src/abi/vault_contract.rs @@ -0,0 +1,5268 @@ + const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error"; + /// Contract's functions. + #[allow(dead_code, unused_imports, unused_variables)] + pub mod functions { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct Weth {} + impl Weth { + const METHOD_ID: [u8; 4] = [173u8, 92u8, 70u8, 72u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Weth { + const NAME: &'static str = "WETH"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Weth { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BatchSwap { + pub kind: substreams::scalar::BigInt, + pub swaps: Vec< + ( + [u8; 32usize], + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + ), + >, + pub assets: Vec>, + pub funds: (Vec, bool, Vec, bool), + pub limits: Vec, + pub deadline: substreams::scalar::BigInt, + } + impl BatchSwap { + const METHOD_ID: [u8; 4] = [148u8, 91u8, 206u8, 201u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(8usize), + ethabi::ParamType::Array( + Box::new( + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ethabi::ParamType::Bytes + ], + ), + ), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::Address, ethabi::ParamType::Bool, + ethabi::ParamType::Address, ethabi::ParamType::Bool + ], + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Int(256usize)), + ), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + kind: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + swaps: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let tuple_elements = inner.into_tuple().expect(INTERNAL_ERR); + ( + { + let mut result = [0u8; 32]; + let v = tuple_elements[0usize] + .clone() + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + { + let mut v = [0 as u8; 32]; + tuple_elements[1usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + tuple_elements[2usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + tuple_elements[3usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tuple_elements[4usize] + .clone() + .into_bytes() + .expect(INTERNAL_ERR), + ) + }) + .collect(), + assets: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + funds: { + let tuple_elements = values + .pop() + .expect(INTERNAL_ERR) + .into_tuple() + .expect(INTERNAL_ERR); + ( + tuple_elements[0usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[1usize] + .clone() + .into_bool() + .expect(INTERNAL_ERR), + tuple_elements[2usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[3usize] + .clone() + .into_bool() + .expect(INTERNAL_ERR), + ) + }, + limits: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }) + .collect(), + deadline: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.kind.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let v = self + .swaps + .iter() + .map(|inner| ethabi::Token::Tuple( + vec![ + ethabi::Token::FixedBytes(inner.0.as_ref().to_vec()), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.1.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.2.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.3.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), ethabi::Token::Bytes(inner.4.clone()) + ], + )) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .assets + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Tuple( + vec![ + ethabi::Token::Address(ethabi::Address::from_slice(& self + .funds.0)), ethabi::Token::Bool(self.funds.1.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(& self + .funds.2)), ethabi::Token::Bool(self.funds.3.clone()) + ], + ), + { + let v = self + .limits + .iter() + .map(|inner| { + let non_full_signed_bytes = inner.to_signed_bytes_be(); + let full_signed_bytes_init = if non_full_signed_bytes[0] + & 0x80 == 0x80 + { + 0xff + } else { + 0x00 + }; + let mut full_signed_bytes = [full_signed_bytes_init + as u8; 32]; + non_full_signed_bytes + .into_iter() + .rev() + .enumerate() + .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); + ethabi::Token::Int( + ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), + ) + }) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.deadline.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result, String> { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Int(256usize)), + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }) + .collect(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for BatchSwap { + const NAME: &'static str = "batchSwap"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> + for BatchSwap { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeregisterTokens { + pub pool_id: [u8; 32usize], + pub tokens: Vec>, + } + impl DeregisterTokens { + const METHOD_ID: [u8; 4] = [125u8, 58u8, 235u8, 150u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + tokens: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec()), + { + let v = self + .tokens + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::Array(v) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for DeregisterTokens { + const NAME: &'static str = "deregisterTokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ExitPool { + pub pool_id: [u8; 32usize], + pub sender: Vec, + pub recipient: Vec, + pub request: (Vec>, Vec, Vec, bool), + } + impl ExitPool { + const METHOD_ID: [u8; 4] = [139u8, 219u8, 57u8, 19u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))), + ethabi::ParamType::Bytes, ethabi::ParamType::Bool + ], + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + sender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + request: { + let tuple_elements = values + .pop() + .expect(INTERNAL_ERR) + .into_tuple() + .expect(INTERNAL_ERR); + ( + tuple_elements[0usize] + .clone() + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }) + .collect(), + tuple_elements[1usize] + .clone() + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + tuple_elements[2usize] + .clone() + .into_bytes() + .expect(INTERNAL_ERR), + tuple_elements[3usize] + .clone() + .into_bool() + .expect(INTERNAL_ERR), + ) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec()), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.sender), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.recipient), + ), + ethabi::Token::Tuple( + vec![ + { let v = self.request.0.iter().map(| inner | + ethabi::Token::Address(ethabi::Address::from_slice(& + inner))).collect(); ethabi::Token::Array(v) }, { let v = + self.request.1.iter().map(| inner | + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),)).collect(); ethabi::Token::Array(v) }, + ethabi::Token::Bytes(self.request.2.clone()), + ethabi::Token::Bool(self.request.3.clone()) + ], + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for ExitPool { + const NAME: &'static str = "exitPool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FlashLoan { + pub recipient: Vec, + pub tokens: Vec>, + pub amounts: Vec, + pub user_data: Vec, + } + impl FlashLoan { + const METHOD_ID: [u8; 4] = [92u8, 56u8, 68u8, 158u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Bytes, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tokens: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + amounts: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + user_data: values + .pop() + .expect(INTERNAL_ERR) + .into_bytes() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.recipient), + ), + { + let v = self + .tokens + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .amounts + .iter() + .map(|inner| ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match inner.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + )) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Bytes(self.user_data.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for FlashLoan { + const NAME: &'static str = "flashLoan"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetActionId { + pub selector: [u8; 4usize], + } + impl GetActionId { + const METHOD_ID: [u8; 4] = [133u8, 28u8, 27u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(4usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + selector: { + let mut result = [0u8; 4]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::FixedBytes(self.selector.as_ref().to_vec())], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetActionId { + const NAME: &'static str = "getActionId"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for GetActionId { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAuthorizer {} + impl GetAuthorizer { + const METHOD_ID: [u8; 4] = [170u8, 171u8, 173u8, 197u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetAuthorizer { + const NAME: &'static str = "getAuthorizer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GetAuthorizer { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDomainSeparator {} + impl GetDomainSeparator { + const METHOD_ID: [u8; 4] = [237u8, 36u8, 145u8, 29u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetDomainSeparator { + const NAME: &'static str = "getDomainSeparator"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> + for GetDomainSeparator { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetInternalBalance { + pub user: Vec, + pub tokens: Vec>, + } + impl GetInternalBalance { + const METHOD_ID: [u8; 4] = [15u8, 90u8, 110u8, 250u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tokens: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.user)), + { + let v = self + .tokens + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::Array(v) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result, String> { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetInternalBalance { + const NAME: &'static str = "getInternalBalance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> + for GetInternalBalance { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNextNonce { + pub user: Vec, + } + impl GetNextNonce { + const METHOD_ID: [u8; 4] = [144u8, 25u8, 59u8, 124u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.user))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetNextNonce { + const NAME: &'static str = "getNextNonce"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetNextNonce { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPausedState {} + impl GetPausedState { + const METHOD_ID: [u8; 4] = [28u8, 13u8, 224u8, 81u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + (bool, substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + (bool, substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Bool, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + values.pop().expect(INTERNAL_ERR).into_bool().expect(INTERNAL_ERR), + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option<(bool, substreams::scalar::BigInt, substreams::scalar::BigInt)> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetPausedState { + const NAME: &'static str = "getPausedState"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (bool, substreams::scalar::BigInt, substreams::scalar::BigInt), + > for GetPausedState { + fn output( + data: &[u8], + ) -> Result< + (bool, substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPool { + pub pool_id: [u8; 32usize], + } + impl GetPool { + const METHOD_ID: [u8; 4] = [246u8, 192u8, 9u8, 39u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec())], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<(Vec, substreams::scalar::BigInt), String> { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result<(Vec, substreams::scalar::BigInt), String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(8usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option<(Vec, substreams::scalar::BigInt)> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetPool { + const NAME: &'static str = "getPool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (Vec, substreams::scalar::BigInt), + > for GetPool { + fn output( + data: &[u8], + ) -> Result<(Vec, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolTokenInfo { + pub pool_id: [u8; 32usize], + pub token: Vec, + } + impl GetPoolTokenInfo { + const METHOD_ID: [u8; 4] = [176u8, 95u8, 142u8, 72u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.token)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + ), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + ), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetPoolTokenInfo { + const NAME: &'static str = "getPoolTokenInfo"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + ), + > for GetPoolTokenInfo { + fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + ), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolTokens { + pub pool_id: [u8; 32usize], + } + impl GetPoolTokens { + const METHOD_ID: [u8; 4] = [249u8, 77u8, 70u8, 104u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec())], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + ( + Vec>, + Vec, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + Vec>, + Vec, + substreams::scalar::BigInt, + ), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option< + ( + Vec>, + Vec, + substreams::scalar::BigInt, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetPoolTokens { + const NAME: &'static str = "getPoolTokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (Vec>, Vec, substreams::scalar::BigInt), + > for GetPoolTokens { + fn output( + data: &[u8], + ) -> Result< + ( + Vec>, + Vec, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeesCollector {} + impl GetProtocolFeesCollector { + const METHOD_ID: [u8; 4] = [210u8, 148u8, 108u8, 43u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GetProtocolFeesCollector { + const NAME: &'static str = "getProtocolFeesCollector"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> + for GetProtocolFeesCollector { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct HasApprovedRelayer { + pub user: Vec, + pub relayer: Vec, + } + impl HasApprovedRelayer { + const METHOD_ID: [u8; 4] = [254u8, 201u8, 13u8, 114u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + relayer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.user)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.relayer), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for HasApprovedRelayer { + const NAME: &'static str = "hasApprovedRelayer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for HasApprovedRelayer { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct JoinPool { + pub pool_id: [u8; 32usize], + pub sender: Vec, + pub recipient: Vec, + pub request: (Vec>, Vec, Vec, bool), + } + impl JoinPool { + const METHOD_ID: [u8; 4] = [185u8, 92u8, 172u8, 40u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))), + ethabi::ParamType::Bytes, ethabi::ParamType::Bool + ], + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + sender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + request: { + let tuple_elements = values + .pop() + .expect(INTERNAL_ERR) + .into_tuple() + .expect(INTERNAL_ERR); + ( + tuple_elements[0usize] + .clone() + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }) + .collect(), + tuple_elements[1usize] + .clone() + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + tuple_elements[2usize] + .clone() + .into_bytes() + .expect(INTERNAL_ERR), + tuple_elements[3usize] + .clone() + .into_bool() + .expect(INTERNAL_ERR), + ) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec()), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.sender), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.recipient), + ), + ethabi::Token::Tuple( + vec![ + { let v = self.request.0.iter().map(| inner | + ethabi::Token::Address(ethabi::Address::from_slice(& + inner))).collect(); ethabi::Token::Array(v) }, { let v = + self.request.1.iter().map(| inner | + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),)).collect(); ethabi::Token::Array(v) }, + ethabi::Token::Bytes(self.request.2.clone()), + ethabi::Token::Bool(self.request.3.clone()) + ], + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for JoinPool { + const NAME: &'static str = "joinPool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ManagePoolBalance { + pub ops: Vec< + ( + substreams::scalar::BigInt, + [u8; 32usize], + Vec, + substreams::scalar::BigInt, + ), + >, + } + impl ManagePoolBalance { + const METHOD_ID: [u8; 4] = [230u8, 196u8, 96u8, 146u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new( + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::Uint(8usize), + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize) + ], + ), + ), + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + ops: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let tuple_elements = inner.into_tuple().expect(INTERNAL_ERR); + ( + { + let mut v = [0 as u8; 32]; + tuple_elements[0usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut result = [0u8; 32]; + let v = tuple_elements[1usize] + .clone() + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + tuple_elements[2usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + { + let mut v = [0 as u8; 32]; + tuple_elements[3usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + ) + }) + .collect(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .ops + .iter() + .map(|inner| ethabi::Token::Tuple( + vec![ + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.0.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), ethabi::Token::FixedBytes(inner.1.as_ref() + .to_vec()), + ethabi::Token::Address(ethabi::Address::from_slice(& inner + .2)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.3.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),) + ], + )) + .collect(); + ethabi::Token::Array(v) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for ManagePoolBalance { + const NAME: &'static str = "managePoolBalance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ManageUserBalance { + pub ops: Vec< + ( + substreams::scalar::BigInt, + Vec, + substreams::scalar::BigInt, + Vec, + Vec, + ), + >, + } + impl ManageUserBalance { + const METHOD_ID: [u8; 4] = [14u8, 142u8, 62u8, 132u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new( + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::Uint(8usize), ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, ethabi::ParamType::Address + ], + ), + ), + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + ops: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let tuple_elements = inner.into_tuple().expect(INTERNAL_ERR); + ( + { + let mut v = [0 as u8; 32]; + tuple_elements[0usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tuple_elements[1usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + { + let mut v = [0 as u8; 32]; + tuple_elements[2usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tuple_elements[3usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[4usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + }) + .collect(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .ops + .iter() + .map(|inner| ethabi::Token::Tuple( + vec![ + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.0.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), + ethabi::Token::Address(ethabi::Address::from_slice(& inner + .1)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.2.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), + ethabi::Token::Address(ethabi::Address::from_slice(& inner + .3)), ethabi::Token::Address(ethabi::Address::from_slice(& + inner.4)) + ], + )) + .collect(); + ethabi::Token::Array(v) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for ManageUserBalance { + const NAME: &'static str = "manageUserBalance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct QueryBatchSwap { + pub kind: substreams::scalar::BigInt, + pub swaps: Vec< + ( + [u8; 32usize], + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + ), + >, + pub assets: Vec>, + pub funds: (Vec, bool, Vec, bool), + } + impl QueryBatchSwap { + const METHOD_ID: [u8; 4] = [248u8, 77u8, 6u8, 110u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(8usize), + ethabi::ParamType::Array( + Box::new( + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ethabi::ParamType::Bytes + ], + ), + ), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::Address, ethabi::ParamType::Bool, + ethabi::ParamType::Address, ethabi::ParamType::Bool + ], + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + kind: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + swaps: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let tuple_elements = inner.into_tuple().expect(INTERNAL_ERR); + ( + { + let mut result = [0u8; 32]; + let v = tuple_elements[0usize] + .clone() + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + { + let mut v = [0 as u8; 32]; + tuple_elements[1usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + tuple_elements[2usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + tuple_elements[3usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tuple_elements[4usize] + .clone() + .into_bytes() + .expect(INTERNAL_ERR), + ) + }) + .collect(), + assets: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + funds: { + let tuple_elements = values + .pop() + .expect(INTERNAL_ERR) + .into_tuple() + .expect(INTERNAL_ERR); + ( + tuple_elements[0usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[1usize] + .clone() + .into_bool() + .expect(INTERNAL_ERR), + tuple_elements[2usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[3usize] + .clone() + .into_bool() + .expect(INTERNAL_ERR), + ) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.kind.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let v = self + .swaps + .iter() + .map(|inner| ethabi::Token::Tuple( + vec![ + ethabi::Token::FixedBytes(inner.0.as_ref().to_vec()), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.1.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.2.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match + inner.3.clone().to_bytes_be() { (num_bigint::Sign::Plus, + bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), ethabi::Token::Bytes(inner.4.clone()) + ], + )) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .assets + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Tuple( + vec![ + ethabi::Token::Address(ethabi::Address::from_slice(& self + .funds.0)), ethabi::Token::Bool(self.funds.1.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(& self + .funds.2)), ethabi::Token::Bool(self.funds.3.clone()) + ], + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result, String> { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Int(256usize)), + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }) + .collect(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call( + &self, + address: Vec, + ) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for QueryBatchSwap { + const NAME: &'static str = "queryBatchSwap"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> + for QueryBatchSwap { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RegisterPool { + pub specialization: substreams::scalar::BigInt, + } + impl RegisterPool { + const METHOD_ID: [u8; 4] = [9u8, 178u8, 118u8, 15u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(8usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + specialization: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.specialization.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for RegisterPool { + const NAME: &'static str = "registerPool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for RegisterPool { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RegisterTokens { + pub pool_id: [u8; 32usize], + pub tokens: Vec>, + pub asset_managers: Vec>, + } + impl RegisterTokens { + const METHOD_ID: [u8; 4] = [102u8, 169u8, 199u8, 210u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + tokens: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + asset_managers: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::FixedBytes(self.pool_id.as_ref().to_vec()), + { + let v = self + .tokens + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .asset_managers + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::Array(v) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for RegisterTokens { + const NAME: &'static str = "registerTokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetAuthorizer { + pub new_authorizer: Vec, + } + impl SetAuthorizer { + const METHOD_ID: [u8; 4] = [5u8, 138u8, 98u8, 143u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + new_authorizer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.new_authorizer), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for SetAuthorizer { + const NAME: &'static str = "setAuthorizer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetPaused { + pub paused: bool, + } + impl SetPaused { + const METHOD_ID: [u8; 4] = [22u8, 195u8, 139u8, 60u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + paused: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ethabi::Token::Bool(self.paused.clone())]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for SetPaused { + const NAME: &'static str = "setPaused"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetRelayerApproval { + pub sender: Vec, + pub relayer: Vec, + pub approved: bool, + } + impl SetRelayerApproval { + const METHOD_ID: [u8; 4] = [250u8, 110u8, 103u8, 29u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Bool, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + sender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + relayer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + approved: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.sender), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.relayer), + ), + ethabi::Token::Bool(self.approved.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for SetRelayerApproval { + const NAME: &'static str = "setRelayerApproval"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Swap { + pub single_swap: ( + [u8; 32usize], + substreams::scalar::BigInt, + Vec, + Vec, + substreams::scalar::BigInt, + Vec, + ), + pub funds: (Vec, bool, Vec, bool), + pub limit: substreams::scalar::BigInt, + pub deadline: substreams::scalar::BigInt, + } + impl Swap { + const METHOD_ID: [u8; 4] = [82u8, 187u8, 190u8, 41u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Uint(8usize), ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), ethabi::ParamType::Bytes + ], + ), + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::Address, ethabi::ParamType::Bool, + ethabi::ParamType::Address, ethabi::ParamType::Bool + ], + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + single_swap: { + let tuple_elements = values + .pop() + .expect(INTERNAL_ERR) + .into_tuple() + .expect(INTERNAL_ERR); + ( + { + let mut result = [0u8; 32]; + let v = tuple_elements[0usize] + .clone() + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + { + let mut v = [0 as u8; 32]; + tuple_elements[1usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tuple_elements[2usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[3usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + { + let mut v = [0 as u8; 32]; + tuple_elements[4usize] + .clone() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tuple_elements[5usize] + .clone() + .into_bytes() + .expect(INTERNAL_ERR), + ) + }, + funds: { + let tuple_elements = values + .pop() + .expect(INTERNAL_ERR) + .into_tuple() + .expect(INTERNAL_ERR); + ( + tuple_elements[0usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[1usize] + .clone() + .into_bool() + .expect(INTERNAL_ERR), + tuple_elements[2usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[3usize] + .clone() + .into_bool() + .expect(INTERNAL_ERR), + ) + }, + limit: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + deadline: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Tuple( + vec![ + ethabi::Token::FixedBytes(self.single_swap.0.as_ref() + .to_vec()), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self + .single_swap.1.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), + ethabi::Token::Address(ethabi::Address::from_slice(& self + .single_swap.2)), + ethabi::Token::Address(ethabi::Address::from_slice(& self + .single_swap.3)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self + .single_swap.4.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") }, } + .as_slice(),),), ethabi::Token::Bytes(self.single_swap.5 + .clone()) + ], + ), + ethabi::Token::Tuple( + vec![ + ethabi::Token::Address(ethabi::Address::from_slice(& self + .funds.0)), ethabi::Token::Bool(self.funds.1.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(& self + .funds.2)), ethabi::Token::Bool(self.funds.3.clone()) + ], + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.limit.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.deadline.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Swap { + const NAME: &'static str = "swap"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Swap { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + } + /// Contract's events. + #[allow(dead_code, unused_imports, unused_variables)] + pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct AuthorizerChanged { + pub new_authorizer: Vec, + } + impl AuthorizerChanged { + const TOPIC_ID: [u8; 32] = [ + 148u8, + 185u8, + 121u8, + 182u8, + 131u8, + 26u8, + 81u8, + 41u8, + 62u8, + 38u8, + 65u8, + 66u8, + 111u8, + 151u8, + 116u8, + 127u8, + 238u8, + 212u8, + 111u8, + 23u8, + 119u8, + 159u8, + 237u8, + 156u8, + 209u8, + 141u8, + 30u8, + 206u8, + 252u8, + 254u8, + 146u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 0usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Ok(Self { + new_authorizer: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'new_authorizer' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for AuthorizerChanged { + const NAME: &'static str = "AuthorizerChanged"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ExternalBalanceTransfer { + pub token: Vec, + pub sender: Vec, + pub recipient: Vec, + pub amount: substreams::scalar::BigInt, + } + impl ExternalBalanceTransfer { + const TOPIC_ID: [u8; 32] = [ + 84u8, + 10u8, + 26u8, + 63u8, + 40u8, + 52u8, + 12u8, + 174u8, + 195u8, + 54u8, + 200u8, + 29u8, + 141u8, + 123u8, + 61u8, + 241u8, + 57u8, + 238u8, + 92u8, + 220u8, + 24u8, + 57u8, + 164u8, + 242u8, + 131u8, + 215u8, + 235u8, + 183u8, + 234u8, + 174u8, + 45u8, + 92u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 64usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + token: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'token' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + sender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'sender' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for ExternalBalanceTransfer { + const NAME: &'static str = "ExternalBalanceTransfer"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FlashLoan { + pub recipient: Vec, + pub token: Vec, + pub amount: substreams::scalar::BigInt, + pub fee_amount: substreams::scalar::BigInt, + } + impl FlashLoan { + const TOPIC_ID: [u8; 32] = [ + 13u8, + 125u8, + 117u8, + 224u8, + 26u8, + 185u8, + 87u8, + 128u8, + 211u8, + 205u8, + 28u8, + 142u8, + 192u8, + 221u8, + 108u8, + 44u8, + 225u8, + 158u8, + 58u8, + 32u8, + 66u8, + 126u8, + 236u8, + 139u8, + 245u8, + 50u8, + 131u8, + 182u8, + 251u8, + 142u8, + 149u8, + 240u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 64usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + recipient: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'recipient' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'token' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + fee_amount: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for FlashLoan { + const NAME: &'static str = "FlashLoan"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InternalBalanceChanged { + pub user: Vec, + pub token: Vec, + pub delta: substreams::scalar::BigInt, + } + impl InternalBalanceChanged { + const TOPIC_ID: [u8; 32] = [ + 24u8, + 225u8, + 234u8, + 65u8, + 57u8, + 230u8, + 132u8, + 19u8, + 215u8, + 208u8, + 138u8, + 167u8, + 82u8, + 231u8, + 21u8, + 104u8, + 227u8, + 107u8, + 44u8, + 91u8, + 249u8, + 64u8, + 137u8, + 51u8, + 20u8, + 194u8, + 197u8, + 176u8, + 30u8, + 170u8, + 12u8, + 66u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Int(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + user: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'user' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'token' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + delta: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for InternalBalanceChanged { + const NAME: &'static str = "InternalBalanceChanged"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PausedStateChanged { + pub paused: bool, + } + impl PausedStateChanged { + const TOPIC_ID: [u8; 32] = [ + 158u8, + 58u8, + 94u8, + 55u8, + 34u8, + 69u8, + 50u8, + 222u8, + 166u8, + 123u8, + 137u8, + 250u8, + 206u8, + 24u8, + 87u8, + 3u8, + 115u8, + 138u8, + 34u8, + 138u8, + 110u8, + 138u8, + 35u8, + 222u8, + 229u8, + 70u8, + 150u8, + 1u8, + 128u8, + 211u8, + 190u8, + 100u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + paused: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + } + impl substreams_ethereum::Event for PausedStateChanged { + const NAME: &'static str = "PausedStateChanged"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolBalanceChanged { + pub pool_id: [u8; 32usize], + pub liquidity_provider: Vec, + pub tokens: Vec>, + pub deltas: Vec, + pub protocol_fee_amounts: Vec, + } + impl PoolBalanceChanged { + const TOPIC_ID: [u8; 32] = [ + 229u8, + 206u8, + 36u8, + 144u8, + 135u8, + 206u8, + 4u8, + 240u8, + 90u8, + 149u8, + 113u8, + 146u8, + 67u8, + 84u8, + 0u8, + 253u8, + 151u8, + 134u8, + 141u8, + 186u8, + 14u8, + 106u8, + 75u8, + 76u8, + 4u8, + 154u8, + 191u8, + 138u8, + 248u8, + 13u8, + 174u8, + 120u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() < 192usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Int(256usize)), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'pool_id' from topic of type 'bytes32': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + liquidity_provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'liquidity_provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tokens: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + deltas: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }) + .collect(), + protocol_fee_amounts: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + let mut v = [0 as u8; 32]; + inner + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + .collect(), + }) + } + } + impl substreams_ethereum::Event for PoolBalanceChanged { + const NAME: &'static str = "PoolBalanceChanged"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolBalanceManaged { + pub pool_id: [u8; 32usize], + pub asset_manager: Vec, + pub token: Vec, + pub cash_delta: substreams::scalar::BigInt, + pub managed_delta: substreams::scalar::BigInt, + } + impl PoolBalanceManaged { + const TOPIC_ID: [u8; 32] = [ + 110u8, + 220u8, + 175u8, + 98u8, + 65u8, + 16u8, + 91u8, + 76u8, + 148u8, + 194u8, + 239u8, + 219u8, + 243u8, + 166u8, + 177u8, + 36u8, + 88u8, + 235u8, + 61u8, + 7u8, + 190u8, + 58u8, + 14u8, + 129u8, + 210u8, + 75u8, + 19u8, + 196u8, + 64u8, + 69u8, + 254u8, + 122u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 4usize { + return false; + } + if log.data.len() != 64usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(256usize), + ethabi::ParamType::Int(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'pool_id' from topic of type 'bytes32': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + asset_manager: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'asset_manager' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[3usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'token' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + cash_delta: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + managed_delta: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for PoolBalanceManaged { + const NAME: &'static str = "PoolBalanceManaged"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolRegistered { + pub pool_id: [u8; 32usize], + pub pool_address: Vec, + pub specialization: substreams::scalar::BigInt, + } + impl PoolRegistered { + const TOPIC_ID: [u8; 32] = [ + 60u8, + 19u8, + 188u8, + 48u8, + 184u8, + 232u8, + 120u8, + 197u8, + 63u8, + 210u8, + 163u8, + 107u8, + 103u8, + 148u8, + 9u8, + 192u8, + 115u8, + 175u8, + 215u8, + 89u8, + 80u8, + 190u8, + 67u8, + 216u8, + 133u8, + 135u8, + 104u8, + 233u8, + 86u8, + 251u8, + 194u8, + 14u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(8usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'pool_id' from topic of type 'bytes32': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + pool_address: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'pool_address' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + specialization: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for PoolRegistered { + const NAME: &'static str = "PoolRegistered"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RelayerApprovalChanged { + pub relayer: Vec, + pub sender: Vec, + pub approved: bool, + } + impl RelayerApprovalChanged { + const TOPIC_ID: [u8; 32] = [ + 70u8, + 150u8, + 31u8, + 219u8, + 69u8, + 2u8, + 182u8, + 70u8, + 213u8, + 9u8, + 95u8, + 186u8, + 118u8, + 0u8, + 72u8, + 106u8, + 138u8, + 192u8, + 80u8, + 65u8, + 213u8, + 92u8, + 223u8, + 15u8, + 22u8, + 237u8, + 103u8, + 113u8, + 128u8, + 181u8, + 202u8, + 216u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Bool], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + relayer: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'relayer' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + sender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'sender' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + approved: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + } + impl substreams_ethereum::Event for RelayerApprovalChanged { + const NAME: &'static str = "RelayerApprovalChanged"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Swap { + pub pool_id: [u8; 32usize], + pub token_in: Vec, + pub token_out: Vec, + pub amount_in: substreams::scalar::BigInt, + pub amount_out: substreams::scalar::BigInt, + } + impl Swap { + const TOPIC_ID: [u8; 32] = [ + 33u8, + 112u8, + 199u8, + 65u8, + 196u8, + 21u8, + 49u8, + 174u8, + 194u8, + 14u8, + 124u8, + 16u8, + 124u8, + 36u8, + 238u8, + 207u8, + 221u8, + 21u8, + 230u8, + 156u8, + 155u8, + 176u8, + 168u8, + 221u8, + 55u8, + 177u8, + 132u8, + 11u8, + 158u8, + 11u8, + 32u8, + 123u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 4usize { + return false; + } + if log.data.len() != 64usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'pool_id' from topic of type 'bytes32': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + token_in: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'token_in' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_out: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[3usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'token_out' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount_in: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + amount_out: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Swap { + const NAME: &'static str = "Swap"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TokensDeregistered { + pub pool_id: [u8; 32usize], + pub tokens: Vec>, + } + impl TokensDeregistered { + const TOPIC_ID: [u8; 32] = [ + 125u8, + 205u8, + 198u8, + 208u8, + 46u8, + 244u8, + 12u8, + 124u8, + 26u8, + 112u8, + 70u8, + 160u8, + 17u8, + 176u8, + 88u8, + 189u8, + 127u8, + 152u8, + 143u8, + 161u8, + 78u8, + 32u8, + 166u8, + 99u8, + 68u8, + 249u8, + 212u8, + 230u8, + 6u8, + 87u8, + 214u8, + 16u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() < 64usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'pool_id' from topic of type 'bytes32': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + tokens: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + }) + } + } + impl substreams_ethereum::Event for TokensDeregistered { + const NAME: &'static str = "TokensDeregistered"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TokensRegistered { + pub pool_id: [u8; 32usize], + pub tokens: Vec>, + pub asset_managers: Vec>, + } + impl TokensRegistered { + const TOPIC_ID: [u8; 32] = [ + 245u8, + 132u8, + 125u8, + 63u8, + 33u8, + 151u8, + 177u8, + 108u8, + 220u8, + 210u8, + 9u8, + 142u8, + 201u8, + 93u8, + 9u8, + 5u8, + 205u8, + 26u8, + 189u8, + 175u8, + 65u8, + 95u8, + 7u8, + 187u8, + 124u8, + 239u8, + 43u8, + 186u8, + 138u8, + 197u8, + 222u8, + 196u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() < 128usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Address), + ), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_id: { + let mut result = [0u8; 32]; + let v = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'pool_id' from topic of type 'bytes32': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + tokens: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + asset_managers: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() + }) + .collect(), + }) + } + } + impl substreams_ethereum::Event for TokensRegistered { + const NAME: &'static str = "TokensRegistered"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + } \ No newline at end of file diff --git a/sql/balancer_v2/src/lib.rs b/sql/balancer_v2/src/lib.rs new file mode 100644 index 0000000..324a51b --- /dev/null +++ b/sql/balancer_v2/src/lib.rs @@ -0,0 +1,2862 @@ +mod abi; +mod pb; +use hex_literal::hex; +use pb::contract::v1 as contract; +use substreams::prelude::*; +use substreams::store; +use substreams::Hex; +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; +use substreams_ethereum::pb::eth::v2 as eth; +use substreams_ethereum::Event; + +#[allow(unused_imports)] +use num_traits::cast::ToPrimitive; +use std::str::FromStr; +use substreams::scalar::BigDecimal; + +substreams_ethereum::init!(); + +const VAULT_TRACKED_CONTRACT: [u8; 20] = hex!("ba12222222228d8ba445958a75a0704d566bf2c8"); + +fn map_vault_events(blk: ð::Block, events: &mut contract::Events) { + events.vault_authorizer_changeds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::AuthorizerChanged::match_and_decode(log) { + return Some(contract::VaultAuthorizerChanged { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + new_authorizer: event.new_authorizer, + }); + } + + None + }) + }) + .collect()); + events.vault_external_balance_transfers.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::ExternalBalanceTransfer::match_and_decode(log) { + return Some(contract::VaultExternalBalanceTransfer { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + amount: event.amount.to_string(), + recipient: event.recipient, + sender: event.sender, + token: event.token, + }); + } + + None + }) + }) + .collect()); + events.vault_flash_loans.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::FlashLoan::match_and_decode(log) { + return Some(contract::VaultFlashLoan { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + amount: event.amount.to_string(), + fee_amount: event.fee_amount.to_string(), + recipient: event.recipient, + token: event.token, + }); + } + + None + }) + }) + .collect()); + events.vault_internal_balance_changeds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::InternalBalanceChanged::match_and_decode(log) { + return Some(contract::VaultInternalBalanceChanged { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + delta: event.delta.to_string(), + token: event.token, + user: event.user, + }); + } + + None + }) + }) + .collect()); + events.vault_paused_state_changeds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::PausedStateChanged::match_and_decode(log) { + return Some(contract::VaultPausedStateChanged { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + paused: event.paused, + }); + } + + None + }) + }) + .collect()); + events.vault_pool_balance_changeds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::PoolBalanceChanged::match_and_decode(log) { + return Some(contract::VaultPoolBalanceChanged { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + deltas: event.deltas.into_iter().map(|x| x.to_string()).collect::>(), + liquidity_provider: event.liquidity_provider, + pool_id: Vec::from(event.pool_id), + protocol_fee_amounts: event.protocol_fee_amounts.into_iter().map(|x| x.to_string()).collect::>(), + tokens: event.tokens.into_iter().map(|x| x).collect::>(), + }); + } + + None + }) + }) + .collect()); + events.vault_pool_balance_manageds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::PoolBalanceManaged::match_and_decode(log) { + return Some(contract::VaultPoolBalanceManaged { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + asset_manager: event.asset_manager, + cash_delta: event.cash_delta.to_string(), + managed_delta: event.managed_delta.to_string(), + pool_id: Vec::from(event.pool_id), + token: event.token, + }); + } + + None + }) + }) + .collect()); + events.vault_pool_registereds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::PoolRegistered::match_and_decode(log) { + return Some(contract::VaultPoolRegistered { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + pool_address: event.pool_address, + pool_id: Vec::from(event.pool_id), + specialization: event.specialization.to_u64(), + }); + } + + None + }) + }) + .collect()); + events.vault_relayer_approval_changeds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::RelayerApprovalChanged::match_and_decode(log) { + return Some(contract::VaultRelayerApprovalChanged { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + approved: event.approved, + relayer: event.relayer, + sender: event.sender, + }); + } + + None + }) + }) + .collect()); + events.vault_swaps.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::Swap::match_and_decode(log) { + return Some(contract::VaultSwap { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + amount_in: event.amount_in.to_string(), + amount_out: event.amount_out.to_string(), + pool_id: Vec::from(event.pool_id), + token_in: event.token_in, + token_out: event.token_out, + }); + } + + None + }) + }) + .collect()); + events.vault_tokens_deregistereds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::TokensDeregistered::match_and_decode(log) { + return Some(contract::VaultTokensDeregistered { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + pool_id: Vec::from(event.pool_id), + tokens: event.tokens.into_iter().map(|x| x).collect::>(), + }); + } + + None + }) + }) + .collect()); + events.vault_tokens_registereds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + .filter_map(|log| { + if let Some(event) = abi::vault_contract::events::TokensRegistered::match_and_decode(log) { + return Some(contract::VaultTokensRegistered { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + asset_managers: event.asset_managers.into_iter().map(|x| x).collect::>(), + pool_id: Vec::from(event.pool_id), + tokens: event.tokens.into_iter().map(|x| x).collect::>(), + }); + } + + None + }) + }) + .collect()); +} + +fn map_vault_calls(blk: ð::Block, calls: &mut contract::Calls) { + calls.vault_call_batch_swaps.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::BatchSwap::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::BatchSwap::decode(call) { + Ok(decoded_call) => { + let output_asset_deltas = match abi::vault_contract::functions::BatchSwap::output(&call.return_data) { + Ok(output_asset_deltas) => {output_asset_deltas} + Err(_) => Default::default(), + }; + + Some(contract::VaultBatchSwapCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + assets: decoded_call.assets.into_iter().map(|x| x).collect::>(), + deadline: decoded_call.deadline.to_string(), + kind: decoded_call.kind.to_u64(), + limits: decoded_call.limits.into_iter().map(|x| x.to_string()).collect::>(), + output_asset_deltas: output_asset_deltas.into_iter().map(|x| x.to_string()).collect::>(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_deregister_tokens.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::DeregisterTokens::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::DeregisterTokens::decode(call) { + Ok(decoded_call) => { + Some(contract::VaultDeregisterTokensCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + pool_id: Vec::from(decoded_call.pool_id), + tokens: decoded_call.tokens.into_iter().map(|x| x).collect::>(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_exit_pools.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::ExitPool::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::ExitPool::decode(call) { + Ok(decoded_call) => { + Some(contract::VaultExitPoolCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + pool_id: Vec::from(decoded_call.pool_id), + recipient: decoded_call.recipient, + sender: decoded_call.sender, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_flash_loans.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::FlashLoan::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::FlashLoan::decode(call) { + Ok(decoded_call) => { + Some(contract::VaultFlashLoanCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + amounts: decoded_call.amounts.into_iter().map(|x| x.to_string()).collect::>(), + recipient: decoded_call.recipient, + tokens: decoded_call.tokens.into_iter().map(|x| x).collect::>(), + user_data: decoded_call.user_data, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_join_pools.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::JoinPool::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::JoinPool::decode(call) { + Ok(decoded_call) => { + Some(contract::VaultJoinPoolCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + pool_id: Vec::from(decoded_call.pool_id), + recipient: decoded_call.recipient, + sender: decoded_call.sender, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_manage_pool_balances.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::ManagePoolBalance::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::ManagePoolBalance::decode(call) { + Ok(decoded_call) => { + Some(contract::VaultManagePoolBalanceCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_manage_user_balances.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::ManageUserBalance::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::ManageUserBalance::decode(call) { + Ok(decoded_call) => { + Some(contract::VaultManageUserBalanceCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_query_batch_swaps.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::QueryBatchSwap::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::QueryBatchSwap::decode(call) { + Ok(decoded_call) => { + let output_param0 = match abi::vault_contract::functions::QueryBatchSwap::output(&call.return_data) { + Ok(output_param0) => {output_param0} + Err(_) => Default::default(), + }; + + Some(contract::VaultQueryBatchSwapCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + assets: decoded_call.assets.into_iter().map(|x| x).collect::>(), + kind: decoded_call.kind.to_u64(), + output_param0: output_param0.into_iter().map(|x| x.to_string()).collect::>(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_register_pools.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::RegisterPool::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::RegisterPool::decode(call) { + Ok(decoded_call) => { + let output_param0 = match abi::vault_contract::functions::RegisterPool::output(&call.return_data) { + Ok(output_param0) => {output_param0} + Err(_) => Default::default(), + }; + + Some(contract::VaultRegisterPoolCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + output_param0: Vec::from(output_param0), + specialization: decoded_call.specialization.to_u64(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_register_tokens.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::RegisterTokens::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::RegisterTokens::decode(call) { + Ok(decoded_call) => { + Some(contract::VaultRegisterTokensCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + asset_managers: decoded_call.asset_managers.into_iter().map(|x| x).collect::>(), + pool_id: Vec::from(decoded_call.pool_id), + tokens: decoded_call.tokens.into_iter().map(|x| x).collect::>(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_set_authorizers.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::SetAuthorizer::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::SetAuthorizer::decode(call) { + Ok(decoded_call) => { + Some(contract::VaultSetAuthorizerCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + new_authorizer: decoded_call.new_authorizer, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_set_pauseds.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::SetPaused::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::SetPaused::decode(call) { + Ok(decoded_call) => { + Some(contract::VaultSetPausedCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + paused: decoded_call.paused, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_set_relayer_approvals.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::SetRelayerApproval::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::SetRelayerApproval::decode(call) { + Ok(decoded_call) => { + Some(contract::VaultSetRelayerApprovalCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + approved: decoded_call.approved, + relayer: decoded_call.relayer, + sender: decoded_call.sender, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.vault_call_swaps.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| call.address == VAULT_TRACKED_CONTRACT && abi::vault_contract::functions::Swap::match_call(call)) + .filter_map(|call| { + match abi::vault_contract::functions::Swap::decode(call) { + Ok(decoded_call) => { + let output_amount_calculated = match abi::vault_contract::functions::Swap::output(&call.return_data) { + Ok(output_amount_calculated) => {output_amount_calculated} + Err(_) => Default::default(), + }; + + Some(contract::VaultSwapCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + deadline: decoded_call.deadline.to_string(), + limit: decoded_call.limit.to_string(), + output_amount_calculated: output_amount_calculated.to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); +} + +fn is_declared_dds_address(addr: &Vec, ordinal: u64, dds_store: &store::StoreGetInt64) -> bool { + // substreams::log::info!("Checking if address {} is declared dds address", Hex(addr).to_string()); + if dds_store.get_at(ordinal, Hex(addr).to_string()).is_some() { + return true; + } + return false; +} + +fn map_pools_events( + blk: ð::Block, + dds_store: &store::StoreGetInt64, + events: &mut contract::Events, +) { + + events.pools_amp_update_starteds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| is_declared_dds_address(&log.address, log.ordinal, dds_store)) + .filter_map(|log| { + if let Some(event) = abi::pools_contract::events::AmpUpdateStarted::match_and_decode(log) { + return Some(contract::PoolsAmpUpdateStarted { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + evt_address: Hex(&log.address).to_string(), + end_time: event.end_time.to_string(), + end_value: event.end_value.to_string(), + start_time: event.start_time.to_string(), + start_value: event.start_value.to_string(), + }); + } + + None + }) + }) + .collect()); + + events.pools_amp_update_stoppeds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| is_declared_dds_address(&log.address, log.ordinal, dds_store)) + .filter_map(|log| { + if let Some(event) = abi::pools_contract::events::AmpUpdateStopped::match_and_decode(log) { + return Some(contract::PoolsAmpUpdateStopped { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + evt_address: Hex(&log.address).to_string(), + current_value: event.current_value.to_string(), + }); + } + + None + }) + }) + .collect()); + + events.pools_approvals.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| is_declared_dds_address(&log.address, log.ordinal, dds_store)) + .filter_map(|log| { + if let Some(event) = abi::pools_contract::events::Approval::match_and_decode(log) { + return Some(contract::PoolsApproval { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + evt_address: Hex(&log.address).to_string(), + owner: event.owner, + spender: event.spender, + value: event.value.to_string(), + }); + } + + None + }) + }) + .collect()); + + events.pools_paused_state_changeds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| is_declared_dds_address(&log.address, log.ordinal, dds_store)) + .filter_map(|log| { + if let Some(event) = abi::pools_contract::events::PausedStateChanged::match_and_decode(log) { + return Some(contract::PoolsPausedStateChanged { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + evt_address: Hex(&log.address).to_string(), + paused: event.paused, + }); + } + + None + }) + }) + .collect()); + + events.pools_protocol_fee_percentage_cache_updateds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| is_declared_dds_address(&log.address, log.ordinal, dds_store)) + .filter_map(|log| { + if let Some(event) = abi::pools_contract::events::ProtocolFeePercentageCacheUpdated::match_and_decode(log) { + return Some(contract::PoolsProtocolFeePercentageCacheUpdated { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + evt_address: Hex(&log.address).to_string(), + fee_type: event.fee_type.to_string(), + protocol_fee_percentage: event.protocol_fee_percentage.to_string(), + }); + } + + None + }) + }) + .collect()); + + events.pools_recovery_mode_state_changeds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| is_declared_dds_address(&log.address, log.ordinal, dds_store)) + .filter_map(|log| { + if let Some(event) = abi::pools_contract::events::RecoveryModeStateChanged::match_and_decode(log) { + return Some(contract::PoolsRecoveryModeStateChanged { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + evt_address: Hex(&log.address).to_string(), + enabled: event.enabled, + }); + } + + None + }) + }) + .collect()); + + events.pools_swap_fee_percentage_changeds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| is_declared_dds_address(&log.address, log.ordinal, dds_store)) + .filter_map(|log| { + if let Some(event) = abi::pools_contract::events::SwapFeePercentageChanged::match_and_decode(log) { + return Some(contract::PoolsSwapFeePercentageChanged { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + evt_address: Hex(&log.address).to_string(), + swap_fee_percentage: event.swap_fee_percentage.to_string(), + }); + } + + None + }) + }) + .collect()); + + events.pools_token_rate_cache_updateds.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| is_declared_dds_address(&log.address, log.ordinal, dds_store)) + .filter_map(|log| { + if let Some(event) = abi::pools_contract::events::TokenRateCacheUpdated::match_and_decode(log) { + return Some(contract::PoolsTokenRateCacheUpdated { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + evt_address: Hex(&log.address).to_string(), + rate: event.rate.to_string(), + token_index: event.token_index.to_string(), + }); + } + + None + }) + }) + .collect()); + + events.pools_token_rate_provider_sets.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| is_declared_dds_address(&log.address, log.ordinal, dds_store)) + .filter_map(|log| { + if let Some(event) = abi::pools_contract::events::TokenRateProviderSet::match_and_decode(log) { + return Some(contract::PoolsTokenRateProviderSet { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + evt_address: Hex(&log.address).to_string(), + cache_duration: event.cache_duration.to_string(), + provider: event.provider, + token_index: event.token_index.to_string(), + }); + } + + None + }) + }) + .collect()); + + events.pools_transfers.append(&mut blk + .receipts() + .flat_map(|view| { + view.receipt.logs.iter() + .filter(|log| is_declared_dds_address(&log.address, log.ordinal, dds_store)) + .filter_map(|log| { + if let Some(event) = abi::pools_contract::events::Transfer::match_and_decode(log) { + return Some(contract::PoolsTransfer { + evt_tx_hash: Hex(&view.transaction.hash).to_string(), + evt_index: log.block_index, + evt_block_time: Some(blk.timestamp().to_owned()), + evt_block_number: blk.number, + evt_address: Hex(&log.address).to_string(), + from: event.from, + to: event.to, + value: event.value.to_string(), + }); + } + + None + }) + }) + .collect()); +} +fn map_pools_calls( + blk: ð::Block, + dds_store: &store::StoreGetInt64, + calls: &mut contract::Calls, +) { + calls.pools_call_approves.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::Approve::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::Approve::decode(call) { + Ok(decoded_call) => { + let output_param0 = match abi::pools_contract::functions::Approve::output(&call.return_data) { + Ok(output_param0) => {output_param0} + Err(_) => Default::default(), + }; + + Some(contract::PoolsApproveCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + amount: decoded_call.amount.to_string(), + output_param0: output_param0, + spender: decoded_call.spender, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_decrease_allowances.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::DecreaseAllowance::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::DecreaseAllowance::decode(call) { + Ok(decoded_call) => { + let output_param0 = match abi::pools_contract::functions::DecreaseAllowance::output(&call.return_data) { + Ok(output_param0) => {output_param0} + Err(_) => Default::default(), + }; + + Some(contract::PoolsDecreaseAllowanceCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + amount: decoded_call.amount.to_string(), + output_param0: output_param0, + spender: decoded_call.spender, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_disable_recovery_modes.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::DisableRecoveryMode::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::DisableRecoveryMode::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsDisableRecoveryModeCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_enable_recovery_modes.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::EnableRecoveryMode::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::EnableRecoveryMode::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsEnableRecoveryModeCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_increase_allowances.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::IncreaseAllowance::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::IncreaseAllowance::decode(call) { + Ok(decoded_call) => { + let output_param0 = match abi::pools_contract::functions::IncreaseAllowance::output(&call.return_data) { + Ok(output_param0) => {output_param0} + Err(_) => Default::default(), + }; + + Some(contract::PoolsIncreaseAllowanceCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + added_value: decoded_call.added_value.to_string(), + output_param0: output_param0, + spender: decoded_call.spender, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_on_exit_pools.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::OnExitPool::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::OnExitPool::decode(call) { + Ok(decoded_call) => { + let (output_param0, output_param1) = match abi::pools_contract::functions::OnExitPool::output(&call.return_data) { + Ok((output_param0, output_param1)) => {(output_param0, output_param1)} + Err(_) => Default::default(), + }; + + Some(contract::PoolsOnExitPoolCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + balances: decoded_call.balances.into_iter().map(|x| x.to_string()).collect::>(), + last_change_block: decoded_call.last_change_block.to_string(), + output_param0: output_param0.into_iter().map(|x| x.to_string()).collect::>(), + output_param1: output_param1.into_iter().map(|x| x.to_string()).collect::>(), + pool_id: Vec::from(decoded_call.pool_id), + protocol_swap_fee_percentage: decoded_call.protocol_swap_fee_percentage.to_string(), + recipient: decoded_call.recipient, + sender: decoded_call.sender, + user_data: decoded_call.user_data, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_on_join_pools.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::OnJoinPool::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::OnJoinPool::decode(call) { + Ok(decoded_call) => { + let (output_param0, output_param1) = match abi::pools_contract::functions::OnJoinPool::output(&call.return_data) { + Ok((output_param0, output_param1)) => {(output_param0, output_param1)} + Err(_) => Default::default(), + }; + + Some(contract::PoolsOnJoinPoolCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + balances: decoded_call.balances.into_iter().map(|x| x.to_string()).collect::>(), + last_change_block: decoded_call.last_change_block.to_string(), + output_param0: output_param0.into_iter().map(|x| x.to_string()).collect::>(), + output_param1: output_param1.into_iter().map(|x| x.to_string()).collect::>(), + pool_id: Vec::from(decoded_call.pool_id), + protocol_swap_fee_percentage: decoded_call.protocol_swap_fee_percentage.to_string(), + recipient: decoded_call.recipient, + sender: decoded_call.sender, + user_data: decoded_call.user_data, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_on_swaps.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::OnSwap::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::OnSwap::decode(call) { + Ok(decoded_call) => { + let output_param0 = match abi::pools_contract::functions::OnSwap::output(&call.return_data) { + Ok(output_param0) => {output_param0} + Err(_) => Default::default(), + }; + + Some(contract::PoolsOnSwapCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + balances: decoded_call.balances.into_iter().map(|x| x.to_string()).collect::>(), + index_in: decoded_call.index_in.to_string(), + index_out: decoded_call.index_out.to_string(), + output_param0: output_param0.to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_pauses.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::Pause::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::Pause::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsPauseCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_permits.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::Permit::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::Permit::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsPermitCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + deadline: decoded_call.deadline.to_string(), + owner: decoded_call.owner, + r: Vec::from(decoded_call.r), + s: Vec::from(decoded_call.s), + spender: decoded_call.spender, + v: decoded_call.v.to_u64(), + value: decoded_call.value.to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_query_exits.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::QueryExit::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::QueryExit::decode(call) { + Ok(decoded_call) => { + let (output_bpt_in, output_amounts_out) = match abi::pools_contract::functions::QueryExit::output(&call.return_data) { + Ok((output_bpt_in, output_amounts_out)) => {(output_bpt_in, output_amounts_out)} + Err(_) => Default::default(), + }; + + Some(contract::PoolsQueryExitCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + balances: decoded_call.balances.into_iter().map(|x| x.to_string()).collect::>(), + last_change_block: decoded_call.last_change_block.to_string(), + output_amounts_out: output_amounts_out.into_iter().map(|x| x.to_string()).collect::>(), + output_bpt_in: output_bpt_in.to_string(), + pool_id: Vec::from(decoded_call.pool_id), + protocol_swap_fee_percentage: decoded_call.protocol_swap_fee_percentage.to_string(), + recipient: decoded_call.recipient, + sender: decoded_call.sender, + user_data: decoded_call.user_data, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_query_joins.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::QueryJoin::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::QueryJoin::decode(call) { + Ok(decoded_call) => { + let (output_bpt_out, output_amounts_in) = match abi::pools_contract::functions::QueryJoin::output(&call.return_data) { + Ok((output_bpt_out, output_amounts_in)) => {(output_bpt_out, output_amounts_in)} + Err(_) => Default::default(), + }; + + Some(contract::PoolsQueryJoinCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + balances: decoded_call.balances.into_iter().map(|x| x.to_string()).collect::>(), + last_change_block: decoded_call.last_change_block.to_string(), + output_amounts_in: output_amounts_in.into_iter().map(|x| x.to_string()).collect::>(), + output_bpt_out: output_bpt_out.to_string(), + pool_id: Vec::from(decoded_call.pool_id), + protocol_swap_fee_percentage: decoded_call.protocol_swap_fee_percentage.to_string(), + recipient: decoded_call.recipient, + sender: decoded_call.sender, + user_data: decoded_call.user_data, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_set_asset_manager_pool_configs.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::SetAssetManagerPoolConfig::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::SetAssetManagerPoolConfig::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsSetAssetManagerPoolConfigCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + pool_config: decoded_call.pool_config, + token: decoded_call.token, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_set_swap_fee_percentages.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::SetSwapFeePercentage::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::SetSwapFeePercentage::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsSetSwapFeePercentageCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + swap_fee_percentage: decoded_call.swap_fee_percentage.to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_set_token_rate_cache_durations.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::SetTokenRateCacheDuration::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::SetTokenRateCacheDuration::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsSetTokenRateCacheDurationCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + duration: decoded_call.duration.to_string(), + token: decoded_call.token, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_start_amplification_parameter_updates.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::StartAmplificationParameterUpdate::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::StartAmplificationParameterUpdate::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsStartAmplificationParameterUpdateCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + end_time: decoded_call.end_time.to_string(), + raw_end_value: decoded_call.raw_end_value.to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_stop_amplification_parameter_updates.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::StopAmplificationParameterUpdate::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::StopAmplificationParameterUpdate::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsStopAmplificationParameterUpdateCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_transfers.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::Transfer::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::Transfer::decode(call) { + Ok(decoded_call) => { + let output_param0 = match abi::pools_contract::functions::Transfer::output(&call.return_data) { + Ok(output_param0) => {output_param0} + Err(_) => Default::default(), + }; + + Some(contract::PoolsTransferCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + amount: decoded_call.amount.to_string(), + output_param0: output_param0, + recipient: decoded_call.recipient, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_transfer_froms.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::TransferFrom::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::TransferFrom::decode(call) { + Ok(decoded_call) => { + let output_param0 = match abi::pools_contract::functions::TransferFrom::output(&call.return_data) { + Ok(output_param0) => {output_param0} + Err(_) => Default::default(), + }; + + Some(contract::PoolsTransferFromCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + amount: decoded_call.amount.to_string(), + output_param0: output_param0, + recipient: decoded_call.recipient, + sender: decoded_call.sender, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_unpauses.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::Unpause::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::Unpause::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsUnpauseCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_update_protocol_fee_percentage_caches.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::UpdateProtocolFeePercentageCache::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::UpdateProtocolFeePercentageCache::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsUpdateProtocolFeePercentageCacheCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + }) + }, + Err(_) => None, + } + }) + }) + .collect()); + calls.pools_call_update_token_rate_caches.append(&mut blk + .transactions() + .flat_map(|tx| { + tx.calls.iter() + .filter(|call| is_declared_dds_address(&call.address, call.begin_ordinal, dds_store) && abi::pools_contract::functions::UpdateTokenRateCache::match_call(call)) + .filter_map(|call| { + match abi::pools_contract::functions::UpdateTokenRateCache::decode(call) { + Ok(decoded_call) => { + Some(contract::PoolsUpdateTokenRateCacheCall { + call_tx_hash: Hex(&tx.hash).to_string(), + call_block_time: Some(blk.timestamp().to_owned()), + call_block_number: blk.number, + call_ordinal: call.begin_ordinal, + call_success: !call.state_reverted, + call_address: Hex(&call.address).to_string(), + token: decoded_call.token, + }) + }, + Err(_) => None, + } + }) + }) + .collect()); +} + + + +fn db_vault_out(events: &contract::Events, tables: &mut DatabaseChangeTables) { + // Loop over all the abis events to create table changes + events.vault_authorizer_changeds.iter().for_each(|evt| { + tables + .create_row("vault_authorizer_changed", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("new_authorizer", Hex(&evt.new_authorizer).to_string()); + }); + events.vault_external_balance_transfers.iter().for_each(|evt| { + tables + .create_row("vault_external_balance_transfer", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("amount", BigDecimal::from_str(&evt.amount).unwrap()) + .set("recipient", Hex(&evt.recipient).to_string()) + .set("sender", Hex(&evt.sender).to_string()) + .set("token", Hex(&evt.token).to_string()); + }); + events.vault_flash_loans.iter().for_each(|evt| { + tables + .create_row("vault_flash_loan", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("amount", BigDecimal::from_str(&evt.amount).unwrap()) + .set("fee_amount", BigDecimal::from_str(&evt.fee_amount).unwrap()) + .set("recipient", Hex(&evt.recipient).to_string()) + .set("token", Hex(&evt.token).to_string()); + }); + events.vault_internal_balance_changeds.iter().for_each(|evt| { + tables + .create_row("vault_internal_balance_changed", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("delta", BigDecimal::from_str(&evt.delta).unwrap()) + .set("token", Hex(&evt.token).to_string()) + .set("user", Hex(&evt.user).to_string()); + }); + events.vault_paused_state_changeds.iter().for_each(|evt| { + tables + .create_row("vault_paused_state_changed", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("paused", evt.paused); + }); + events.vault_pool_balance_changeds.iter().for_each(|evt| { + tables + .create_row("vault_pool_balance_changed", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set_psql_array("deltas", evt.deltas.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("liquidity_provider", Hex(&evt.liquidity_provider).to_string()) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set_psql_array("protocol_fee_amounts", evt.protocol_fee_amounts.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set_psql_array("tokens", evt.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()); + }); + events.vault_pool_balance_manageds.iter().for_each(|evt| { + tables + .create_row("vault_pool_balance_managed", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("asset_manager", Hex(&evt.asset_manager).to_string()) + .set("cash_delta", BigDecimal::from_str(&evt.cash_delta).unwrap()) + .set("managed_delta", BigDecimal::from_str(&evt.managed_delta).unwrap()) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("token", Hex(&evt.token).to_string()); + }); + events.vault_pool_registereds.iter().for_each(|evt| { + tables + .create_row("vault_pool_registered", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("pool_address", Hex(&evt.pool_address).to_string()) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("specialization", evt.specialization); + }); + events.vault_relayer_approval_changeds.iter().for_each(|evt| { + tables + .create_row("vault_relayer_approval_changed", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("approved", evt.approved) + .set("relayer", Hex(&evt.relayer).to_string()) + .set("sender", Hex(&evt.sender).to_string()); + }); + events.vault_swaps.iter().for_each(|evt| { + tables + .create_row("vault_swap", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("amount_in", BigDecimal::from_str(&evt.amount_in).unwrap()) + .set("amount_out", BigDecimal::from_str(&evt.amount_out).unwrap()) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("token_in", Hex(&evt.token_in).to_string()) + .set("token_out", Hex(&evt.token_out).to_string()); + }); + events.vault_tokens_deregistereds.iter().for_each(|evt| { + tables + .create_row("vault_tokens_deregistered", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set_psql_array("tokens", evt.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()); + }); + events.vault_tokens_registereds.iter().for_each(|evt| { + tables + .create_row("vault_tokens_registered", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set_psql_array("asset_managers", evt.asset_managers.iter().map(|x| Hex(&x).to_string()).collect::>()) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set_psql_array("tokens", evt.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()); + }); +} +fn db_vault_calls_out(calls: &contract::Calls, tables: &mut DatabaseChangeTables) { + // Loop over all the abis calls to create table changes + calls.vault_call_batch_swaps.iter().for_each(|call| { + tables + .create_row("vault_call_batch_swap", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set_psql_array("assets", call.assets.iter().map(|x| Hex(&x).to_string()).collect::>()) + .set("deadline", BigDecimal::from_str(&call.deadline).unwrap()) + .set("kind", call.kind) + .set_psql_array("limits", call.limits.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set_psql_array("output_asset_deltas", call.output_asset_deltas.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()); + }); + calls.vault_call_deregister_tokens.iter().for_each(|call| { + tables + .create_row("vault_call_deregister_tokens", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set_psql_array("tokens", call.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()); + }); + calls.vault_call_exit_pools.iter().for_each(|call| { + tables + .create_row("vault_call_exit_pool", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()); + }); + calls.vault_call_flash_loans.iter().for_each(|call| { + tables + .create_row("vault_call_flash_loan", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set_psql_array("amounts", call.amounts.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("recipient", Hex(&call.recipient).to_string()) + .set_psql_array("tokens", call.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()) + .set("user_data", Hex(&call.user_data).to_string()); + }); + calls.vault_call_join_pools.iter().for_each(|call| { + tables + .create_row("vault_call_join_pool", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()); + }); + calls.vault_call_manage_pool_balances.iter().for_each(|call| { + tables + .create_row("vault_call_manage_pool_balance", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success); + }); + calls.vault_call_manage_user_balances.iter().for_each(|call| { + tables + .create_row("vault_call_manage_user_balance", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success); + }); + calls.vault_call_query_batch_swaps.iter().for_each(|call| { + tables + .create_row("vault_call_query_batch_swap", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set_psql_array("assets", call.assets.iter().map(|x| Hex(&x).to_string()).collect::>()) + .set("kind", call.kind) + .set_psql_array("output_param0", call.output_param0.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()); + }); + calls.vault_call_register_pools.iter().for_each(|call| { + tables + .create_row("vault_call_register_pool", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("output_param0", Hex(&call.output_param0).to_string()) + .set("specialization", call.specialization); + }); + calls.vault_call_register_tokens.iter().for_each(|call| { + tables + .create_row("vault_call_register_tokens", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set_psql_array("asset_managers", call.asset_managers.iter().map(|x| Hex(&x).to_string()).collect::>()) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set_psql_array("tokens", call.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()); + }); + calls.vault_call_set_authorizers.iter().for_each(|call| { + tables + .create_row("vault_call_set_authorizer", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("new_authorizer", Hex(&call.new_authorizer).to_string()); + }); + calls.vault_call_set_pauseds.iter().for_each(|call| { + tables + .create_row("vault_call_set_paused", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("paused", call.paused); + }); + calls.vault_call_set_relayer_approvals.iter().for_each(|call| { + tables + .create_row("vault_call_set_relayer_approval", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("approved", call.approved) + .set("relayer", Hex(&call.relayer).to_string()) + .set("sender", Hex(&call.sender).to_string()); + }); + calls.vault_call_swaps.iter().for_each(|call| { + tables + .create_row("vault_call_swap", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("deadline", BigDecimal::from_str(&call.deadline).unwrap()) + .set("limit", BigDecimal::from_str(&call.limit).unwrap()) + .set("output_amount_calculated", BigDecimal::from_str(&call.output_amount_calculated).unwrap()); + }); +} +fn db_pools_out(events: &contract::Events, tables: &mut DatabaseChangeTables) { + // Loop over all the abis events to create table changes + events.pools_amp_update_starteds.iter().for_each(|evt| { + tables + .create_row("pools_amp_update_started", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("end_time", BigDecimal::from_str(&evt.end_time).unwrap()) + .set("end_value", BigDecimal::from_str(&evt.end_value).unwrap()) + .set("start_time", BigDecimal::from_str(&evt.start_time).unwrap()) + .set("start_value", BigDecimal::from_str(&evt.start_value).unwrap()); + }); + events.pools_amp_update_stoppeds.iter().for_each(|evt| { + tables + .create_row("pools_amp_update_stopped", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("current_value", BigDecimal::from_str(&evt.current_value).unwrap()); + }); + events.pools_approvals.iter().for_each(|evt| { + tables + .create_row("pools_approval", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("owner", Hex(&evt.owner).to_string()) + .set("spender", Hex(&evt.spender).to_string()) + .set("value", BigDecimal::from_str(&evt.value).unwrap()); + }); + events.pools_paused_state_changeds.iter().for_each(|evt| { + tables + .create_row("pools_paused_state_changed", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("paused", evt.paused); + }); + events.pools_protocol_fee_percentage_cache_updateds.iter().for_each(|evt| { + tables + .create_row("pools_protocol_fee_percentage_cache_updated", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("fee_type", BigDecimal::from_str(&evt.fee_type).unwrap()) + .set("protocol_fee_percentage", BigDecimal::from_str(&evt.protocol_fee_percentage).unwrap()); + }); + events.pools_recovery_mode_state_changeds.iter().for_each(|evt| { + tables + .create_row("pools_recovery_mode_state_changed", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("enabled", evt.enabled); + }); + events.pools_swap_fee_percentage_changeds.iter().for_each(|evt| { + tables + .create_row("pools_swap_fee_percentage_changed", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("swap_fee_percentage", BigDecimal::from_str(&evt.swap_fee_percentage).unwrap()); + }); + events.pools_token_rate_cache_updateds.iter().for_each(|evt| { + tables + .create_row("pools_token_rate_cache_updated", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("rate", BigDecimal::from_str(&evt.rate).unwrap()) + .set("token_index", BigDecimal::from_str(&evt.token_index).unwrap()); + }); + events.pools_token_rate_provider_sets.iter().for_each(|evt| { + tables + .create_row("pools_token_rate_provider_set", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("cache_duration", BigDecimal::from_str(&evt.cache_duration).unwrap()) + .set("provider", Hex(&evt.provider).to_string()) + .set("token_index", BigDecimal::from_str(&evt.token_index).unwrap()); + }); + events.pools_transfers.iter().for_each(|evt| { + tables + .create_row("pools_transfer", [("evt_tx_hash", evt.evt_tx_hash.to_string()),("evt_index", evt.evt_index.to_string())]) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("from", Hex(&evt.from).to_string()) + .set("to", Hex(&evt.to).to_string()) + .set("value", BigDecimal::from_str(&evt.value).unwrap()); + }); +} +fn db_pools_calls_out(calls: &contract::Calls, tables: &mut DatabaseChangeTables) { + // Loop over all the abis calls to create table changes + calls.pools_call_approves.iter().for_each(|call| { + tables + .create_row("pools_call_approve", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("amount", BigDecimal::from_str(&call.amount).unwrap()) + .set("output_param0", call.output_param0) + .set("spender", Hex(&call.spender).to_string()); + }); + calls.pools_call_decrease_allowances.iter().for_each(|call| { + tables + .create_row("pools_call_decrease_allowance", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("amount", BigDecimal::from_str(&call.amount).unwrap()) + .set("output_param0", call.output_param0) + .set("spender", Hex(&call.spender).to_string()); + }); + calls.pools_call_disable_recovery_modes.iter().for_each(|call| { + tables + .create_row("pools_call_disable_recovery_mode", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_enable_recovery_modes.iter().for_each(|call| { + tables + .create_row("pools_call_enable_recovery_mode", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_increase_allowances.iter().for_each(|call| { + tables + .create_row("pools_call_increase_allowance", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("added_value", BigDecimal::from_str(&call.added_value).unwrap()) + .set("output_param0", call.output_param0) + .set("spender", Hex(&call.spender).to_string()); + }); + calls.pools_call_on_exit_pools.iter().for_each(|call| { + tables + .create_row("pools_call_on_exit_pool", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set_psql_array("balances", call.balances.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("last_change_block", BigDecimal::from_str(&call.last_change_block).unwrap()) + .set_psql_array("output_param0", call.output_param0.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set_psql_array("output_param1", call.output_param1.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("protocol_swap_fee_percentage", BigDecimal::from_str(&call.protocol_swap_fee_percentage).unwrap()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()) + .set("user_data", Hex(&call.user_data).to_string()); + }); + calls.pools_call_on_join_pools.iter().for_each(|call| { + tables + .create_row("pools_call_on_join_pool", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set_psql_array("balances", call.balances.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("last_change_block", BigDecimal::from_str(&call.last_change_block).unwrap()) + .set_psql_array("output_param0", call.output_param0.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set_psql_array("output_param1", call.output_param1.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("protocol_swap_fee_percentage", BigDecimal::from_str(&call.protocol_swap_fee_percentage).unwrap()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()) + .set("user_data", Hex(&call.user_data).to_string()); + }); + calls.pools_call_on_swaps.iter().for_each(|call| { + tables + .create_row("pools_call_on_swap", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set_psql_array("balances", call.balances.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("index_in", BigDecimal::from_str(&call.index_in).unwrap()) + .set("index_out", BigDecimal::from_str(&call.index_out).unwrap()) + .set("output_param0", BigDecimal::from_str(&call.output_param0).unwrap()); + }); + calls.pools_call_pauses.iter().for_each(|call| { + tables + .create_row("pools_call_pause", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_permits.iter().for_each(|call| { + tables + .create_row("pools_call_permit", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("deadline", BigDecimal::from_str(&call.deadline).unwrap()) + .set("owner", Hex(&call.owner).to_string()) + .set("r", Hex(&call.r).to_string()) + .set("s", Hex(&call.s).to_string()) + .set("spender", Hex(&call.spender).to_string()) + .set("v", call.v) + .set("value", BigDecimal::from_str(&call.value).unwrap()); + }); + calls.pools_call_query_exits.iter().for_each(|call| { + tables + .create_row("pools_call_query_exit", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set_psql_array("balances", call.balances.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("last_change_block", BigDecimal::from_str(&call.last_change_block).unwrap()) + .set_psql_array("output_amounts_out", call.output_amounts_out.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("output_bpt_in", BigDecimal::from_str(&call.output_bpt_in).unwrap()) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("protocol_swap_fee_percentage", BigDecimal::from_str(&call.protocol_swap_fee_percentage).unwrap()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()) + .set("user_data", Hex(&call.user_data).to_string()); + }); + calls.pools_call_query_joins.iter().for_each(|call| { + tables + .create_row("pools_call_query_join", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set_psql_array("balances", call.balances.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("last_change_block", BigDecimal::from_str(&call.last_change_block).unwrap()) + .set_psql_array("output_amounts_in", call.output_amounts_in.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("output_bpt_out", BigDecimal::from_str(&call.output_bpt_out).unwrap()) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("protocol_swap_fee_percentage", BigDecimal::from_str(&call.protocol_swap_fee_percentage).unwrap()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()) + .set("user_data", Hex(&call.user_data).to_string()); + }); + calls.pools_call_set_asset_manager_pool_configs.iter().for_each(|call| { + tables + .create_row("pools_call_set_asset_manager_pool_config", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("pool_config", Hex(&call.pool_config).to_string()) + .set("token", Hex(&call.token).to_string()); + }); + calls.pools_call_set_swap_fee_percentages.iter().for_each(|call| { + tables + .create_row("pools_call_set_swap_fee_percentage", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("swap_fee_percentage", BigDecimal::from_str(&call.swap_fee_percentage).unwrap()); + }); + calls.pools_call_set_token_rate_cache_durations.iter().for_each(|call| { + tables + .create_row("pools_call_set_token_rate_cache_duration", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("duration", BigDecimal::from_str(&call.duration).unwrap()) + .set("token", Hex(&call.token).to_string()); + }); + calls.pools_call_start_amplification_parameter_updates.iter().for_each(|call| { + tables + .create_row("pools_call_start_amplification_parameter_update", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("end_time", BigDecimal::from_str(&call.end_time).unwrap()) + .set("raw_end_value", BigDecimal::from_str(&call.raw_end_value).unwrap()); + }); + calls.pools_call_stop_amplification_parameter_updates.iter().for_each(|call| { + tables + .create_row("pools_call_stop_amplification_parameter_update", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_transfers.iter().for_each(|call| { + tables + .create_row("pools_call_transfer", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("amount", BigDecimal::from_str(&call.amount).unwrap()) + .set("output_param0", call.output_param0) + .set("recipient", Hex(&call.recipient).to_string()); + }); + calls.pools_call_transfer_froms.iter().for_each(|call| { + tables + .create_row("pools_call_transfer_from", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("amount", BigDecimal::from_str(&call.amount).unwrap()) + .set("output_param0", call.output_param0) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()); + }); + calls.pools_call_unpauses.iter().for_each(|call| { + tables + .create_row("pools_call_unpause", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_update_protocol_fee_percentage_caches.iter().for_each(|call| { + tables + .create_row("pools_call_update_protocol_fee_percentage_cache", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_update_token_rate_caches.iter().for_each(|call| { + tables + .create_row("pools_call_update_token_rate_cache", [("call_tx_hash", call.call_tx_hash.to_string()),("call_ordinal", call.call_ordinal.to_string())]) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("token", Hex(&call.token).to_string()); + }); +} + + +fn graph_vault_out(events: &contract::Events, tables: &mut EntityChangesTables) { + // Loop over all the abis events to create table changes + events.vault_authorizer_changeds.iter().for_each(|evt| { + tables + .create_row("vault_authorizer_changed", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("new_authorizer", Hex(&evt.new_authorizer).to_string()); + }); + events.vault_external_balance_transfers.iter().for_each(|evt| { + tables + .create_row("vault_external_balance_transfer", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("amount", BigDecimal::from_str(&evt.amount).unwrap()) + .set("recipient", Hex(&evt.recipient).to_string()) + .set("sender", Hex(&evt.sender).to_string()) + .set("token", Hex(&evt.token).to_string()); + }); + events.vault_flash_loans.iter().for_each(|evt| { + tables + .create_row("vault_flash_loan", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("amount", BigDecimal::from_str(&evt.amount).unwrap()) + .set("fee_amount", BigDecimal::from_str(&evt.fee_amount).unwrap()) + .set("recipient", Hex(&evt.recipient).to_string()) + .set("token", Hex(&evt.token).to_string()); + }); + events.vault_internal_balance_changeds.iter().for_each(|evt| { + tables + .create_row("vault_internal_balance_changed", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("delta", BigDecimal::from_str(&evt.delta).unwrap()) + .set("token", Hex(&evt.token).to_string()) + .set("user", Hex(&evt.user).to_string()); + }); + events.vault_paused_state_changeds.iter().for_each(|evt| { + tables + .create_row("vault_paused_state_changed", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("paused", evt.paused); + }); + events.vault_pool_balance_changeds.iter().for_each(|evt| { + tables + .create_row("vault_pool_balance_changed", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("deltas", evt.deltas.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("liquidity_provider", Hex(&evt.liquidity_provider).to_string()) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("protocol_fee_amounts", evt.protocol_fee_amounts.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("tokens", evt.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()); + }); + events.vault_pool_balance_manageds.iter().for_each(|evt| { + tables + .create_row("vault_pool_balance_managed", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("asset_manager", Hex(&evt.asset_manager).to_string()) + .set("cash_delta", BigDecimal::from_str(&evt.cash_delta).unwrap()) + .set("managed_delta", BigDecimal::from_str(&evt.managed_delta).unwrap()) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("token", Hex(&evt.token).to_string()); + }); + events.vault_pool_registereds.iter().for_each(|evt| { + tables + .create_row("vault_pool_registered", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("pool_address", Hex(&evt.pool_address).to_string()) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("specialization", evt.specialization); + }); + events.vault_relayer_approval_changeds.iter().for_each(|evt| { + tables + .create_row("vault_relayer_approval_changed", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("approved", evt.approved) + .set("relayer", Hex(&evt.relayer).to_string()) + .set("sender", Hex(&evt.sender).to_string()); + }); + events.vault_swaps.iter().for_each(|evt| { + tables + .create_row("vault_swap", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("amount_in", BigDecimal::from_str(&evt.amount_in).unwrap()) + .set("amount_out", BigDecimal::from_str(&evt.amount_out).unwrap()) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("token_in", Hex(&evt.token_in).to_string()) + .set("token_out", Hex(&evt.token_out).to_string()); + }); + events.vault_tokens_deregistereds.iter().for_each(|evt| { + tables + .create_row("vault_tokens_deregistered", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("tokens", evt.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()); + }); + events.vault_tokens_registereds.iter().for_each(|evt| { + tables + .create_row("vault_tokens_registered", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("asset_managers", evt.asset_managers.iter().map(|x| Hex(&x).to_string()).collect::>()) + .set("pool_id", Hex(&evt.pool_id).to_string()) + .set("tokens", evt.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()); + }); +} +fn graph_vault_calls_out(calls: &contract::Calls, tables: &mut EntityChangesTables) { + // Loop over all the abis calls to create table changes + calls.vault_call_batch_swaps.iter().for_each(|call| { + tables + .create_row("vault_call_batch_swap", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("assets", call.assets.iter().map(|x| Hex(&x).to_string()).collect::>()) + .set("deadline", BigDecimal::from_str(&call.deadline).unwrap()) + .set("kind", call.kind) + .set("limits", call.limits.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("output_asset_deltas", call.output_asset_deltas.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()); + }); + calls.vault_call_deregister_tokens.iter().for_each(|call| { + tables + .create_row("vault_call_deregister_tokens", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("tokens", call.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()); + }); + calls.vault_call_exit_pools.iter().for_each(|call| { + tables + .create_row("vault_call_exit_pool", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()); + }); + calls.vault_call_flash_loans.iter().for_each(|call| { + tables + .create_row("vault_call_flash_loan", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("amounts", call.amounts.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("tokens", call.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()) + .set("user_data", Hex(&call.user_data).to_string()); + }); + calls.vault_call_join_pools.iter().for_each(|call| { + tables + .create_row("vault_call_join_pool", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()); + }); + calls.vault_call_manage_pool_balances.iter().for_each(|call| { + tables + .create_row("vault_call_manage_pool_balance", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success); + }); + calls.vault_call_manage_user_balances.iter().for_each(|call| { + tables + .create_row("vault_call_manage_user_balance", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success); + }); + calls.vault_call_query_batch_swaps.iter().for_each(|call| { + tables + .create_row("vault_call_query_batch_swap", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("assets", call.assets.iter().map(|x| Hex(&x).to_string()).collect::>()) + .set("kind", call.kind) + .set("output_param0", call.output_param0.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()); + }); + calls.vault_call_register_pools.iter().for_each(|call| { + tables + .create_row("vault_call_register_pool", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("output_param0", Hex(&call.output_param0).to_string()) + .set("specialization", call.specialization); + }); + calls.vault_call_register_tokens.iter().for_each(|call| { + tables + .create_row("vault_call_register_tokens", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("asset_managers", call.asset_managers.iter().map(|x| Hex(&x).to_string()).collect::>()) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("tokens", call.tokens.iter().map(|x| Hex(&x).to_string()).collect::>()); + }); + calls.vault_call_set_authorizers.iter().for_each(|call| { + tables + .create_row("vault_call_set_authorizer", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("new_authorizer", Hex(&call.new_authorizer).to_string()); + }); + calls.vault_call_set_pauseds.iter().for_each(|call| { + tables + .create_row("vault_call_set_paused", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("paused", call.paused); + }); + calls.vault_call_set_relayer_approvals.iter().for_each(|call| { + tables + .create_row("vault_call_set_relayer_approval", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("approved", call.approved) + .set("relayer", Hex(&call.relayer).to_string()) + .set("sender", Hex(&call.sender).to_string()); + }); + calls.vault_call_swaps.iter().for_each(|call| { + tables + .create_row("vault_call_swap", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("deadline", BigDecimal::from_str(&call.deadline).unwrap()) + .set("limit", BigDecimal::from_str(&call.limit).unwrap()) + .set("output_amount_calculated", BigDecimal::from_str(&call.output_amount_calculated).unwrap()); + }); + } +fn graph_pools_out(events: &contract::Events, tables: &mut EntityChangesTables) { + // Loop over all the abis events to create table changes + events.pools_amp_update_starteds.iter().for_each(|evt| { + tables + .create_row("pools_amp_update_started", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("end_time", BigDecimal::from_str(&evt.end_time).unwrap()) + .set("end_value", BigDecimal::from_str(&evt.end_value).unwrap()) + .set("start_time", BigDecimal::from_str(&evt.start_time).unwrap()) + .set("start_value", BigDecimal::from_str(&evt.start_value).unwrap()); + }); + events.pools_amp_update_stoppeds.iter().for_each(|evt| { + tables + .create_row("pools_amp_update_stopped", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("current_value", BigDecimal::from_str(&evt.current_value).unwrap()); + }); + events.pools_approvals.iter().for_each(|evt| { + tables + .create_row("pools_approval", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("owner", Hex(&evt.owner).to_string()) + .set("spender", Hex(&evt.spender).to_string()) + .set("value", BigDecimal::from_str(&evt.value).unwrap()); + }); + events.pools_paused_state_changeds.iter().for_each(|evt| { + tables + .create_row("pools_paused_state_changed", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("paused", evt.paused); + }); + events.pools_protocol_fee_percentage_cache_updateds.iter().for_each(|evt| { + tables + .create_row("pools_protocol_fee_percentage_cache_updated", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("fee_type", BigDecimal::from_str(&evt.fee_type).unwrap()) + .set("protocol_fee_percentage", BigDecimal::from_str(&evt.protocol_fee_percentage).unwrap()); + }); + events.pools_recovery_mode_state_changeds.iter().for_each(|evt| { + tables + .create_row("pools_recovery_mode_state_changed", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("enabled", evt.enabled); + }); + events.pools_swap_fee_percentage_changeds.iter().for_each(|evt| { + tables + .create_row("pools_swap_fee_percentage_changed", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("swap_fee_percentage", BigDecimal::from_str(&evt.swap_fee_percentage).unwrap()); + }); + events.pools_token_rate_cache_updateds.iter().for_each(|evt| { + tables + .create_row("pools_token_rate_cache_updated", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("rate", BigDecimal::from_str(&evt.rate).unwrap()) + .set("token_index", BigDecimal::from_str(&evt.token_index).unwrap()); + }); + events.pools_token_rate_provider_sets.iter().for_each(|evt| { + tables + .create_row("pools_token_rate_provider_set", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("cache_duration", BigDecimal::from_str(&evt.cache_duration).unwrap()) + .set("provider", Hex(&evt.provider).to_string()) + .set("token_index", BigDecimal::from_str(&evt.token_index).unwrap()); + }); + events.pools_transfers.iter().for_each(|evt| { + tables + .create_row("pools_transfer", format!("{}-{}", evt.evt_tx_hash, evt.evt_index)) + .set("evt_tx_hash", &evt.evt_tx_hash) + .set("evt_index", evt.evt_index) + .set("evt_block_time", evt.evt_block_time.as_ref().unwrap()) + .set("evt_block_number", evt.evt_block_number) + .set("evt_address", &evt.evt_address) + .set("from", Hex(&evt.from).to_string()) + .set("to", Hex(&evt.to).to_string()) + .set("value", BigDecimal::from_str(&evt.value).unwrap()); + }); +} +fn graph_pools_calls_out(calls: &contract::Calls, tables: &mut EntityChangesTables) { + // Loop over all the abis calls to create table changes + calls.pools_call_approves.iter().for_each(|call| { + tables + .create_row("pools_call_approve", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("amount", BigDecimal::from_str(&call.amount).unwrap()) + .set("output_param0", call.output_param0) + .set("spender", Hex(&call.spender).to_string()); + }); + calls.pools_call_decrease_allowances.iter().for_each(|call| { + tables + .create_row("pools_call_decrease_allowance", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("amount", BigDecimal::from_str(&call.amount).unwrap()) + .set("output_param0", call.output_param0) + .set("spender", Hex(&call.spender).to_string()); + }); + calls.pools_call_disable_recovery_modes.iter().for_each(|call| { + tables + .create_row("pools_call_disable_recovery_mode", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_enable_recovery_modes.iter().for_each(|call| { + tables + .create_row("pools_call_enable_recovery_mode", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_increase_allowances.iter().for_each(|call| { + tables + .create_row("pools_call_increase_allowance", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("added_value", BigDecimal::from_str(&call.added_value).unwrap()) + .set("output_param0", call.output_param0) + .set("spender", Hex(&call.spender).to_string()); + }); + calls.pools_call_on_exit_pools.iter().for_each(|call| { + tables + .create_row("pools_call_on_exit_pool", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("balances", call.balances.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("last_change_block", BigDecimal::from_str(&call.last_change_block).unwrap()) + .set("output_param0", call.output_param0.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("output_param1", call.output_param1.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("protocol_swap_fee_percentage", BigDecimal::from_str(&call.protocol_swap_fee_percentage).unwrap()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()) + .set("user_data", Hex(&call.user_data).to_string()); + }); + calls.pools_call_on_join_pools.iter().for_each(|call| { + tables + .create_row("pools_call_on_join_pool", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("balances", call.balances.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("last_change_block", BigDecimal::from_str(&call.last_change_block).unwrap()) + .set("output_param0", call.output_param0.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("output_param1", call.output_param1.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("protocol_swap_fee_percentage", BigDecimal::from_str(&call.protocol_swap_fee_percentage).unwrap()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()) + .set("user_data", Hex(&call.user_data).to_string()); + }); + calls.pools_call_on_swaps.iter().for_each(|call| { + tables + .create_row("pools_call_on_swap", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("balances", call.balances.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("index_in", BigDecimal::from_str(&call.index_in).unwrap()) + .set("index_out", BigDecimal::from_str(&call.index_out).unwrap()) + .set("output_param0", BigDecimal::from_str(&call.output_param0).unwrap()); + }); + calls.pools_call_pauses.iter().for_each(|call| { + tables + .create_row("pools_call_pause", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_permits.iter().for_each(|call| { + tables + .create_row("pools_call_permit", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("deadline", BigDecimal::from_str(&call.deadline).unwrap()) + .set("owner", Hex(&call.owner).to_string()) + .set("r", Hex(&call.r).to_string()) + .set("s", Hex(&call.s).to_string()) + .set("spender", Hex(&call.spender).to_string()) + .set("v", call.v) + .set("value", BigDecimal::from_str(&call.value).unwrap()); + }); + calls.pools_call_query_exits.iter().for_each(|call| { + tables + .create_row("pools_call_query_exit", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("balances", call.balances.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("last_change_block", BigDecimal::from_str(&call.last_change_block).unwrap()) + .set("output_amounts_out", call.output_amounts_out.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("output_bpt_in", BigDecimal::from_str(&call.output_bpt_in).unwrap()) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("protocol_swap_fee_percentage", BigDecimal::from_str(&call.protocol_swap_fee_percentage).unwrap()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()) + .set("user_data", Hex(&call.user_data).to_string()); + }); + calls.pools_call_query_joins.iter().for_each(|call| { + tables + .create_row("pools_call_query_join", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("balances", call.balances.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("last_change_block", BigDecimal::from_str(&call.last_change_block).unwrap()) + .set("output_amounts_in", call.output_amounts_in.iter().map(|x| BigDecimal::from_str(&x).unwrap()).collect::>()) + .set("output_bpt_out", BigDecimal::from_str(&call.output_bpt_out).unwrap()) + .set("pool_id", Hex(&call.pool_id).to_string()) + .set("protocol_swap_fee_percentage", BigDecimal::from_str(&call.protocol_swap_fee_percentage).unwrap()) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()) + .set("user_data", Hex(&call.user_data).to_string()); + }); + calls.pools_call_set_asset_manager_pool_configs.iter().for_each(|call| { + tables + .create_row("pools_call_set_asset_manager_pool_config", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("pool_config", Hex(&call.pool_config).to_string()) + .set("token", Hex(&call.token).to_string()); + }); + calls.pools_call_set_swap_fee_percentages.iter().for_each(|call| { + tables + .create_row("pools_call_set_swap_fee_percentage", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("swap_fee_percentage", BigDecimal::from_str(&call.swap_fee_percentage).unwrap()); + }); + calls.pools_call_set_token_rate_cache_durations.iter().for_each(|call| { + tables + .create_row("pools_call_set_token_rate_cache_duration", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("duration", BigDecimal::from_str(&call.duration).unwrap()) + .set("token", Hex(&call.token).to_string()); + }); + calls.pools_call_start_amplification_parameter_updates.iter().for_each(|call| { + tables + .create_row("pools_call_start_amplification_parameter_update", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("end_time", BigDecimal::from_str(&call.end_time).unwrap()) + .set("raw_end_value", BigDecimal::from_str(&call.raw_end_value).unwrap()); + }); + calls.pools_call_stop_amplification_parameter_updates.iter().for_each(|call| { + tables + .create_row("pools_call_stop_amplification_parameter_update", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_transfers.iter().for_each(|call| { + tables + .create_row("pools_call_transfer", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("amount", BigDecimal::from_str(&call.amount).unwrap()) + .set("output_param0", call.output_param0) + .set("recipient", Hex(&call.recipient).to_string()); + }); + calls.pools_call_transfer_froms.iter().for_each(|call| { + tables + .create_row("pools_call_transfer_from", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("amount", BigDecimal::from_str(&call.amount).unwrap()) + .set("output_param0", call.output_param0) + .set("recipient", Hex(&call.recipient).to_string()) + .set("sender", Hex(&call.sender).to_string()); + }); + calls.pools_call_unpauses.iter().for_each(|call| { + tables + .create_row("pools_call_unpause", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_update_protocol_fee_percentage_caches.iter().for_each(|call| { + tables + .create_row("pools_call_update_protocol_fee_percentage_cache", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address); + }); + calls.pools_call_update_token_rate_caches.iter().for_each(|call| { + tables + .create_row("pools_call_update_token_rate_cache", format!("{}-{}", call.call_tx_hash, call.call_ordinal)) + .set("call_tx_hash", &call.call_tx_hash) + .set("call_ordinal", call.call_ordinal) + .set("call_block_time", call.call_block_time.as_ref().unwrap()) + .set("call_block_number", call.call_block_number) + .set("call_success", call.call_success) + .set("call_address", &call.call_address) + .set("token", Hex(&call.token).to_string()); + }); + } +#[substreams::handlers::store] +fn store_vault_pools_created(blk: eth::Block, store: StoreSetInt64) { + for rcpt in blk.receipts() { + for log in rcpt + .receipt + .logs + .iter() + .filter(|log| log.address == VAULT_TRACKED_CONTRACT) + { + if let Some(event) = abi::vault_contract::events::PoolRegistered::match_and_decode(log) { + store.set(log.ordinal, Hex(event.pool_address).to_string(), &1); + } + } + } +} + +#[substreams::handlers::map] +fn map_events( + blk: eth::Block, + store_pools: StoreGetInt64, +) -> Result { + let mut events = contract::Events::default(); + map_vault_events(&blk, &mut events); + map_pools_events(&blk, &store_pools, &mut events); + Ok(events) +} +#[substreams::handlers::map] +fn map_calls( + blk: eth::Block, + store_pools: StoreGetInt64, +) -> Result { + let mut calls = contract::Calls::default(); + map_vault_calls(&blk, &mut calls); + map_pools_calls(&blk, &store_pools, &mut calls); + Ok(calls) +} + +#[substreams::handlers::map] +fn db_out(events: contract::Events, calls: contract::Calls) -> Result { + // Initialize Database Changes container + let mut tables = DatabaseChangeTables::new(); + db_vault_out(&events, &mut tables); + db_vault_calls_out(&calls, &mut tables); + db_pools_out(&events, &mut tables); + db_pools_calls_out(&calls, &mut tables); + Ok(tables.to_database_changes()) +} + +#[substreams::handlers::map] +fn graph_out(events: contract::Events, calls: contract::Calls) -> Result { + // Initialize Database Changes container + let mut tables = EntityChangesTables::new(); + graph_vault_out(&events, &mut tables); + graph_vault_calls_out(&calls, &mut tables); + graph_pools_out(&events, &mut tables); + graph_pools_calls_out(&calls, &mut tables); + Ok(tables.to_entity_changes()) +} diff --git a/sql/balancer_v2/src/pb/contract.v1.rs b/sql/balancer_v2/src/pb/contract.v1.rs new file mode 100644 index 0000000..e348783 --- /dev/null +++ b/sql/balancer_v2/src/pb/contract.v1.rs @@ -0,0 +1,1286 @@ +// @generated +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Events { + #[prost(message, repeated, tag="1")] + pub vault_authorizer_changeds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="2")] + pub vault_external_balance_transfers: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="3")] + pub vault_flash_loans: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="4")] + pub vault_internal_balance_changeds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="5")] + pub vault_paused_state_changeds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="6")] + pub vault_pool_balance_changeds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="7")] + pub vault_pool_balance_manageds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="8")] + pub vault_pool_registereds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="9")] + pub vault_relayer_approval_changeds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="10")] + pub vault_swaps: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="11")] + pub vault_tokens_deregistereds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="12")] + pub vault_tokens_registereds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="13")] + pub pools_amp_update_starteds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="14")] + pub pools_amp_update_stoppeds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="15")] + pub pools_approvals: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="16")] + pub pools_paused_state_changeds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="17")] + pub pools_protocol_fee_percentage_cache_updateds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="18")] + pub pools_recovery_mode_state_changeds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="19")] + pub pools_swap_fee_percentage_changeds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="20")] + pub pools_token_rate_cache_updateds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="21")] + pub pools_token_rate_provider_sets: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="22")] + pub pools_transfers: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Calls { + #[prost(message, repeated, tag="1")] + pub vault_call_batch_swaps: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="2")] + pub vault_call_deregister_tokens: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="3")] + pub vault_call_exit_pools: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="4")] + pub vault_call_flash_loans: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="5")] + pub vault_call_join_pools: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="6")] + pub vault_call_manage_pool_balances: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="7")] + pub vault_call_manage_user_balances: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="8")] + pub vault_call_query_batch_swaps: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="9")] + pub vault_call_register_pools: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="10")] + pub vault_call_register_tokens: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="11")] + pub vault_call_set_authorizers: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="12")] + pub vault_call_set_pauseds: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="13")] + pub vault_call_set_relayer_approvals: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="14")] + pub vault_call_swaps: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="15")] + pub pools_call_approves: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="16")] + pub pools_call_decrease_allowances: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="17")] + pub pools_call_disable_recovery_modes: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="18")] + pub pools_call_enable_recovery_modes: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="19")] + pub pools_call_increase_allowances: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="20")] + pub pools_call_on_exit_pools: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="21")] + pub pools_call_on_join_pools: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="22")] + pub pools_call_on_swaps: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="23")] + pub pools_call_pauses: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="24")] + pub pools_call_permits: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="25")] + pub pools_call_query_exits: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="26")] + pub pools_call_query_joins: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="27")] + pub pools_call_set_asset_manager_pool_configs: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="28")] + pub pools_call_set_swap_fee_percentages: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="29")] + pub pools_call_set_token_rate_cache_durations: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="30")] + pub pools_call_start_amplification_parameter_updates: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="31")] + pub pools_call_stop_amplification_parameter_updates: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="32")] + pub pools_call_transfers: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="33")] + pub pools_call_transfer_froms: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="34")] + pub pools_call_unpauses: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="35")] + pub pools_call_update_protocol_fee_percentage_caches: ::prost::alloc::vec::Vec, + #[prost(message, repeated, tag="36")] + pub pools_call_update_token_rate_caches: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultAuthorizerChanged { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub new_authorizer: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultExternalBalanceTransfer { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub token: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="6")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="7")] + pub recipient: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub amount: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultFlashLoan { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub recipient: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="6")] + pub token: ::prost::alloc::vec::Vec, + #[prost(string, tag="7")] + pub amount: ::prost::alloc::string::String, + #[prost(string, tag="8")] + pub fee_amount: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultInternalBalanceChanged { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub user: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="6")] + pub token: ::prost::alloc::vec::Vec, + #[prost(string, tag="7")] + pub delta: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultPausedStateChanged { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bool, tag="5")] + pub paused: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultPoolBalanceChanged { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="6")] + pub liquidity_provider: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", repeated, tag="7")] + pub tokens: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(string, repeated, tag="8")] + pub deltas: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, repeated, tag="9")] + pub protocol_fee_amounts: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultPoolBalanceManaged { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="6")] + pub asset_manager: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="7")] + pub token: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub cash_delta: ::prost::alloc::string::String, + #[prost(string, tag="9")] + pub managed_delta: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultPoolRegistered { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="6")] + pub pool_address: ::prost::alloc::vec::Vec, + #[prost(uint64, tag="7")] + pub specialization: u64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultRelayerApprovalChanged { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub relayer: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="6")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bool, tag="7")] + pub approved: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultSwap { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="6")] + pub token_in: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="7")] + pub token_out: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub amount_in: ::prost::alloc::string::String, + #[prost(string, tag="9")] + pub amount_out: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultTokensDeregistered { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", repeated, tag="6")] + pub tokens: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultTokensRegistered { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(bytes="vec", tag="5")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", repeated, tag="6")] + pub tokens: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bytes="vec", repeated, tag="7")] + pub asset_managers: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultBatchSwapCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(uint64, tag="6")] + pub kind: u64, + #[prost(bytes="vec", repeated, tag="7")] + pub assets: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(string, repeated, tag="8")] + pub limits: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, tag="9")] + pub deadline: ::prost::alloc::string::String, + #[prost(string, repeated, tag="10")] + pub output_asset_deltas: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultDeregisterTokensCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(bytes="vec", tag="6")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", repeated, tag="7")] + pub tokens: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultExitPoolCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(bytes="vec", tag="6")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="7")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="8")] + pub recipient: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultFlashLoanCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(bytes="vec", tag="6")] + pub recipient: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", repeated, tag="7")] + pub tokens: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(string, repeated, tag="8")] + pub amounts: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(bytes="vec", tag="9")] + pub user_data: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultJoinPoolCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(bytes="vec", tag="6")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="7")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="8")] + pub recipient: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultManagePoolBalanceCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultManageUserBalanceCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultQueryBatchSwapCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(uint64, tag="6")] + pub kind: u64, + #[prost(bytes="vec", repeated, tag="7")] + pub assets: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(string, repeated, tag="8")] + pub output_param0: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultRegisterPoolCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(uint64, tag="6")] + pub specialization: u64, + #[prost(bytes="vec", tag="7")] + pub output_param0: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultRegisterTokensCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(bytes="vec", tag="6")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", repeated, tag="7")] + pub tokens: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, + #[prost(bytes="vec", repeated, tag="8")] + pub asset_managers: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultSetAuthorizerCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(bytes="vec", tag="6")] + pub new_authorizer: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultSetPausedCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(bool, tag="6")] + pub paused: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultSetRelayerApprovalCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(bytes="vec", tag="6")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="7")] + pub relayer: ::prost::alloc::vec::Vec, + #[prost(bool, tag="8")] + pub approved: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct VaultSwapCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub limit: ::prost::alloc::string::String, + #[prost(string, tag="7")] + pub deadline: ::prost::alloc::string::String, + #[prost(string, tag="8")] + pub output_amount_calculated: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsAmpUpdateStarted { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(string, tag="5")] + pub evt_address: ::prost::alloc::string::String, + #[prost(string, tag="6")] + pub start_value: ::prost::alloc::string::String, + #[prost(string, tag="7")] + pub end_value: ::prost::alloc::string::String, + #[prost(string, tag="8")] + pub start_time: ::prost::alloc::string::String, + #[prost(string, tag="9")] + pub end_time: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsAmpUpdateStopped { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(string, tag="5")] + pub evt_address: ::prost::alloc::string::String, + #[prost(string, tag="6")] + pub current_value: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsApproval { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(string, tag="5")] + pub evt_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="6")] + pub owner: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="7")] + pub spender: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub value: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsPausedStateChanged { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(string, tag="5")] + pub evt_address: ::prost::alloc::string::String, + #[prost(bool, tag="6")] + pub paused: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsProtocolFeePercentageCacheUpdated { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(string, tag="5")] + pub evt_address: ::prost::alloc::string::String, + #[prost(string, tag="6")] + pub fee_type: ::prost::alloc::string::String, + #[prost(string, tag="7")] + pub protocol_fee_percentage: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsRecoveryModeStateChanged { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(string, tag="5")] + pub evt_address: ::prost::alloc::string::String, + #[prost(bool, tag="6")] + pub enabled: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsSwapFeePercentageChanged { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(string, tag="5")] + pub evt_address: ::prost::alloc::string::String, + #[prost(string, tag="6")] + pub swap_fee_percentage: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsTokenRateCacheUpdated { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(string, tag="5")] + pub evt_address: ::prost::alloc::string::String, + #[prost(string, tag="6")] + pub token_index: ::prost::alloc::string::String, + #[prost(string, tag="7")] + pub rate: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsTokenRateProviderSet { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(string, tag="5")] + pub evt_address: ::prost::alloc::string::String, + #[prost(string, tag="6")] + pub token_index: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub provider: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub cache_duration: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsTransfer { + #[prost(string, tag="1")] + pub evt_tx_hash: ::prost::alloc::string::String, + #[prost(uint32, tag="2")] + pub evt_index: u32, + #[prost(message, optional, tag="3")] + pub evt_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="4")] + pub evt_block_number: u64, + #[prost(string, tag="5")] + pub evt_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="6")] + pub from: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="7")] + pub to: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub value: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsApproveCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub spender: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub amount: ::prost::alloc::string::String, + #[prost(bool, tag="9")] + pub output_param0: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsDecreaseAllowanceCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub spender: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub amount: ::prost::alloc::string::String, + #[prost(bool, tag="9")] + pub output_param0: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsDisableRecoveryModeCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsEnableRecoveryModeCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsIncreaseAllowanceCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub spender: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub added_value: ::prost::alloc::string::String, + #[prost(bool, tag="9")] + pub output_param0: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsOnExitPoolCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="8")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="9")] + pub recipient: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="10")] + pub balances: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, tag="11")] + pub last_change_block: ::prost::alloc::string::String, + #[prost(string, tag="12")] + pub protocol_swap_fee_percentage: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="13")] + pub user_data: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="14")] + pub output_param0: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, repeated, tag="15")] + pub output_param1: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsOnJoinPoolCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="8")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="9")] + pub recipient: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="10")] + pub balances: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, tag="11")] + pub last_change_block: ::prost::alloc::string::String, + #[prost(string, tag="12")] + pub protocol_swap_fee_percentage: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="13")] + pub user_data: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="14")] + pub output_param0: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, repeated, tag="15")] + pub output_param1: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsOnSwapCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(string, repeated, tag="7")] + pub balances: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, tag="8")] + pub index_in: ::prost::alloc::string::String, + #[prost(string, tag="9")] + pub index_out: ::prost::alloc::string::String, + #[prost(string, tag="10")] + pub output_param0: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsPauseCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsPermitCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub owner: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="8")] + pub spender: ::prost::alloc::vec::Vec, + #[prost(string, tag="9")] + pub value: ::prost::alloc::string::String, + #[prost(string, tag="10")] + pub deadline: ::prost::alloc::string::String, + #[prost(uint64, tag="11")] + pub v: u64, + #[prost(bytes="vec", tag="12")] + pub r: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="13")] + pub s: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsQueryExitCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="8")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="9")] + pub recipient: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="10")] + pub balances: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, tag="11")] + pub last_change_block: ::prost::alloc::string::String, + #[prost(string, tag="12")] + pub protocol_swap_fee_percentage: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="13")] + pub user_data: ::prost::alloc::vec::Vec, + #[prost(string, tag="14")] + pub output_bpt_in: ::prost::alloc::string::String, + #[prost(string, repeated, tag="15")] + pub output_amounts_out: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsQueryJoinCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub pool_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="8")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="9")] + pub recipient: ::prost::alloc::vec::Vec, + #[prost(string, repeated, tag="10")] + pub balances: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, + #[prost(string, tag="11")] + pub last_change_block: ::prost::alloc::string::String, + #[prost(string, tag="12")] + pub protocol_swap_fee_percentage: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="13")] + pub user_data: ::prost::alloc::vec::Vec, + #[prost(string, tag="14")] + pub output_bpt_out: ::prost::alloc::string::String, + #[prost(string, repeated, tag="15")] + pub output_amounts_in: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsSetAssetManagerPoolConfigCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub token: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="8")] + pub pool_config: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsSetSwapFeePercentageCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(string, tag="7")] + pub swap_fee_percentage: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsSetTokenRateCacheDurationCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub token: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub duration: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsStartAmplificationParameterUpdateCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(string, tag="7")] + pub raw_end_value: ::prost::alloc::string::String, + #[prost(string, tag="8")] + pub end_time: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsStopAmplificationParameterUpdateCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsTransferCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub recipient: ::prost::alloc::vec::Vec, + #[prost(string, tag="8")] + pub amount: ::prost::alloc::string::String, + #[prost(bool, tag="9")] + pub output_param0: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsTransferFromCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub sender: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="8")] + pub recipient: ::prost::alloc::vec::Vec, + #[prost(string, tag="9")] + pub amount: ::prost::alloc::string::String, + #[prost(bool, tag="10")] + pub output_param0: bool, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsUnpauseCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsUpdateProtocolFeePercentageCacheCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct PoolsUpdateTokenRateCacheCall { + #[prost(string, tag="1")] + pub call_tx_hash: ::prost::alloc::string::String, + #[prost(message, optional, tag="2")] + pub call_block_time: ::core::option::Option<::prost_types::Timestamp>, + #[prost(uint64, tag="3")] + pub call_block_number: u64, + #[prost(uint64, tag="4")] + pub call_ordinal: u64, + #[prost(bool, tag="5")] + pub call_success: bool, + #[prost(string, tag="6")] + pub call_address: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="7")] + pub token: ::prost::alloc::vec::Vec, +} +// @@protoc_insertion_point(module) diff --git a/sql/balancer_v2/src/pb/mod.rs b/sql/balancer_v2/src/pb/mod.rs new file mode 100644 index 0000000..611ea83 --- /dev/null +++ b/sql/balancer_v2/src/pb/mod.rs @@ -0,0 +1,8 @@ +// @generated +pub mod contract { + // @@protoc_insertion_point(attribute:contract.v1) + pub mod v1 { + include!("contract.v1.rs"); + // @@protoc_insertion_point(contract.v1) + } +} diff --git a/sql/balancer_v2/subgraph.yaml b/sql/balancer_v2/subgraph.yaml new file mode 100644 index 0000000..dd1dff4 --- /dev/null +++ b/sql/balancer_v2/subgraph.yaml @@ -0,0 +1,17 @@ +specVersion: 0.0.6 +description: balancer-v2 substreams based subgraph +repository: # fill in with git remote url +schema: + file: ./schema.graphql + +dataSources: + - kind: substreams + name: balancer-v2 + network: mainnet + source: + package: + moduleName: graph_out + file: balancer-v2-v0.1.0.spkg + mapping: + kind: substreams/graph-entities + apiVersion: 0.0.5 diff --git a/sql/balancer_v2/substreams.clickhouse.yaml b/sql/balancer_v2/substreams.clickhouse.yaml new file mode 100644 index 0000000..d5f674b --- /dev/null +++ b/sql/balancer_v2/substreams.clickhouse.yaml @@ -0,0 +1,79 @@ +specVersion: v0.1.0 +package: + name: balancer_v2 + version: v0.1.0 + +imports: + 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 + entity: https://github.com/streamingfast/substreams-entity-change/releases/download/v1.1.0/substreams-entity-change-v1.1.0.spkg + +protobuf: + files: + - contract.proto + importPaths: + - ./proto + +binaries: + default: + type: wasm/rust-v1 + file: ./target/wasm32-unknown-unknown/release/substreams.wasm + +modules: + - name: store_vault_pools_created + kind: store + initialBlock: 12272146 + updatePolicy: set + valueType: proto:dynamic_datasource + inputs: + - source: sf.ethereum.type.v2.Block + + - name: map_events + kind: map + initialBlock: 12272146 + inputs: + - source: sf.ethereum.type.v2.Block + - store: store_vault_pools_created + output: + type: proto:contract.v1.Events + + - name: map_calls + kind: map + initialBlock: 12272146 + inputs: + - source: sf.ethereum.type.v2.Block + - store: store_vault_pools_created + output: + type: proto:contract.v1.Calls + + - name: db_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + - map: map_calls + output: + type: proto:sf.substreams.sink.database.v1.DatabaseChanges + + - name: graph_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + - map: map_calls + output: + type: proto:sf.substreams.entity.v1.EntityChanges + +network: mainnet + +sink: + module: db_out + type: sf.substreams.sink.sql.v1.Service + config: + schema: "./schema.clickhouse.sql" + engine: clickhouse + postgraphile_frontend: + enabled: false + rest_frontend: + enabled: false diff --git a/sql/balancer_v2/substreams.sql.yaml b/sql/balancer_v2/substreams.sql.yaml new file mode 100644 index 0000000..a86be3a --- /dev/null +++ b/sql/balancer_v2/substreams.sql.yaml @@ -0,0 +1,77 @@ +specVersion: v0.1.0 +package: + name: balancer_v2 + version: v0.1.0 + +imports: + 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 + entity: https://github.com/streamingfast/substreams-entity-change/releases/download/v1.1.0/substreams-entity-change-v1.1.0.spkg + +protobuf: + files: + - contract.proto + importPaths: + - ./proto + +binaries: + default: + type: wasm/rust-v1 + file: ../../target/wasm32-unknown-unknown/release/substreams.wasm + +modules: + - name: store_vault_pools_created + kind: store + initialBlock: 12272146 + updatePolicy: set + valueType: proto:dynamic_datasource + inputs: + - source: sf.ethereum.type.v2.Block + + - name: map_events + kind: map + initialBlock: 12272146 + inputs: + - source: sf.ethereum.type.v2.Block + - store: store_vault_pools_created + output: + type: proto:contract.v1.Events + + - name: map_calls + kind: map + initialBlock: 12272146 + inputs: + - source: sf.ethereum.type.v2.Block + - store: store_vault_pools_created + output: + type: proto:contract.v1.Calls + + - name: db_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + - map: map_calls + output: + type: proto:sf.substreams.sink.database.v1.DatabaseChanges + + - name: graph_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + - map: map_calls + 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/sql/balancer_v2/substreams.subgraph.yaml b/sql/balancer_v2/substreams.subgraph.yaml new file mode 100644 index 0000000..a1ee6e1 --- /dev/null +++ b/sql/balancer_v2/substreams.subgraph.yaml @@ -0,0 +1,76 @@ +specVersion: v0.1.0 +package: + name: balancer_v2 + version: v0.1.0 + +imports: + 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 + entity: https://github.com/streamingfast/substreams-entity-change/releases/download/v1.1.0/substreams-entity-change-v1.1.0.spkg + +protobuf: + files: + - contract.proto + importPaths: + - ./proto + +binaries: + default: + type: wasm/rust-v1 + file: ./target/wasm32-unknown-unknown/release/substreams.wasm + +modules: + - name: store_vault_pools_created + kind: store + initialBlock: 12272146 + updatePolicy: set + valueType: proto:dynamic_datasource + inputs: + - source: sf.ethereum.type.v2.Block + + - name: map_events + kind: map + initialBlock: 12272146 + inputs: + - source: sf.ethereum.type.v2.Block + - store: store_vault_pools_created + output: + type: proto:contract.v1.Events + + - name: map_calls + kind: map + initialBlock: 12272146 + inputs: + - source: sf.ethereum.type.v2.Block + - store: store_vault_pools_created + output: + type: proto:contract.v1.Calls + + - name: db_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + - map: map_calls + output: + type: proto:sf.substreams.sink.database.v1.DatabaseChanges + + - name: graph_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + - map: map_calls + output: + type: proto:sf.substreams.entity.v1.EntityChanges + +network: mainnet + +sink: + module: graph_out + type: sf.substreams.sink.subgraph.v1.Service + config: + schema: "./schema.graphql" + subgraph_yaml: "./subgraph.yaml" + postgres_direct_protocol_access: true diff --git a/sql/balancer_v2/substreams.yaml b/sql/balancer_v2/substreams.yaml new file mode 100644 index 0000000..7b8092e --- /dev/null +++ b/sql/balancer_v2/substreams.yaml @@ -0,0 +1,68 @@ +specVersion: v0.1.0 +package: + name: balancer_v2 + version: v0.1.0 + +imports: + 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 + entity: https://github.com/streamingfast/substreams-entity-change/releases/download/v1.1.0/substreams-entity-change-v1.1.0.spkg + +protobuf: + files: + - contract.proto + importPaths: + - ./proto + +binaries: + default: + type: wasm/rust-v1 + file: ./target/wasm32-unknown-unknown/release/substreams.wasm + +modules: + - name: store_vault_pools_created + kind: store + initialBlock: 12272146 + updatePolicy: set + valueType: proto:dynamic_datasource + inputs: + - source: sf.ethereum.type.v2.Block + + - name: map_events + kind: map + initialBlock: 12272146 + inputs: + - source: sf.ethereum.type.v2.Block + - store: store_vault_pools_created + output: + type: proto:contract.v1.Events + + - name: map_calls + kind: map + initialBlock: 12272146 + inputs: + - source: sf.ethereum.type.v2.Block + - store: store_vault_pools_created + output: + type: proto:contract.v1.Calls + + - name: db_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + - map: map_calls + output: + type: proto:sf.substreams.sink.database.v1.DatabaseChanges + + - name: graph_out + kind: map + initialBlock: 12272146 + inputs: + - map: map_events + - map: map_calls + output: + type: proto:sf.substreams.entity.v1.EntityChanges + +network: mainnet diff --git a/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__deposits_flattened.sql b/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__deposits_flattened.sql new file mode 100644 index 0000000..c0cba9a --- /dev/null +++ b/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__deposits_flattened.sql @@ -0,0 +1,106 @@ +{{ + config( + materialized = 'table', + alias = 'BALANCER_V2_DEPOSITS_FLATTENED' + ) +}} + +WITH on_join AS ( + SELECT + call_tx_hash AS transaction_hash + , sender + , recipient + , pool_id + , output_param0 AS deltas + , balances AS input_token_balances + FROM pools_call_on_join_pool +) + +, raw_deposits AS ( + SELECT + ve.evt_tx_hash AS transaction_hash + , ve.evt_index AS log_index + , ve.evt_block_number AS block_number + , ve.evt_block_time AS block_timestamp + , ve.deltas + , ve.liquidity_provider + , ve.protocol_fee_amounts + , ve.tokens AS input_tokens + , ve.pool_id AS pool__id_bytes + , oj.recipient + , oj.input_token_balances + FROM vault_pool_balance_changed ve + LEFT JOIN on_join oj + ON oj.transaction_hash = ve.evt_tx_hash + AND oj.deltas = ve.deltas + AND oj.pool_id = ve.pool_id + WHERE recipient IS NOT NULL +) + +, deposits_flattened AS ( + SELECT + rd.transaction_hash + , rd.block_number + , rd.block_timestamp + , rd.log_index + , rd.liquidity_provider + , rd.recipient + -- , RW.PROTOCOL__ID + , rd.deltas + , rd.pool__id_bytes + , SUBSTR(rd.pool__id_bytes, 1, 40) AS pool__id + , token_idx + , rd.deltas[token_idx] AS input_token_amount + , rd.input_tokens[token_idx] AS input_token__id + , rd.protocol_fee_amounts[token_idx] AS protocol_fee_amount + , sum(delta) OVER (PARTITION BY rd.transaction_hash, rd.log_index) AS deltas_sum + , rd.input_token_balances[token_idx] + abs(rd.deltas[token_idx]) AS input_token_balance + FROM raw_deposits rd + CROSS JOIN LATERAL unnest(deltas) WITH ORDINALITY AS F(delta, token_idx) +) + +, mint_amount AS ( + SELECT + df.transaction_hash + , df.log_index + , df.deltas + , pt.to + , pt.value AS output_token_amount + , pt.evt_address AS output_token__id + FROM deposits_flattened df + LEFT JOIN pools_transfer pt + ON pt.evt_tx_hash = df.transaction_hash + AND pt.from = '0000000000000000000000000000000000000000' + AND pt.to IN (df.recipient, df.liquidity_provider) + AND pt.evt_address = df.pool__id + WHERE df.token_idx = 1 +) + +, final AS ( + SELECT + df.transaction_hash + , df.block_number + , df.block_timestamp + , df.log_index + , df.token_idx + , df.recipient + , df.pool__id AS "to" + , df.liquidity_provider AS "from" + , df.pool__id + , df.input_token__id + , df.input_token_amount + , df.input_token_balance + , ma.output_token__id + , ma.output_token_amount + -- , wf.PROTOCOL__ID + , df.protocol_fee_amount + , null AS input_token_amount_usd + , null AS protocol_fee_amount_usd + FROM deposits_flattened df + LEFT JOIN mint_amount ma + ON ma.transaction_hash = df.transaction_hash + AND ma.to IN (df.recipient, df.liquidity_provider) + AND ma.deltas = df.deltas +) + +SELECT * FROM final diff --git a/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__input_token_balances_flattened.sql b/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__input_token_balances_flattened.sql new file mode 100644 index 0000000..1008573 --- /dev/null +++ b/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__input_token_balances_flattened.sql @@ -0,0 +1,126 @@ +{{ + config( + materialized = 'table', + alias = 'INPUT_TOKEN_BALANCES_FLATTENED' + ) +}} + +{% set TOKEN_PRICES = source('ADHOC', 'PRICE_USD_1H') %} +{% set SWAPS = ref('analytics__protocol_balancer_v2_ethereum__swaps') %} +{% set ACTIONS = ref('analytics__protocol_balancer_v2_ethereum__actions') %} +{% set INPUT_TOKENS = ref('analytics__protocol_balnacer_v2_ethereum__input_tokens') %} +{% set ERC20_TOKENS = ref('analytics__protocol_balancer_v2_ethereum__erc20_tokens') %} +{% set DEPOSITS_FLATTENED = ref('analytics__protocol_balancer_v2_ethereum__deposits_flattened') %} +{% set WITHDRAWS_FLATTENED = ref('analytics__protocol_balancer_v2_ethereum__withdraws_flattened') %} + +WITH BALANCES_FLATTENED AS ( + SELECT + TRANSACTION_HASH + , BLOCK_NUMBER + , LOG_INDEX + , POOL__ID + , INPUT_TOKEN__ID AS TOKEN__ID + , INPUT_TOKEN_BALANCE + FROM {{ DEPOSITS_FLATTENED }} + UNION + SELECT + TRANSACTION_HASH + , BLOCK_NUMBER + , LOG_INDEX + , POOL__ID + , INPUT_TOKEN__ID AS TOKEN__ID + , INPUT_TOKEN_BALANCE + FROM {{ WITHDRAWS_FLATTENED }} + UNION + SELECT + HASH AS TRANSACTION_HASH + , BLOCK_NUMBER + , LOG_INDEX + , POOL__ID + , TOKEN_IN__ID AS TOKEN__ID + , TOKEN_IN_BALANCE AS INPUT_TOKEN_BALANCE + FROM {{ SWAPS }} + UNION + SELECT + HASH AS TRANSACTION_HASH + , BLOCK_NUMBER + , LOG_INDEX + , POOL__ID + , TOKEN_OUT__ID AS TOKEN__ID + , TOKEN_OUT_BALANCE AS INPUT_TOKEN_BALANCE + FROM {{ SWAPS }} +) + +, RANKED_BALANCES AS ( + SELECT + TRANSACTION_HASH + , BLOCK_NUMBER + , LOG_INDEX + , POOL__ID + , TOKEN__ID + , INPUT_TOKEN_BALANCE + , ROW_NUMBER() OVER (PARTITION BY POOL__ID, TOKEN__ID ORDER BY BLOCK_NUMBER, LOG_INDEX ASC) AS RANK + FROM BALANCES_FLATTENED +) + +, ALL_TXNS AS ( + SELECT + T.POOL__ID + , T.LOG_INDEX + , T.TIMESTAMP + , T.BLOCK_NUMBER + , T.HASH AS TRANSACTION_HASH + FROM {{ ACTIONS }} T +) + +, FLATTENED_TXNS AS ( + SELECT + T.TRANSACTION_HASH + , T.BLOCK_NUMBER + , T.LOG_INDEX + , T.TIMESTAMP + , T.POOL__ID + , IT.TOKEN_IDX + , IT.INPUT_TOKEN AS TOKEN__ID + , ROW_NUMBER() OVER (PARTITION BY T.POOL__ID, TOKEN__ID ORDER BY T.BLOCK_NUMBER, T.LOG_INDEX ASC) AS RANK + FROM ALL_TXNS T + LEFT JOIN {{ INPUT_TOKENS }} IT + ON IT.POOL__ID = T.POOL__ID +) + +, FINAL AS ( + SELECT + T.POOL__ID + , T.TOKEN__ID + , T.TOKEN_IDX + , DATE_TRUNC('hour', T.TIMESTAMP) AS HOUR + , T.TIMESTAMP + , T.BLOCK_NUMBER + , COALESCE( + B.INPUT_TOKEN_BALANCE, + LAG(B.INPUT_TOKEN_BALANCE) IGNORE NULLS OVER (PARTITION BY T.TOKEN_IDX, T.POOL__ID ORDER BY T.RANK) + ) AS INPUT_TOKEN_BALANCE + , INPUT_TOKEN_BALANCE / POWER(10, ET.DECIMALS) * PR.PRICE_USD AS INPUT_TOKEN_BALANCE_USD + FROM FLATTENED_TXNS T + LEFT JOIN RANKED_BALANCES B + ON T.POOL__ID = B.POOL__ID + AND T.TOKEN__ID = B.TOKEN__ID + AND B.RANK = ( + SELECT + MAX(Z.RANK) + FROM RANKED_BALANCES Z + WHERE Z.TOKEN__ID = T.TOKEN__ID + AND Z.POOL__ID = T.POOL__ID + AND Z.BLOCK_NUMBER = T.BLOCK_NUMBER + ) + LEFT JOIN {{ ERC20_TOKENS }} ET + ON ET.ADDRESS = T.TOKEN__ID + LEFT JOIN {{ TOKEN_PRICES }} PR + ON PR.CONTRACT_ADDRESS = T.TOKEN__ID + AND PR.TIME = DATE_TRUNC('hour', T.TIMESTAMP) + AND PR.NETWORK = 'Ethereum' + + QUALIFY ROW_NUMBER() OVER (PARTITION BY T.POOL__ID, T.TOKEN__ID, HOUR ORDER BY T.BLOCK_NUMBER DESC, T.LOG_INDEX DESC) = 1 +) + +SELECT * FROM FINAL \ No newline at end of file diff --git a/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__swaps.sql b/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__swaps.sql new file mode 100644 index 0000000..1c320b3 --- /dev/null +++ b/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__swaps.sql @@ -0,0 +1,48 @@ +{{ + config( + materialized = 'table', + alias = 'BALANCER_V2_SWAPS' + ) +}} + +WITH raw_swaps AS ( + SELECT + ve.evt_tx_hash AS transaction_hash + , ve.evt_index AS log_index + , ve.evt_block_number AS block_number + , ve.evt_block_time AS block_timestamp + , ve.pool_id AS pool__id_bytes + , SUBSTR(ve.pool_id, 1, 40) AS pool__id + , ve.amount_in + , ve.amount_out + , ve.token_in AS token__in_id + , ve.token_out AS token__out_id + FROM vault_swap ve +) + +, final AS ( + SELECT + rs.transaction_hash as HASH + , rs.block_number + , rs.block_timestamp + , rs.log_index + , 'SWAP' || '-' || rs.transaction_hash || '-' || rs.log_index AS id + , rs.pool__id + , rs.pool__id AS "to" + , null AS "from" + , rs.token__in_id + , rs.token__out_id + , rs.amount_in + , rs.amount_out + , array_position(vr.tokens, rs.token__in_id) AS token_in_idx + , array_position(vr.tokens, rs.token__out_id) AS token_out_idx + + , null AS amount_in_usd + , null AS amount_out_usd + , null AS volume_usd + FROM raw_swaps rs + LEFT JOIN vault_tokens_registered vr + ON vr.pool_id = rs.pool__id_bytes +) + +SELECT * FROM final diff --git a/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__withdraws_flattened.sql b/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__withdraws_flattened.sql new file mode 100644 index 0000000..8fbcac3 --- /dev/null +++ b/sql/dbt/models/protocol_balancer_v2_ethereum_mainnet/analytics__protocol_balancer_v2_ethereum__withdraws_flattened.sql @@ -0,0 +1,105 @@ +{{ + config( + materialized = 'table', + alias = 'BALANCER_V2_WITHDRAWS_FLATTENED' + ) +}} + +WITH on_exit AS ( + SELECT + call_tx_hash AS transaction_hash + , sender + , recipient + , pool_id + , balances AS input_token_balances + FROM pools_call_on_exit_pool +) + +, raw_withdraws AS ( + SELECT + ve.evt_tx_hash AS transaction_hash + , ve.evt_index AS log_index + , ve.evt_block_number AS block_number + , ve.evt_block_time AS block_timestamp + , ve.deltas + , ve.liquidity_provider + , ve.protocol_fee_amounts + , ve.tokens AS input_tokens + , ve.pool_id AS pool__id_bytes + , oe.recipient + , oe.input_token_balances + FROM vault_pool_balance_changed ve + LEFT JOIN on_exit oe + ON oe.transaction_hash = ve.evt_tx_hash + AND oe.sender = ve.liquidity_provider + AND oe.pool_id = ve.pool_id + WHERE recipient IS NOT NULL +) + +, withdraws_flattened AS ( + SELECT + rw.transaction_hash + , rw.block_number + , rw.block_timestamp + , rw.log_index + , rw.liquidity_provider + , rw.recipient + -- , RW.PROTOCOL__ID + , rw.deltas + , rw.pool__id_bytes + , SUBSTR(rw.pool__id_bytes, 1, 40) AS pool__id + , token_idx + , rw.deltas[token_idx] AS input_token_amount + , rw.input_tokens[token_idx] AS input_token__id + , rw.protocol_fee_amounts[token_idx] AS protocol_fee_amount + , sum(delta) OVER (PARTITION BY rw.transaction_hash, rw.log_index) AS deltas_sum + , rw.input_token_balances[token_idx] - abs(rw.deltas[token_idx]) AS input_token_balance + FROM raw_withdraws rw + CROSS JOIN LATERAL unnest(deltas) WITH ORDINALITY AS F(delta, token_idx) +) + +, burnt_amount AS ( + SELECT + wf.transaction_hash + , wf.log_index + , wf.deltas + , pt.from + , pt.value AS output_token_amount + , pt.evt_address AS output_token__id + FROM withdraws_flattened wf + LEFT JOIN pools_transfer pt + ON pt.evt_tx_hash = wf.transaction_hash + AND pt.to = '0000000000000000000000000000000000000000' + AND pt.from IN (wf.recipient, wf.liquidity_provider) + AND pt.evt_address = wf.pool__id + WHERE wf.token_idx = 1 +) + +, final AS ( + SELECT + wf.transaction_hash + , wf.block_number + , wf.block_timestamp + , wf.log_index + , wf.token_idx + , wf.recipient + , wf.pool__id AS "to" + , wf.liquidity_provider AS "from" + , wf.pool__id + , wf.input_token__id + , wf.input_token_amount + , wf.input_token_balance + , ba.output_token__id + , ba.output_token_amount + -- , wf.PROTOCOL__ID + , wf.protocol_fee_amount + , null AS input_token_amount_usd + , null AS protocol_fee_amount_usd + FROM withdraws_flattened wf + LEFT JOIN burnt_amount ba + ON ba.transaction_hash = wf.transaction_hash + AND ba.from IN (wf.recipient, wf.liquidity_provider) + AND ba.deltas = wf.deltas +) + +SELECT * FROM final