diff --git a/substreams/crates/tycho-substreams/src/attributes.rs b/substreams/crates/tycho-substreams/src/attributes.rs index 3a00244..da4449e 100644 --- a/substreams/crates/tycho-substreams/src/attributes.rs +++ b/substreams/crates/tycho-substreams/src/attributes.rs @@ -13,7 +13,6 @@ pub fn json_serialize_value(v: T) -> Vec { .to_vec() } - /// Encodes a list of addresses (in byte representation) into json. /// /// Converts each address to a 0x prefixed hex string and then serializes @@ -30,7 +29,6 @@ pub fn json_serialize_address_list(addresses: &[Vec]) -> Vec { ) } - /// Encodes a list of BigInt values into json. /// /// Converts each integer to a 0x prefixed hex string and then serializes diff --git a/substreams/crates/tycho-substreams/src/contract.rs b/substreams/crates/tycho-substreams/src/contract.rs index c237d1a..79dc216 100644 --- a/substreams/crates/tycho-substreams/src/contract.rs +++ b/substreams/crates/tycho-substreams/src/contract.rs @@ -10,13 +10,14 @@ /// more [here](https://streamingfastio.medium.com/new-block-model-to-accelerate-chain-integration-9f65126e5425) use std::collections::HashMap; +use crate::{ + models::{InterimContractChange, TransactionChanges}, + prelude::TransactionChangesBuilder, +}; use substreams_ethereum::pb::{ eth, - eth::v2::block::DetailLevel, eth::v2::CallType + eth::v2::{block::DetailLevel, TransactionTrace, CallType}, }; -use substreams_ethereum::pb::eth::v2::TransactionTrace; -use crate::models::{InterimContractChange, TransactionChanges}; -use crate::prelude::TransactionChangesBuilder; /// Extracts and aggregates contract changes from a block. /// @@ -49,46 +50,40 @@ pub fn extract_contract_changes bool>( inclusion_predicate: F, transaction_changes: &mut HashMap, ) { - extract_contract_changes_generic( - block, - inclusion_predicate, - |tx, changed_contracts| { - transaction_changes - .entry(tx.index.into()) - .or_insert_with(|| TransactionChanges::new(&(tx.into()))) - .contract_changes - .extend( - changed_contracts - .clone() - .into_values() - .map(|change| change.into()), - ); - }, - ) + extract_contract_changes_generic(block, inclusion_predicate, |tx, changed_contracts| { + transaction_changes + .entry(tx.index.into()) + .or_insert_with(|| TransactionChanges::new(&(tx.into()))) + .contract_changes + .extend( + changed_contracts + .clone() + .into_values() + .map(|change| change.into()), + ); + }) } - pub fn extract_contract_changes_builder bool>( block: ð::v2::Block, inclusion_predicate: F, transaction_changes: &mut HashMap, ) { - extract_contract_changes_generic( - block, - inclusion_predicate, - |tx, changed_contracts| { - let builder = transaction_changes - .entry(tx.index.into()) - .or_insert_with(|| TransactionChangesBuilder::new(&(tx.into()))); - changed_contracts - .clone() - .into_iter() - .for_each(|(_, change)| builder.add_contract_changes(&change)); - }, - ) + extract_contract_changes_generic(block, inclusion_predicate, |tx, changed_contracts| { + let builder = transaction_changes + .entry(tx.index.into()) + .or_insert_with(|| TransactionChangesBuilder::new(&(tx.into()))); + changed_contracts + .clone() + .into_iter() + .for_each(|(_, change)| builder.add_contract_changes(&change)); + }) } -fn extract_contract_changes_generic bool, G: FnMut(&TransactionTrace, &HashMap, InterimContractChange>)>( +fn extract_contract_changes_generic< + F: Fn(&[u8]) -> bool, + G: FnMut(&TransactionTrace, &HashMap, InterimContractChange>), +>( block: ð::v2::Block, inclusion_predicate: F, mut store_changes: G, diff --git a/substreams/crates/tycho-substreams/src/lib.rs b/substreams/crates/tycho-substreams/src/lib.rs index 4537305..0eef870 100644 --- a/substreams/crates/tycho-substreams/src/lib.rs +++ b/substreams/crates/tycho-substreams/src/lib.rs @@ -1,10 +1,10 @@ mod abi; +pub mod attributes; pub mod balances; pub mod contract; mod mock_store; pub mod models; mod pb; -pub mod attributes; pub mod prelude { pub use super::models::*; diff --git a/substreams/crates/tycho-substreams/src/models.rs b/substreams/crates/tycho-substreams/src/models.rs index 41aaa13..445baf5 100644 --- a/substreams/crates/tycho-substreams/src/models.rs +++ b/substreams/crates/tycho-substreams/src/models.rs @@ -66,7 +66,7 @@ impl TransactionChangesBuilder { } /// Unique contract/account addresses that have been changed so far. - pub fn changed_contracts(&self) -> impl Iterator { + pub fn changed_contracts(&self) -> impl Iterator { self.contract_changes .keys() .map(|k| k.as_slice()) diff --git a/substreams/crates/tycho-substreams/src/pb/mod.rs b/substreams/crates/tycho-substreams/src/pb/mod.rs index 43002f2..43d8838 100644 --- a/substreams/crates/tycho-substreams/src/pb/mod.rs +++ b/substreams/crates/tycho-substreams/src/pb/mod.rs @@ -7,4 +7,4 @@ pub mod tycho { // @@protoc_insertion_point(tycho.evm.v1) } } -} \ No newline at end of file +} diff --git a/substreams/ethereum-balancer/src/abi/composable_stable_pool_factory.rs b/substreams/ethereum-balancer/src/abi/composable_stable_pool_factory.rs index 0d2a930..a9b9391 100644 --- a/substreams/ethereum-balancer/src/abi/composable_stable_pool_factory.rs +++ b/substreams/ethereum-balancer/src/abi/composable_stable_pool_factory.rs @@ -1,1545 +1,1353 @@ - 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 Create { - pub name: String, - pub symbol: String, - pub tokens: Vec>, - pub amplification_parameter: substreams::scalar::BigInt, - pub rate_providers: Vec>, - pub token_rate_cache_durations: Vec, - pub exempt_from_yield_protocol_fee_flag: bool, - pub swap_fee_percentage: substreams::scalar::BigInt, - pub owner: Vec, - pub salt: [u8; 32usize], - } - impl Create { - const METHOD_ID: [u8; 4] = [151u8, 30u8, 24u8, 51u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Address), - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Address), - ), - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Uint(256usize)), - ), - ethabi::ParamType::Bool, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - 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(), - amplification_parameter: { - 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) - }, - rate_providers: 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(), - token_rate_cache_durations: 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(), - exempt_from_yield_protocol_fee_flag: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - 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) - }, - owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - salt: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - }) + +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 Create { + pub name: String, + pub symbol: String, + pub tokens: Vec>, + pub amplification_parameter: substreams::scalar::BigInt, + pub rate_providers: Vec>, + pub token_rate_cache_durations: Vec, + pub exempt_from_yield_protocol_fee_flag: bool, + pub swap_fee_percentage: substreams::scalar::BigInt, + pub owner: Vec, + pub salt: [u8; 32usize], + } + impl Create { + const METHOD_ID: [u8; 4] = [151u8, 30u8, 24u8, 51u8]; + 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()); } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .tokens - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::Array(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amplification_parameter.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 - .rate_providers - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::Array(v) - }, - { - let v = self - .token_rate_cache_durations - .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::Bool( - self.exempt_from_yield_protocol_fee_flag.clone(), - ), - 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(), - ), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), - ethabi::Token::FixedBytes(self.salt.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, 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( + let mut values = ethabi::decode( + &[ + ethabi::ParamType::String, + ethabi::ParamType::String, + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))), + ethabi::ParamType::Bool, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::FixedBytes(32usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + 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(), + amplification_parameter: { + let mut v = [0 as u8; 32]; 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 Create { - const NAME: &'static str = "create"; - 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 Create { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Disable {} - impl Disable { - const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; - 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 Disable { - const NAME: &'static str = "disable"; - 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() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + rate_providers: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() .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({ + .as_bytes() + .to_vec() + }) + .collect(), + token_rate_cache_durations: 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(), + exempt_from_yield_protocol_fee_flag: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + 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) + }, + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + salt: { let mut result = [0u8; 32]; let v = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .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 GetCreationCode {} - impl GetCreationCode { - const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; - 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::Bytes], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bytes() - .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 GetCreationCode { - const NAME: &'static str = "getCreationCode"; - 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 GetCreationCode { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCreationCodeContracts {} - impl GetCreationCodeContracts { - const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], - 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(), - 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<(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 GetCreationCodeContracts { - const NAME: &'static str = "getCreationCodeContracts"; - 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 GetCreationCodeContracts { - fn output(data: &[u8]) -> Result<(Vec, Vec), String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPauseConfiguration {} - impl GetPauseConfiguration { - const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; - 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(( + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .tokens + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .amplification_parameter + .clone() + .to_bytes_be() { - 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) - }, + (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 + .rate_providers + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .token_rate_cache_durations + .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::Bool( + self.exempt_from_yield_protocol_fee_flag + .clone(), + ), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .swap_fee_percentage + .clone() + .to_bytes_be() { - 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 + (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.owner)), + ethabi::Token::FixedBytes(self.salt.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, 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 GetPauseConfiguration { - const NAME: &'static str = "getPauseConfiguration"; - 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 GetPauseConfiguration { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolVersion {} - impl GetPoolVersion { - const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; - 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 GetPoolVersion { - const NAME: &'static str = "getPoolVersion"; - 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 GetPoolVersion { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetProtocolFeePercentagesProvider {} - impl GetProtocolFeePercentagesProvider { - const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { - const NAME: &'static str = "getProtocolFeePercentagesProvider"; - 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 GetProtocolFeePercentagesProvider { - fn output(data: &[u8]) -> Result, 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 IsDisabled {} - impl IsDisabled { - const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; - 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 IsDisabled { - const NAME: &'static str = "isDisabled"; - 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 IsDisabled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsPoolFromFactory { - pub pool: Vec, - } - impl IsPoolFromFactory { - const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; - 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 { - pool: 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.pool))], - ); - 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 IsPoolFromFactory { - const NAME: &'static str = "isPoolFromFactory"; - 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 IsPoolFromFactory { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[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 FactoryDisabled {} - impl FactoryDisabled { - const TOPIC_ID: [u8; 32] = [ - 67u8, - 42u8, - 203u8, - 253u8, - 102u8, - 45u8, - 187u8, - 93u8, - 139u8, - 55u8, - 131u8, - 132u8, - 166u8, - 113u8, - 89u8, - 180u8, - 124u8, - 169u8, - 208u8, - 241u8, - 183u8, - 159u8, - 151u8, - 207u8, - 100u8, - 207u8, - 133u8, - 133u8, - 250u8, - 54u8, - 45u8, - 80u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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 {}) + impl substreams_ethereum::Function for Create { + const NAME: &'static str = "create"; + 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 Create { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Disable {} + impl Disable { + const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; + 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::Event for FactoryDisabled { - const NAME: &'static str = "FactoryDisabled"; - 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) - } + } + impl substreams_ethereum::Function for Disable { + const NAME: &'static str = "disable"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCreated { - pub pool: Vec, + fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { + Self::decode(call) } - impl PoolCreated { - const TOPIC_ID: [u8; 32] = [ - 131u8, - 164u8, - 143u8, - 188u8, - 252u8, - 153u8, - 19u8, - 53u8, - 49u8, - 78u8, - 116u8, - 208u8, - 73u8, - 106u8, - 171u8, - 106u8, - 25u8, - 135u8, - 233u8, - 146u8, - 221u8, - 200u8, - 93u8, - 221u8, - 188u8, - 196u8, - 214u8, - 221u8, - 110u8, - 242u8, - 233u8, - 252u8, - ]; - 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; + 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()); } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + 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_address() + .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 GetCreationCode {} + impl GetCreationCode { + const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; + 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::Bytes], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok(values + .pop() + .expect("one output data should have existed") + .into_bytes() + .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 GetCreationCode { + const NAME: &'static str = "getCreationCode"; + 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 GetCreationCode { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCreationCodeContracts {} + impl GetCreationCodeContracts { + const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], + 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(), + 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<(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 GetCreationCodeContracts { + const NAME: &'static str = "getCreationCodeContracts"; + 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 GetCreationCodeContracts { + fn output(data: &[u8]) -> Result<(Vec, Vec), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPauseConfiguration {} + impl GetPauseConfiguration { + const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; + 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) - .as_bytes() - .to_vec(), - }) + .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, } } - impl substreams_ethereum::Event for PoolCreated { - const NAME: &'static str = "PoolCreated"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 + } } } - } \ No newline at end of file + } + impl substreams_ethereum::Function for GetPauseConfiguration { + const NAME: &'static str = "getPauseConfiguration"; + 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 GetPauseConfiguration + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolVersion {} + impl GetPoolVersion { + const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; + 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 GetPoolVersion { + const NAME: &'static str = "getPoolVersion"; + 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 GetPoolVersion { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeePercentagesProvider {} + impl GetProtocolFeePercentagesProvider { + const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { + const NAME: &'static str = "getProtocolFeePercentagesProvider"; + 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 GetProtocolFeePercentagesProvider { + fn output(data: &[u8]) -> Result, 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 IsDisabled {} + impl IsDisabled { + const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; + 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 IsDisabled { + const NAME: &'static str = "isDisabled"; + 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 IsDisabled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsPoolFromFactory { + pub pool: Vec, + } + impl IsPoolFromFactory { + const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; + 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 { + pool: 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.pool))]); + 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 IsPoolFromFactory { + const NAME: &'static str = "isPoolFromFactory"; + 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 IsPoolFromFactory { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[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 FactoryDisabled {} + impl FactoryDisabled { + const TOPIC_ID: [u8; 32] = [ + 67u8, 42u8, 203u8, 253u8, 102u8, 45u8, 187u8, 93u8, 139u8, 55u8, 131u8, 132u8, 166u8, + 113u8, 89u8, 180u8, 124u8, 169u8, 208u8, 241u8, 183u8, 159u8, 151u8, 207u8, 100u8, + 207u8, 133u8, 133u8, 250u8, 54u8, 45u8, 80u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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 {}) + } + } + impl substreams_ethereum::Event for FactoryDisabled { + const NAME: &'static str = "FactoryDisabled"; + 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 PoolCreated { + pub pool: Vec, + } + impl PoolCreated { + const TOPIC_ID: [u8; 32] = [ + 131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8, + 106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8, + 196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8, + ]; + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for PoolCreated { + const NAME: &'static str = "PoolCreated"; + 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) + } + } +} diff --git a/substreams/ethereum-balancer/src/abi/erc_linear_pool_factory.rs b/substreams/ethereum-balancer/src/abi/erc_linear_pool_factory.rs index 5905670..5c2e098 100644 --- a/substreams/ethereum-balancer/src/abi/erc_linear_pool_factory.rs +++ b/substreams/ethereum-balancer/src/abi/erc_linear_pool_factory.rs @@ -1,1514 +1,1334 @@ - 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 Create { - pub name: String, - pub symbol: String, - pub main_token: Vec, - pub wrapped_token: Vec, - pub upper_target: substreams::scalar::BigInt, - pub swap_fee_percentage: substreams::scalar::BigInt, - pub owner: Vec, - pub protocol_id: substreams::scalar::BigInt, - pub salt: [u8; 32usize], - } - impl Create { - const METHOD_ID: [u8; 4] = [118u8, 137u8, 91u8, 231u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - main_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - wrapped_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - upper_target: { - 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) - }, - 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) - }, - owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - protocol_id: { - 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) - }, - salt: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - }) + +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 Create { + pub name: String, + pub symbol: String, + pub main_token: Vec, + pub wrapped_token: Vec, + pub upper_target: substreams::scalar::BigInt, + pub swap_fee_percentage: substreams::scalar::BigInt, + pub owner: Vec, + pub protocol_id: substreams::scalar::BigInt, + pub salt: [u8; 32usize], + } + impl Create { + const METHOD_ID: [u8; 4] = [118u8, 137u8, 91u8, 231u8]; + 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()); } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.main_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.wrapped_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.upper_target.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.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::Address(ethabi::Address::from_slice(&self.owner)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.protocol_id.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.salt.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, 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( + let mut values = ethabi::decode( + &[ + ethabi::ParamType::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedBytes(32usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + main_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + wrapped_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + upper_target: { + let mut v = [0 as u8; 32]; 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 Create { - const NAME: &'static str = "create"; - 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 Create { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Disable {} - impl Disable { - const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; - 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 Disable { - const NAME: &'static str = "disable"; - 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({ + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + 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) + }, + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + protocol_id: { + 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) + }, + salt: { let mut result = [0u8; 32]; let v = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .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 + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.main_token)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.wrapped_token)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.upper_target.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") + } } - } - } - } - 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 GetCreationCode {} - impl GetCreationCode { - const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; - 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::Bytes], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bytes() - .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 GetCreationCode { - const NAME: &'static str = "getCreationCode"; - 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 GetCreationCode { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCreationCodeContracts {} - impl GetCreationCodeContracts { - const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], - 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(), - 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<(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 GetCreationCodeContracts { - const NAME: &'static str = "getCreationCodeContracts"; - 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 GetCreationCodeContracts { - fn output(data: &[u8]) -> Result<(Vec, Vec), String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLastCreatedPool {} - impl GetLastCreatedPool { - const METHOD_ID: [u8; 4] = [94u8, 211u8, 18u8, 130u8]; - 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 GetLastCreatedPool { - const NAME: &'static str = "getLastCreatedPool"; - 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 GetLastCreatedPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPauseConfiguration {} - impl GetPauseConfiguration { - const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; - 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(( + .as_slice(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .swap_fee_percentage + .clone() + .to_bytes_be() { - 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 + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } } - } - } - } - impl substreams_ethereum::Function for GetPauseConfiguration { - const NAME: &'static str = "getPauseConfiguration"; - 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 GetPauseConfiguration { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolVersion {} - impl GetPoolVersion { - const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; - 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 + .as_slice(), + )), + ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.protocol_id.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.salt.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, 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 GetPoolVersion { - const NAME: &'static str = "getPoolVersion"; - 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 GetPoolVersion { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetProtocolFeePercentagesProvider {} - impl GetProtocolFeePercentagesProvider { - const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { - const NAME: &'static str = "getProtocolFeePercentagesProvider"; - 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 GetProtocolFeePercentagesProvider { - fn output(data: &[u8]) -> Result, 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 IsDisabled {} - impl IsDisabled { - const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; - 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 IsDisabled { - const NAME: &'static str = "isDisabled"; - 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 IsDisabled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsPoolFromFactory { - pub pool: Vec, - } - impl IsPoolFromFactory { - const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; - 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 { - pool: 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.pool))], - ); - 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 IsPoolFromFactory { - const NAME: &'static str = "isPoolFromFactory"; - 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 IsPoolFromFactory { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[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 Erc4626LinearPoolCreated { - pub pool: Vec, - pub protocol_id: substreams::scalar::BigInt, + impl substreams_ethereum::Function for Create { + const NAME: &'static str = "create"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl Erc4626LinearPoolCreated { - const TOPIC_ID: [u8; 32] = [ - 69u8, - 221u8, - 97u8, - 93u8, - 46u8, - 215u8, - 153u8, - 79u8, - 152u8, - 254u8, - 200u8, - 55u8, - 178u8, - 208u8, - 146u8, - 175u8, - 147u8, - 60u8, - 101u8, - 32u8, - 184u8, - 113u8, - 124u8, - 58u8, - 100u8, - 49u8, - 121u8, - 97u8, - 202u8, - 165u8, - 50u8, - 234u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 0usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; + 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 Create { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Disable {} + impl Disable { + const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; + 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, } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + } + } + impl substreams_ethereum::Function for Disable { + const NAME: &'static str = "disable"; + 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_address() + .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 GetCreationCode {} + impl GetCreationCode { + const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; + 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::Bytes], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok(values + .pop() + .expect("one output data should have existed") + .into_bytes() + .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 GetCreationCode { + const NAME: &'static str = "getCreationCode"; + 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 GetCreationCode { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCreationCodeContracts {} + impl GetCreationCodeContracts { + const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], + 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(), + 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<(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 GetCreationCodeContracts { + const NAME: &'static str = "getCreationCodeContracts"; + 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 GetCreationCodeContracts { + fn output(data: &[u8]) -> Result<(Vec, Vec), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLastCreatedPool {} + impl GetLastCreatedPool { + const METHOD_ID: [u8; 4] = [94u8, 211u8, 18u8, 130u8]; + 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 GetLastCreatedPool { + const NAME: &'static str = "getLastCreatedPool"; + 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 GetLastCreatedPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPauseConfiguration {} + impl GetPauseConfiguration { + const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; + 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) - .as_bytes() - .to_vec(), - protocol_id: { - let mut v = [0 as u8; 32]; - ethabi::decode( + .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 GetPauseConfiguration { + const NAME: &'static str = "getPauseConfiguration"; + 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 GetPauseConfiguration + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolVersion {} + impl GetPoolVersion { + const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; + 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 GetPoolVersion { + const NAME: &'static str = "getPoolVersion"; + 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 GetPoolVersion { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeePercentagesProvider {} + impl GetProtocolFeePercentagesProvider { + const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { + const NAME: &'static str = "getProtocolFeePercentagesProvider"; + 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 GetProtocolFeePercentagesProvider { + fn output(data: &[u8]) -> Result, 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 IsDisabled {} + impl IsDisabled { + const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; + 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 IsDisabled { + const NAME: &'static str = "isDisabled"; + 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 IsDisabled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsPoolFromFactory { + pub pool: Vec, + } + impl IsPoolFromFactory { + const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; + 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 { + pool: 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.pool))]); + 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 IsPoolFromFactory { + const NAME: &'static str = "isPoolFromFactory"; + 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 IsPoolFromFactory { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[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 Erc4626LinearPoolCreated { + pub pool: Vec, + pub protocol_id: substreams::scalar::BigInt, + } + impl Erc4626LinearPoolCreated { + const TOPIC_ID: [u8; 32] = [ + 69u8, 221u8, 97u8, 93u8, 46u8, 215u8, 153u8, 79u8, 152u8, 254u8, 200u8, 55u8, 178u8, + 208u8, 146u8, 175u8, 147u8, 60u8, 101u8, 32u8, 184u8, 113u8, 124u8, 58u8, 100u8, 49u8, + 121u8, 97u8, 202u8, 165u8, 50u8, 234u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + protocol_id: { + let mut v = [0 as u8; 32]; + ethabi::decode( &[ethabi::ParamType::Uint(256usize)], log.topics[2usize].as_ref(), ) @@ -1523,167 +1343,104 @@ .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for Erc4626LinearPoolCreated { - const NAME: &'static str = "Erc4626LinearPoolCreated"; - 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) - } + } + impl substreams_ethereum::Event for Erc4626LinearPoolCreated { + const NAME: &'static str = "Erc4626LinearPoolCreated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct FactoryDisabled {} - impl FactoryDisabled { - const TOPIC_ID: [u8; 32] = [ - 67u8, - 42u8, - 203u8, - 253u8, - 102u8, - 45u8, - 187u8, - 93u8, - 139u8, - 55u8, - 131u8, - 132u8, - 166u8, - 113u8, - 89u8, - 180u8, - 124u8, - 169u8, - 208u8, - 241u8, - 183u8, - 159u8, - 151u8, - 207u8, - 100u8, - 207u8, - 133u8, - 133u8, - 250u8, - 54u8, - 45u8, - 80u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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 {}) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl substreams_ethereum::Event for FactoryDisabled { - const NAME: &'static str = "FactoryDisabled"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + } + #[derive(Debug, Clone, PartialEq)] + pub struct FactoryDisabled {} + impl FactoryDisabled { + const TOPIC_ID: [u8; 32] = [ + 67u8, 42u8, 203u8, 253u8, 102u8, 45u8, 187u8, 93u8, 139u8, 55u8, 131u8, 132u8, 166u8, + 113u8, 89u8, 180u8, 124u8, 169u8, 208u8, 241u8, 183u8, 159u8, 151u8, 207u8, 100u8, + 207u8, 133u8, 133u8, 250u8, 54u8, 45u8, 80u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + if log.data.len() != 0usize { + return false; } + return log + .topics + .get(0) + .expect("bounds already checked") + .as_ref() + == Self::TOPIC_ID; } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCreated { - pub pool: Vec, + pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Ok(Self {}) } - impl PoolCreated { - const TOPIC_ID: [u8; 32] = [ - 131u8, - 164u8, - 143u8, - 188u8, - 252u8, - 153u8, - 19u8, - 53u8, - 49u8, - 78u8, - 116u8, - 208u8, - 73u8, - 106u8, - 171u8, - 106u8, - 25u8, - 135u8, - 233u8, - 146u8, - 221u8, - 200u8, - 93u8, - 221u8, - 188u8, - 196u8, - 214u8, - 221u8, - 110u8, - 242u8, - 233u8, - 252u8, - ]; - 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; + } + impl substreams_ethereum::Event for FactoryDisabled { + const NAME: &'static str = "FactoryDisabled"; + 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 PoolCreated { + pub pool: Vec, + } + impl PoolCreated { + const TOPIC_ID: [u8; 32] = [ + 131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8, + 106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8, + 196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Event for PoolCreated { - const NAME: &'static str = "PoolCreated"; - 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) - } + } + impl substreams_ethereum::Event for PoolCreated { + const NAME: &'static str = "PoolCreated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - } \ No newline at end of file + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} diff --git a/substreams/ethereum-balancer/src/abi/euler_linear_pool_factory.rs b/substreams/ethereum-balancer/src/abi/euler_linear_pool_factory.rs index afc20e3..a1ecc34 100644 --- a/substreams/ethereum-balancer/src/abi/euler_linear_pool_factory.rs +++ b/substreams/ethereum-balancer/src/abi/euler_linear_pool_factory.rs @@ -1,1590 +1,1400 @@ - 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 Create { - pub name: String, - pub symbol: String, - pub main_token: Vec, - pub wrapped_token: Vec, - pub upper_target: substreams::scalar::BigInt, - pub swap_fee_percentage: substreams::scalar::BigInt, - pub owner: Vec, - pub protocol_id: substreams::scalar::BigInt, - } - impl Create { - const METHOD_ID: [u8; 4] = [223u8, 138u8, 249u8, 137u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - main_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - wrapped_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - upper_target: { - 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) - }, - 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) - }, - owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - protocol_id: { - 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) - }, - }) + +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 Create { + pub name: String, + pub symbol: String, + pub main_token: Vec, + pub wrapped_token: Vec, + pub upper_target: substreams::scalar::BigInt, + pub swap_fee_percentage: substreams::scalar::BigInt, + pub owner: Vec, + pub protocol_id: substreams::scalar::BigInt, + } + impl Create { + const METHOD_ID: [u8; 4] = [223u8, 138u8, 249u8, 137u8]; + 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()); } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.main_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.wrapped_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.upper_target.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.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::Address(ethabi::Address::from_slice(&self.owner)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.protocol_id.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::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + let mut values = ethabi::decode( + &[ + ethabi::ParamType::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + main_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + wrapped_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + upper_target: { + let mut v = [0 as u8; 32]; 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 Create { - const NAME: &'static str = "create"; - 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 Create { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Disable {} - impl Disable { - const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; - 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 Disable { - const NAME: &'static str = "disable"; - 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 EulerProtocol {} - impl EulerProtocol { - const METHOD_ID: [u8; 4] = [82u8, 8u8, 252u8, 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( + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + swap_fee_percentage: { + let mut v = [0 as u8; 32]; 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 + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + protocol_id: { + 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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.main_token)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.wrapped_token)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.upper_target.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 + .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::Address(ethabi::Address::from_slice(&self.owner)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.protocol_id.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::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 EulerProtocol { - const NAME: &'static str = "eulerProtocol"; - 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::Function for Create { + const NAME: &'static str = "create"; + 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 Create { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Disable {} + impl Disable { + const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; + 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::rpc::RPCDecodable> for EulerProtocol { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + } + impl substreams_ethereum::Function for Disable { + const NAME: &'static str = "disable"; + 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 EulerProtocol {} + impl EulerProtocol { + const METHOD_ID: [u8; 4] = [82u8, 8u8, 252u8, 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, } } - #[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()); + 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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::FixedBytes(4usize)], - maybe_data.unwrap(), - ) + } + } + } + impl substreams_ethereum::Function for EulerProtocol { + const NAME: &'static str = "eulerProtocol"; + 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 EulerProtocol { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[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]; + values.reverse(); + Ok(Self { + selector: { + let mut result = [0u8; 4]; let v = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .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() - } + 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 } - impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for GetActionId { - fn output(data: &[u8]) -> Result<[u8; 32usize], String> { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) } - #[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(), - ) + 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( - 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 - } - } + 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, } } - 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) + 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; } - 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 GetCreationCode {} - impl GetCreationCode { - const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; - 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::Bytes], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bytes() - .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, + 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 } } - 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 GetCreationCode { - const NAME: &'static str = "getCreationCode"; - 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 GetCreationCode { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCreationCodeContracts {} - impl GetCreationCodeContracts { - const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], - 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(), - 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<(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 GetCreationCodeContracts { - const NAME: &'static str = "getCreationCodeContracts"; - 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 GetCreationCodeContracts { - fn output(data: &[u8]) -> Result<(Vec, Vec), String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLastCreatedPool {} - impl GetLastCreatedPool { - const METHOD_ID: [u8; 4] = [94u8, 211u8, 18u8, 130u8]; - 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 GetLastCreatedPool { - const NAME: &'static str = "getLastCreatedPool"; - 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 GetLastCreatedPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPauseConfiguration {} - impl GetPauseConfiguration { - const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; - 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 GetPauseConfiguration { - const NAME: &'static str = "getPauseConfiguration"; - 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 GetPauseConfiguration { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolVersion {} - impl GetPoolVersion { - const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; - 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 GetPoolVersion { - const NAME: &'static str = "getPoolVersion"; - 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 GetPoolVersion { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetProtocolFeePercentagesProvider {} - impl GetProtocolFeePercentagesProvider { - const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { - const NAME: &'static str = "getProtocolFeePercentagesProvider"; - 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 GetProtocolFeePercentagesProvider { - fn output(data: &[u8]) -> Result, 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 IsDisabled {} - impl IsDisabled { - const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; - 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 IsDisabled { - const NAME: &'static str = "isDisabled"; - 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 IsDisabled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsPoolFromFactory { - pub pool: Vec, - } - impl IsPoolFromFactory { - const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; - 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 { - pool: 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.pool))], - ); - 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 IsPoolFromFactory { - const NAME: &'static str = "isPoolFromFactory"; - 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 IsPoolFromFactory { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[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 EulerLinearPoolCreated { - pub pool: Vec, - pub protocol_id: substreams::scalar::BigInt, + 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) } - impl EulerLinearPoolCreated { - const TOPIC_ID: [u8; 32] = [ - 222u8, - 57u8, - 57u8, - 206u8, - 202u8, - 16u8, - 20u8, - 97u8, - 253u8, - 126u8, - 56u8, - 151u8, - 5u8, - 2u8, - 10u8, - 31u8, - 139u8, - 21u8, - 24u8, - 237u8, - 183u8, - 93u8, - 5u8, - 40u8, - 75u8, - 33u8, - 170u8, - 39u8, - 3u8, - 84u8, - 195u8, - 220u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 0usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; + 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 decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + } + 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 GetCreationCode {} + impl GetCreationCode { + const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; + 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::Bytes], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok(values + .pop() + .expect("one output data should have existed") + .into_bytes() + .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 GetCreationCode { + const NAME: &'static str = "getCreationCode"; + 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 GetCreationCode { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCreationCodeContracts {} + impl GetCreationCodeContracts { + const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], + 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(), + 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<(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 GetCreationCodeContracts { + const NAME: &'static str = "getCreationCodeContracts"; + 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 GetCreationCodeContracts { + fn output(data: &[u8]) -> Result<(Vec, Vec), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLastCreatedPool {} + impl GetLastCreatedPool { + const METHOD_ID: [u8; 4] = [94u8, 211u8, 18u8, 130u8]; + 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 GetLastCreatedPool { + const NAME: &'static str = "getLastCreatedPool"; + 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 GetLastCreatedPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPauseConfiguration {} + impl GetPauseConfiguration { + const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; + 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - protocol_id: { - let mut v = [0 as u8; 32]; - ethabi::decode( + .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 GetPauseConfiguration { + const NAME: &'static str = "getPauseConfiguration"; + 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 GetPauseConfiguration + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolVersion {} + impl GetPoolVersion { + const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; + 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 GetPoolVersion { + const NAME: &'static str = "getPoolVersion"; + 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 GetPoolVersion { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeePercentagesProvider {} + impl GetProtocolFeePercentagesProvider { + const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { + const NAME: &'static str = "getProtocolFeePercentagesProvider"; + 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 GetProtocolFeePercentagesProvider { + fn output(data: &[u8]) -> Result, 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 IsDisabled {} + impl IsDisabled { + const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; + 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 IsDisabled { + const NAME: &'static str = "isDisabled"; + 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 IsDisabled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsPoolFromFactory { + pub pool: Vec, + } + impl IsPoolFromFactory { + const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; + 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 { + pool: 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.pool))]); + 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 IsPoolFromFactory { + const NAME: &'static str = "isPoolFromFactory"; + 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 IsPoolFromFactory { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[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 EulerLinearPoolCreated { + pub pool: Vec, + pub protocol_id: substreams::scalar::BigInt, + } + impl EulerLinearPoolCreated { + const TOPIC_ID: [u8; 32] = [ + 222u8, 57u8, 57u8, 206u8, 202u8, 16u8, 20u8, 97u8, 253u8, 126u8, 56u8, 151u8, 5u8, 2u8, + 10u8, 31u8, 139u8, 21u8, 24u8, 237u8, 183u8, 93u8, 5u8, 40u8, 75u8, 33u8, 170u8, 39u8, + 3u8, 84u8, 195u8, 220u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + protocol_id: { + let mut v = [0 as u8; 32]; + ethabi::decode( &[ethabi::ParamType::Uint(256usize)], log.topics[2usize].as_ref(), ) @@ -1599,167 +1409,104 @@ .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for EulerLinearPoolCreated { - const NAME: &'static str = "EulerLinearPoolCreated"; - 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) - } + } + impl substreams_ethereum::Event for EulerLinearPoolCreated { + const NAME: &'static str = "EulerLinearPoolCreated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct FactoryDisabled {} - impl FactoryDisabled { - const TOPIC_ID: [u8; 32] = [ - 67u8, - 42u8, - 203u8, - 253u8, - 102u8, - 45u8, - 187u8, - 93u8, - 139u8, - 55u8, - 131u8, - 132u8, - 166u8, - 113u8, - 89u8, - 180u8, - 124u8, - 169u8, - 208u8, - 241u8, - 183u8, - 159u8, - 151u8, - 207u8, - 100u8, - 207u8, - 133u8, - 133u8, - 250u8, - 54u8, - 45u8, - 80u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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 {}) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl substreams_ethereum::Event for FactoryDisabled { - const NAME: &'static str = "FactoryDisabled"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + } + #[derive(Debug, Clone, PartialEq)] + pub struct FactoryDisabled {} + impl FactoryDisabled { + const TOPIC_ID: [u8; 32] = [ + 67u8, 42u8, 203u8, 253u8, 102u8, 45u8, 187u8, 93u8, 139u8, 55u8, 131u8, 132u8, 166u8, + 113u8, 89u8, 180u8, 124u8, 169u8, 208u8, 241u8, 183u8, 159u8, 151u8, 207u8, 100u8, + 207u8, 133u8, 133u8, 250u8, 54u8, 45u8, 80u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + if log.data.len() != 0usize { + return false; } + return log + .topics + .get(0) + .expect("bounds already checked") + .as_ref() + == Self::TOPIC_ID; } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCreated { - pub pool: Vec, + pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Ok(Self {}) } - impl PoolCreated { - const TOPIC_ID: [u8; 32] = [ - 131u8, - 164u8, - 143u8, - 188u8, - 252u8, - 153u8, - 19u8, - 53u8, - 49u8, - 78u8, - 116u8, - 208u8, - 73u8, - 106u8, - 171u8, - 106u8, - 25u8, - 135u8, - 233u8, - 146u8, - 221u8, - 200u8, - 93u8, - 221u8, - 188u8, - 196u8, - 214u8, - 221u8, - 110u8, - 242u8, - 233u8, - 252u8, - ]; - 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; + } + impl substreams_ethereum::Event for FactoryDisabled { + const NAME: &'static str = "FactoryDisabled"; + 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 PoolCreated { + pub pool: Vec, + } + impl PoolCreated { + const TOPIC_ID: [u8; 32] = [ + 131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8, + 106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8, + 196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Event for PoolCreated { - const NAME: &'static str = "PoolCreated"; - 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) - } + } + impl substreams_ethereum::Event for PoolCreated { + const NAME: &'static str = "PoolCreated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - } \ No newline at end of file + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} diff --git a/substreams/ethereum-balancer/src/abi/gearbox_linear_pool_factory.rs b/substreams/ethereum-balancer/src/abi/gearbox_linear_pool_factory.rs index 89a2b16..5a21ffd 100644 --- a/substreams/ethereum-balancer/src/abi/gearbox_linear_pool_factory.rs +++ b/substreams/ethereum-balancer/src/abi/gearbox_linear_pool_factory.rs @@ -1,1578 +1,1369 @@ - 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 Create { - pub name: String, - pub symbol: String, - pub main_token: Vec, - pub wrapped_token: Vec, - pub upper_target: substreams::scalar::BigInt, - pub swap_fee_percentage: substreams::scalar::BigInt, - pub owner: Vec, - pub protocol_id: substreams::scalar::BigInt, - pub salt: [u8; 32usize], - } - impl Create { - const METHOD_ID: [u8; 4] = [118u8, 137u8, 91u8, 231u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - main_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - wrapped_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - upper_target: { - 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) - }, - 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) - }, - owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - protocol_id: { - 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) - }, - salt: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - }) + +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 Create { + pub name: String, + pub symbol: String, + pub main_token: Vec, + pub wrapped_token: Vec, + pub upper_target: substreams::scalar::BigInt, + pub swap_fee_percentage: substreams::scalar::BigInt, + pub owner: Vec, + pub protocol_id: substreams::scalar::BigInt, + pub salt: [u8; 32usize], + } + impl Create { + const METHOD_ID: [u8; 4] = [118u8, 137u8, 91u8, 231u8]; + 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()); } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.main_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.wrapped_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.upper_target.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.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::Address(ethabi::Address::from_slice(&self.owner)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.protocol_id.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.salt.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, 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( + let mut values = ethabi::decode( + &[ + ethabi::ParamType::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedBytes(32usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + main_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + wrapped_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + upper_target: { + let mut v = [0 as u8; 32]; 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 Create { - const NAME: &'static str = "create"; - 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 Create { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Disable {} - impl Disable { - const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; - 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 Disable { - const NAME: &'static str = "disable"; - 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({ + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + 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) + }, + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + protocol_id: { + 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) + }, + salt: { let mut result = [0u8; 32]; let v = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .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 + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.main_token)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.wrapped_token)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.upper_target.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") + } } - } - } - } - 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 GetCreationCode {} - impl GetCreationCode { - const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; - 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::Bytes], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bytes() - .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 GetCreationCode { - const NAME: &'static str = "getCreationCode"; - 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 GetCreationCode { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCreationCodeContracts {} - impl GetCreationCodeContracts { - const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], - 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(), - 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<(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 GetCreationCodeContracts { - const NAME: &'static str = "getCreationCodeContracts"; - 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 GetCreationCodeContracts { - fn output(data: &[u8]) -> Result<(Vec, Vec), String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLastCreatedPool {} - impl GetLastCreatedPool { - const METHOD_ID: [u8; 4] = [94u8, 211u8, 18u8, 130u8]; - 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 GetLastCreatedPool { - const NAME: &'static str = "getLastCreatedPool"; - 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 GetLastCreatedPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPauseConfiguration {} - impl GetPauseConfiguration { - const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; - 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(( + .as_slice(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .swap_fee_percentage + .clone() + .to_bytes_be() { - 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 + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } } - } - } - } - impl substreams_ethereum::Function for GetPauseConfiguration { - const NAME: &'static str = "getPauseConfiguration"; - 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 GetPauseConfiguration { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolVersion {} - impl GetPoolVersion { - const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; - 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 + .as_slice(), + )), + ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.protocol_id.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.salt.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, 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 GetPoolVersion { - const NAME: &'static str = "getPoolVersion"; - 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 GetPoolVersion { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetProtocolFeePercentagesProvider {} - impl GetProtocolFeePercentagesProvider { - const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { - const NAME: &'static str = "getProtocolFeePercentagesProvider"; - 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 GetProtocolFeePercentagesProvider { - fn output(data: &[u8]) -> Result, 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 IsDisabled {} - impl IsDisabled { - const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; - 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 IsDisabled { - const NAME: &'static str = "isDisabled"; - 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 IsDisabled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsPoolFromFactory { - pub pool: Vec, - } - impl IsPoolFromFactory { - const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; - 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 { - pool: 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.pool))], - ); - 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 IsPoolFromFactory { - const NAME: &'static str = "isPoolFromFactory"; - 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 IsPoolFromFactory { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[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 FactoryDisabled {} - impl FactoryDisabled { - const TOPIC_ID: [u8; 32] = [ - 67u8, - 42u8, - 203u8, - 253u8, - 102u8, - 45u8, - 187u8, - 93u8, - 139u8, - 55u8, - 131u8, - 132u8, - 166u8, - 113u8, - 89u8, - 180u8, - 124u8, - 169u8, - 208u8, - 241u8, - 183u8, - 159u8, - 151u8, - 207u8, - 100u8, - 207u8, - 133u8, - 133u8, - 250u8, - 54u8, - 45u8, - 80u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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 {}) + impl substreams_ethereum::Function for Create { + const NAME: &'static str = "create"; + 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 Create { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Disable {} + impl Disable { + const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; + 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::Event for FactoryDisabled { - const NAME: &'static str = "FactoryDisabled"; - 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) - } + } + impl substreams_ethereum::Function for Disable { + const NAME: &'static str = "disable"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GearboxLinearPoolCreated { - pub pool: Vec, - pub protocol_id: substreams::scalar::BigInt, + fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { + Self::decode(call) } - impl GearboxLinearPoolCreated { - const TOPIC_ID: [u8; 32] = [ - 247u8, - 233u8, - 204u8, - 1u8, - 56u8, - 242u8, - 70u8, - 13u8, - 229u8, - 105u8, - 50u8, - 195u8, - 236u8, - 237u8, - 29u8, - 78u8, - 21u8, - 121u8, - 168u8, - 54u8, - 100u8, - 80u8, - 108u8, - 25u8, - 212u8, - 48u8, - 74u8, - 242u8, - 106u8, - 164u8, - 139u8, - 212u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 0usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; + 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()); } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + 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_address() + .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 GetCreationCode {} + impl GetCreationCode { + const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; + 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::Bytes], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok(values + .pop() + .expect("one output data should have existed") + .into_bytes() + .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 GetCreationCode { + const NAME: &'static str = "getCreationCode"; + 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 GetCreationCode { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCreationCodeContracts {} + impl GetCreationCodeContracts { + const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], + 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(), + 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<(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 GetCreationCodeContracts { + const NAME: &'static str = "getCreationCodeContracts"; + 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 GetCreationCodeContracts { + fn output(data: &[u8]) -> Result<(Vec, Vec), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLastCreatedPool {} + impl GetLastCreatedPool { + const METHOD_ID: [u8; 4] = [94u8, 211u8, 18u8, 130u8]; + 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 GetLastCreatedPool { + const NAME: &'static str = "getLastCreatedPool"; + 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 GetLastCreatedPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPauseConfiguration {} + impl GetPauseConfiguration { + const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; + 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) - .as_bytes() - .to_vec(), - protocol_id: { - let mut v = [0 as u8; 32]; - ethabi::decode( + .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 GetPauseConfiguration { + const NAME: &'static str = "getPauseConfiguration"; + 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 GetPauseConfiguration + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolVersion {} + impl GetPoolVersion { + const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; + 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 GetPoolVersion { + const NAME: &'static str = "getPoolVersion"; + 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 GetPoolVersion { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeePercentagesProvider {} + impl GetProtocolFeePercentagesProvider { + const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { + const NAME: &'static str = "getProtocolFeePercentagesProvider"; + 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 GetProtocolFeePercentagesProvider { + fn output(data: &[u8]) -> Result, 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 IsDisabled {} + impl IsDisabled { + const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; + 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 IsDisabled { + const NAME: &'static str = "isDisabled"; + 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 IsDisabled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsPoolFromFactory { + pub pool: Vec, + } + impl IsPoolFromFactory { + const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; + 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 { + pool: 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.pool))]); + 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 IsPoolFromFactory { + const NAME: &'static str = "isPoolFromFactory"; + 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 IsPoolFromFactory { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[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 FactoryDisabled {} + impl FactoryDisabled { + const TOPIC_ID: [u8; 32] = [ + 67u8, 42u8, 203u8, 253u8, 102u8, 45u8, 187u8, 93u8, 139u8, 55u8, 131u8, 132u8, 166u8, + 113u8, 89u8, 180u8, 124u8, 169u8, 208u8, 241u8, 183u8, 159u8, 151u8, 207u8, 100u8, + 207u8, 133u8, 133u8, 250u8, 54u8, 45u8, 80u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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 {}) + } + } + impl substreams_ethereum::Event for FactoryDisabled { + const NAME: &'static str = "FactoryDisabled"; + 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 GearboxLinearPoolCreated { + pub pool: Vec, + pub protocol_id: substreams::scalar::BigInt, + } + impl GearboxLinearPoolCreated { + const TOPIC_ID: [u8; 32] = [ + 247u8, 233u8, 204u8, 1u8, 56u8, 242u8, 70u8, 13u8, 229u8, 105u8, 50u8, 195u8, 236u8, + 237u8, 29u8, 78u8, 21u8, 121u8, 168u8, 54u8, 100u8, 80u8, 108u8, 25u8, 212u8, 48u8, + 74u8, 242u8, 106u8, 164u8, 139u8, 212u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + protocol_id: { + let mut v = [0 as u8; 32]; + ethabi::decode( &[ethabi::ParamType::Uint(256usize)], log.topics[2usize].as_ref(), ) @@ -1587,103 +1378,69 @@ .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for GearboxLinearPoolCreated { - const NAME: &'static str = "GearboxLinearPoolCreated"; - 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) - } + } + impl substreams_ethereum::Event for GearboxLinearPoolCreated { + const NAME: &'static str = "GearboxLinearPoolCreated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCreated { - pub pool: Vec, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl PoolCreated { - const TOPIC_ID: [u8; 32] = [ - 131u8, - 164u8, - 143u8, - 188u8, - 252u8, - 153u8, - 19u8, - 53u8, - 49u8, - 78u8, - 116u8, - 208u8, - 73u8, - 106u8, - 171u8, - 106u8, - 25u8, - 135u8, - 233u8, - 146u8, - 221u8, - 200u8, - 93u8, - 221u8, - 188u8, - 196u8, - 214u8, - 221u8, - 110u8, - 242u8, - 233u8, - 252u8, - ]; - 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; + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolCreated { + pub pool: Vec, + } + impl PoolCreated { + const TOPIC_ID: [u8; 32] = [ + 131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8, + 106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8, + 196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Event for PoolCreated { - const NAME: &'static str = "PoolCreated"; - 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) - } + } + impl substreams_ethereum::Event for PoolCreated { + const NAME: &'static str = "PoolCreated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - } \ No newline at end of file + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} diff --git a/substreams/ethereum-balancer/src/abi/managed_pool_factory.rs b/substreams/ethereum-balancer/src/abi/managed_pool_factory.rs index afd6cab..9367a3c 100644 --- a/substreams/ethereum-balancer/src/abi/managed_pool_factory.rs +++ b/substreams/ethereum-balancer/src/abi/managed_pool_factory.rs @@ -1,1735 +1,1568 @@ - 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 Create { - pub params: (String, String, Vec>), - pub settings_params: ( - Vec>, - Vec, - substreams::scalar::BigInt, - bool, - bool, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - pub owner: Vec, - pub salt: [u8; 32usize], - } - impl Create { - const METHOD_ID: [u8; 4] = [115u8, 4u8, 184u8, 185u8]; - 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::String, ethabi::ParamType::String, - ethabi::ParamType::Array(Box::new(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::Uint(256usize), ethabi::ParamType::Bool, - ethabi::ParamType::Bool, ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize) - ], - ), - ethabi::ParamType::Address, - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - params: { - let tuple_elements = values - .pop() + +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 Create { + pub params: (String, String, Vec>), + pub settings_params: ( + Vec>, + Vec, + substreams::scalar::BigInt, + bool, + bool, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + pub owner: Vec, + pub salt: [u8; 32usize], + } + impl Create { + const METHOD_ID: [u8; 4] = [115u8, 4u8, 184u8, 185u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::Array(Box::new(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::Uint(256usize), + ethabi::ParamType::Bool, + ethabi::ParamType::Bool, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ]), + ethabi::ParamType::Address, + ethabi::ParamType::FixedBytes(32usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + params: { + let tuple_elements = values + .pop() + .expect(INTERNAL_ERR) + .into_tuple() + .expect(INTERNAL_ERR); + ( + tuple_elements[0usize] + .clone() + .into_string() + .expect(INTERNAL_ERR), + tuple_elements[1usize] + .clone() + .into_string() + .expect(INTERNAL_ERR), + tuple_elements[2usize] + .clone() + .into_array() .expect(INTERNAL_ERR) - .into_tuple() - .expect(INTERNAL_ERR); - ( - tuple_elements[0usize] - .clone() - .into_string() - .expect(INTERNAL_ERR), - tuple_elements[1usize] - .clone() - .into_string() - .expect(INTERNAL_ERR), + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }) + .collect(), + ) + }, + settings_params: { + 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(), + { + let mut v = [0 as u8; 32]; tuple_elements[2usize] .clone() - .into_array() + .into_uint() .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }) - .collect(), - ) - }, - settings_params: { - let tuple_elements = values - .pop() - .expect(INTERNAL_ERR) - .into_tuple() - .expect(INTERNAL_ERR); - ( - tuple_elements[0usize] + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tuple_elements[3usize] + .clone() + .into_bool() + .expect(INTERNAL_ERR), + tuple_elements[4usize] + .clone() + .into_bool() + .expect(INTERNAL_ERR), + { + let mut v = [0 as u8; 32]; + tuple_elements[5usize] .clone() - .into_array() + .into_uint() .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }) - .collect(), - tuple_elements[1usize] + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + tuple_elements[6usize] .clone() - .into_array() + .into_uint() .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]; - 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_bool() - .expect(INTERNAL_ERR), - tuple_elements[4usize] - .clone() - .into_bool() - .expect(INTERNAL_ERR), - { - 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) - }, - { - let mut v = [0 as u8; 32]; - tuple_elements[6usize] - .clone() - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - ) - }, - owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - salt: { - 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::Tuple( - vec![ - ethabi::Token::String(self.params.0.clone()), - ethabi::Token::String(self.params.1.clone()), { let v = self - .params.2.iter().map(| inner | - ethabi::Token::Address(ethabi::Address::from_slice(& - inner))).collect(); ethabi::Token::Array(v) } - ], - ), - ethabi::Token::Tuple( - vec![ - { let v = self.settings_params.0.iter().map(| inner | - ethabi::Token::Address(ethabi::Address::from_slice(& - inner))).collect(); ethabi::Token::Array(v) }, { let v = - self.settings_params.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::Uint(ethabi::Uint::from_big_endian(match self - .settings_params.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::Bool(self.settings_params.3 - .clone()), ethabi::Token::Bool(self.settings_params.4 - .clone()), - ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self - .settings_params.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::Uint(ethabi::Uint::from_big_endian(match self - .settings_params.6.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.owner)), - ethabi::Token::FixedBytes(self.salt.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, 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(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, ) - .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 Create { - const NAME: &'static str = "create"; - 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 Create { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Disable {} - impl Disable { - const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; - 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 Disable { - const NAME: &'static str = "disable"; - 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({ + }, + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + salt: { let mut result = [0u8; 32]; let v = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .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 GetCreationCode {} - impl GetCreationCode { - const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; - 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::Bytes], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bytes() - .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 GetCreationCode { - const NAME: &'static str = "getCreationCode"; - 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 GetCreationCode { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCreationCodeContracts {} - impl GetCreationCodeContracts { - const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], - 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(), - 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<(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 GetCreationCodeContracts { - const NAME: &'static str = "getCreationCodeContracts"; - 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 GetCreationCodeContracts { - fn output(data: &[u8]) -> Result<(Vec, Vec), String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPauseConfiguration {} - impl GetPauseConfiguration { - const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; - 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(( + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::Tuple(vec![ + ethabi::Token::String(self.params.0.clone()), + ethabi::Token::String(self.params.1.clone()), { - 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 v = self + .params + .2 + .iter() + .map(|inner| { + ethabi::Token::Address(ethabi::Address::from_slice(&inner)) + }) + .collect(); + ethabi::Token::Array(v) + }, + ]), + ethabi::Token::Tuple(vec![ + { + let v = self + .settings_params + .0 + .iter() + .map(|inner| { + ethabi::Token::Address(ethabi::Address::from_slice(&inner)) + }) + .collect(); + ethabi::Token::Array(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 v = self + .settings_params + .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) }, - )) - } - 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 - } - } + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .settings_params + .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::Bool(self.settings_params.3.clone()), + ethabi::Token::Bool(self.settings_params.4.clone()), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .settings_params + .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::Uint(ethabi::Uint::from_big_endian( + match self + .settings_params + .6 + .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.owner)), + ethabi::Token::FixedBytes(self.salt.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, 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, } } - impl substreams_ethereum::Function for GetPauseConfiguration { - const NAME: &'static str = "getPauseConfiguration"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + 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; } - 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 GetPauseConfiguration { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolVersion {} - impl GetPoolVersion { - const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; - 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, + 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 } } - 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 GetPoolVersion { - const NAME: &'static str = "getPoolVersion"; - 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 GetPoolVersion { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetProtocolFeePercentagesProvider {} - impl GetProtocolFeePercentagesProvider { - const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { - const NAME: &'static str = "getProtocolFeePercentagesProvider"; - 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 GetProtocolFeePercentagesProvider { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetRecoveryModeHelper {} - impl GetRecoveryModeHelper { - const METHOD_ID: [u8; 4] = [138u8, 71u8, 174u8, 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, 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 GetRecoveryModeHelper { - const NAME: &'static str = "getRecoveryModeHelper"; - 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 GetRecoveryModeHelper { - fn output(data: &[u8]) -> Result, 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 GetWeightedMath {} - impl GetWeightedMath { - const METHOD_ID: [u8; 4] = [80u8, 143u8, 14u8, 174u8]; - 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 GetWeightedMath { - const NAME: &'static str = "getWeightedMath"; - 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 GetWeightedMath { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsDisabled {} - impl IsDisabled { - const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; - 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 IsDisabled { - const NAME: &'static str = "isDisabled"; - 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 IsDisabled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsPoolFromFactory { - pub pool: Vec, - } - impl IsPoolFromFactory { - const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; - 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 { - pool: 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.pool))], - ); - 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 IsPoolFromFactory { - const NAME: &'static str = "isPoolFromFactory"; - 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 IsPoolFromFactory { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[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 FactoryDisabled {} - impl FactoryDisabled { - const TOPIC_ID: [u8; 32] = [ - 67u8, - 42u8, - 203u8, - 253u8, - 102u8, - 45u8, - 187u8, - 93u8, - 139u8, - 55u8, - 131u8, - 132u8, - 166u8, - 113u8, - 89u8, - 180u8, - 124u8, - 169u8, - 208u8, - 241u8, - 183u8, - 159u8, - 151u8, - 207u8, - 100u8, - 207u8, - 133u8, - 133u8, - 250u8, - 54u8, - 45u8, - 80u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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 {}) + impl substreams_ethereum::Function for Create { + const NAME: &'static str = "create"; + 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 Create { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Disable {} + impl Disable { + const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; + 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::Event for FactoryDisabled { - const NAME: &'static str = "FactoryDisabled"; - 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) - } + } + impl substreams_ethereum::Function for Disable { + const NAME: &'static str = "disable"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCreated { - pub pool: Vec, + fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { + Self::decode(call) } - impl PoolCreated { - const TOPIC_ID: [u8; 32] = [ - 131u8, - 164u8, - 143u8, - 188u8, - 252u8, - 153u8, - 19u8, - 53u8, - 49u8, - 78u8, - 116u8, - 208u8, - 73u8, - 106u8, - 171u8, - 106u8, - 25u8, - 135u8, - 233u8, - 146u8, - 221u8, - 200u8, - 93u8, - 221u8, - 188u8, - 196u8, - 214u8, - 221u8, - 110u8, - 242u8, - 233u8, - 252u8, - ]; - 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; + 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()); } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + 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_address() + .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 GetCreationCode {} + impl GetCreationCode { + const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; + 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::Bytes], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok(values + .pop() + .expect("one output data should have existed") + .into_bytes() + .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 GetCreationCode { + const NAME: &'static str = "getCreationCode"; + 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 GetCreationCode { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCreationCodeContracts {} + impl GetCreationCodeContracts { + const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], + 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(), + 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<(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 GetCreationCodeContracts { + const NAME: &'static str = "getCreationCodeContracts"; + 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 GetCreationCodeContracts { + fn output(data: &[u8]) -> Result<(Vec, Vec), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPauseConfiguration {} + impl GetPauseConfiguration { + const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; + 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) - .as_bytes() - .to_vec(), - }) + .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, } } - impl substreams_ethereum::Event for PoolCreated { - const NAME: &'static str = "PoolCreated"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 + } } } - } \ No newline at end of file + } + impl substreams_ethereum::Function for GetPauseConfiguration { + const NAME: &'static str = "getPauseConfiguration"; + 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 GetPauseConfiguration + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolVersion {} + impl GetPoolVersion { + const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; + 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 GetPoolVersion { + const NAME: &'static str = "getPoolVersion"; + 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 GetPoolVersion { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeePercentagesProvider {} + impl GetProtocolFeePercentagesProvider { + const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { + const NAME: &'static str = "getProtocolFeePercentagesProvider"; + 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 GetProtocolFeePercentagesProvider { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRecoveryModeHelper {} + impl GetRecoveryModeHelper { + const METHOD_ID: [u8; 4] = [138u8, 71u8, 174u8, 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, 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 GetRecoveryModeHelper { + const NAME: &'static str = "getRecoveryModeHelper"; + 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 GetRecoveryModeHelper { + fn output(data: &[u8]) -> Result, 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 GetWeightedMath {} + impl GetWeightedMath { + const METHOD_ID: [u8; 4] = [80u8, 143u8, 14u8, 174u8]; + 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 GetWeightedMath { + const NAME: &'static str = "getWeightedMath"; + 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 GetWeightedMath { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsDisabled {} + impl IsDisabled { + const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; + 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 IsDisabled { + const NAME: &'static str = "isDisabled"; + 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 IsDisabled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsPoolFromFactory { + pub pool: Vec, + } + impl IsPoolFromFactory { + const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; + 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 { + pool: 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.pool))]); + 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 IsPoolFromFactory { + const NAME: &'static str = "isPoolFromFactory"; + 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 IsPoolFromFactory { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[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 FactoryDisabled {} + impl FactoryDisabled { + const TOPIC_ID: [u8; 32] = [ + 67u8, 42u8, 203u8, 253u8, 102u8, 45u8, 187u8, 93u8, 139u8, 55u8, 131u8, 132u8, 166u8, + 113u8, 89u8, 180u8, 124u8, 169u8, 208u8, 241u8, 183u8, 159u8, 151u8, 207u8, 100u8, + 207u8, 133u8, 133u8, 250u8, 54u8, 45u8, 80u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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 {}) + } + } + impl substreams_ethereum::Event for FactoryDisabled { + const NAME: &'static str = "FactoryDisabled"; + 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 PoolCreated { + pub pool: Vec, + } + impl PoolCreated { + const TOPIC_ID: [u8; 32] = [ + 131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8, + 106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8, + 196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8, + ]; + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for PoolCreated { + const NAME: &'static str = "PoolCreated"; + 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) + } + } +} diff --git a/substreams/ethereum-balancer/src/abi/mod.rs b/substreams/ethereum-balancer/src/abi/mod.rs index 0f60dc0..a5dff5e 100644 --- a/substreams/ethereum-balancer/src/abi/mod.rs +++ b/substreams/ethereum-balancer/src/abi/mod.rs @@ -1,11 +1,11 @@ #![allow(clippy::all)] -pub mod yearn_linear_pool_factory; pub mod composable_stable_pool_factory; -pub mod vault; -pub mod weighted_pool_tokens_factory; -pub mod silo_linear_pool_factory; -pub mod euler_linear_pool_factory; -pub mod weighted_pool_factory; -pub mod managed_pool_factory; pub mod erc_linear_pool_factory; +pub mod euler_linear_pool_factory; pub mod gearbox_linear_pool_factory; +pub mod managed_pool_factory; +pub mod silo_linear_pool_factory; +pub mod vault; +pub mod weighted_pool_factory; +pub mod weighted_pool_tokens_factory; +pub mod yearn_linear_pool_factory; diff --git a/substreams/ethereum-balancer/src/abi/silo_linear_pool_factory.rs b/substreams/ethereum-balancer/src/abi/silo_linear_pool_factory.rs index aa0a62e..a364d2d 100644 --- a/substreams/ethereum-balancer/src/abi/silo_linear_pool_factory.rs +++ b/substreams/ethereum-balancer/src/abi/silo_linear_pool_factory.rs @@ -1,1661 +1,1420 @@ - 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 Create { - pub name: String, - pub symbol: String, - pub main_token: Vec, - pub wrapped_token: Vec, - pub upper_target: substreams::scalar::BigInt, - pub swap_fee_percentage: substreams::scalar::BigInt, - pub owner: Vec, - pub protocol_id: substreams::scalar::BigInt, - pub salt: [u8; 32usize], - } - impl Create { - const METHOD_ID: [u8; 4] = [118u8, 137u8, 91u8, 231u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - main_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - wrapped_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - upper_target: { - 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) - }, - 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) - }, - owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - protocol_id: { - 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) - }, - salt: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - }) + +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 Create { + pub name: String, + pub symbol: String, + pub main_token: Vec, + pub wrapped_token: Vec, + pub upper_target: substreams::scalar::BigInt, + pub swap_fee_percentage: substreams::scalar::BigInt, + pub owner: Vec, + pub protocol_id: substreams::scalar::BigInt, + pub salt: [u8; 32usize], + } + impl Create { + const METHOD_ID: [u8; 4] = [118u8, 137u8, 91u8, 231u8]; + 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()); } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.main_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.wrapped_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.upper_target.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.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::Address(ethabi::Address::from_slice(&self.owner)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.protocol_id.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.salt.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, 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( + let mut values = ethabi::decode( + &[ + ethabi::ParamType::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedBytes(32usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + main_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + wrapped_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + upper_target: { + let mut v = [0 as u8; 32]; 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 Create { - const NAME: &'static str = "create"; - 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 Create { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Disable {} - impl Disable { - const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; - 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 Disable { - const NAME: &'static str = "disable"; - 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({ + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + 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) + }, + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + protocol_id: { + 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) + }, + salt: { let mut result = [0u8; 32]; let v = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .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 + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.main_token)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.wrapped_token)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.upper_target.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") + } } - } - } - } - 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 GetCreationCode {} - impl GetCreationCode { - const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; - 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::Bytes], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bytes() - .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 GetCreationCode { - const NAME: &'static str = "getCreationCode"; - 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 GetCreationCode { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCreationCodeContracts {} - impl GetCreationCodeContracts { - const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], - 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(), - 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<(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 GetCreationCodeContracts { - const NAME: &'static str = "getCreationCodeContracts"; - 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 GetCreationCodeContracts { - fn output(data: &[u8]) -> Result<(Vec, Vec), String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLastCreatedPool {} - impl GetLastCreatedPool { - const METHOD_ID: [u8; 4] = [94u8, 211u8, 18u8, 130u8]; - 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 GetLastCreatedPool { - const NAME: &'static str = "getLastCreatedPool"; - 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 GetLastCreatedPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPauseConfiguration {} - impl GetPauseConfiguration { - const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; - 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(( + .as_slice(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .swap_fee_percentage + .clone() + .to_bytes_be() { - 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 + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } } - } - } - } - impl substreams_ethereum::Function for GetPauseConfiguration { - const NAME: &'static str = "getPauseConfiguration"; - 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 GetPauseConfiguration { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolVersion {} - impl GetPoolVersion { - const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; - 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 + .as_slice(), + )), + ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.protocol_id.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.salt.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, 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 GetPoolVersion { - const NAME: &'static str = "getPoolVersion"; - 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 GetPoolVersion { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetProtocolFeePercentagesProvider {} - impl GetProtocolFeePercentagesProvider { - const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { - const NAME: &'static str = "getProtocolFeePercentagesProvider"; - 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 GetProtocolFeePercentagesProvider { - fn output(data: &[u8]) -> Result, 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 IsDisabled {} - impl IsDisabled { - const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; - 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 IsDisabled { - const NAME: &'static str = "isDisabled"; - 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 IsDisabled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsPoolFromFactory { - pub pool: Vec, - } - impl IsPoolFromFactory { - const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; - 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 { - pool: 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.pool))], - ); - 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 IsPoolFromFactory { - const NAME: &'static str = "isPoolFromFactory"; - 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 IsPoolFromFactory { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[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 FactoryDisabled {} - impl FactoryDisabled { - const TOPIC_ID: [u8; 32] = [ - 67u8, - 42u8, - 203u8, - 253u8, - 102u8, - 45u8, - 187u8, - 93u8, - 139u8, - 55u8, - 131u8, - 132u8, - 166u8, - 113u8, - 89u8, - 180u8, - 124u8, - 169u8, - 208u8, - 241u8, - 183u8, - 159u8, - 151u8, - 207u8, - 100u8, - 207u8, - 133u8, - 133u8, - 250u8, - 54u8, - 45u8, - 80u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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 {}) + impl substreams_ethereum::Function for Create { + const NAME: &'static str = "create"; + 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 Create { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Disable {} + impl Disable { + const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; + 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::Event for FactoryDisabled { - const NAME: &'static str = "FactoryDisabled"; - 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) - } + } + impl substreams_ethereum::Function for Disable { + const NAME: &'static str = "disable"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCreated { - pub pool: Vec, + fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { + Self::decode(call) } - impl PoolCreated { - const TOPIC_ID: [u8; 32] = [ - 131u8, - 164u8, - 143u8, - 188u8, - 252u8, - 153u8, - 19u8, - 53u8, - 49u8, - 78u8, - 116u8, - 208u8, - 73u8, - 106u8, - 171u8, - 106u8, - 25u8, - 135u8, - 233u8, - 146u8, - 221u8, - 200u8, - 93u8, - 221u8, - 188u8, - 196u8, - 214u8, - 221u8, - 110u8, - 242u8, - 233u8, - 252u8, - ]; - 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; + 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()); } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + 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_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .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, } } - impl substreams_ethereum::Event for PoolCreated { - const NAME: &'static str = "PoolCreated"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SiloLinearPoolCreated { - pub pool: Vec, - pub protocol_id: substreams::scalar::BigInt, - } - impl SiloLinearPoolCreated { - const TOPIC_ID: [u8; 32] = [ - 51u8, - 255u8, - 20u8, - 158u8, - 158u8, - 34u8, - 79u8, - 133u8, - 82u8, - 43u8, - 217u8, - 79u8, - 245u8, - 135u8, - 189u8, - 84u8, - 170u8, - 248u8, - 170u8, - 90u8, - 22u8, - 253u8, - 146u8, - 79u8, - 240u8, - 1u8, - 55u8, - 93u8, - 114u8, - 156u8, - 173u8, - 41u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; + 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 } - 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 { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + } + } + 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 GetCreationCode {} + impl GetCreationCode { + const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; + 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::Bytes], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok(values + .pop() + .expect("one output data should have existed") + .into_bytes() + .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 GetCreationCode { + const NAME: &'static str = "getCreationCode"; + 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 GetCreationCode { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCreationCodeContracts {} + impl GetCreationCodeContracts { + const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], + 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(), + 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<(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 GetCreationCodeContracts { + const NAME: &'static str = "getCreationCodeContracts"; + 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 GetCreationCodeContracts { + fn output(data: &[u8]) -> Result<(Vec, Vec), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLastCreatedPool {} + impl GetLastCreatedPool { + const METHOD_ID: [u8; 4] = [94u8, 211u8, 18u8, 130u8]; + 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 GetLastCreatedPool { + const NAME: &'static str = "getLastCreatedPool"; + 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 GetLastCreatedPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPauseConfiguration {} + impl GetPauseConfiguration { + const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; + 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - protocol_id: { - let mut v = [0 as u8; 32]; - ethabi::decode( + .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 GetPauseConfiguration { + const NAME: &'static str = "getPauseConfiguration"; + 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 GetPauseConfiguration + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolVersion {} + impl GetPoolVersion { + const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; + 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 GetPoolVersion { + const NAME: &'static str = "getPoolVersion"; + 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 GetPoolVersion { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeePercentagesProvider {} + impl GetProtocolFeePercentagesProvider { + const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { + const NAME: &'static str = "getProtocolFeePercentagesProvider"; + 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 GetProtocolFeePercentagesProvider { + fn output(data: &[u8]) -> Result, 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 IsDisabled {} + impl IsDisabled { + const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; + 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 IsDisabled { + const NAME: &'static str = "isDisabled"; + 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 IsDisabled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsPoolFromFactory { + pub pool: Vec, + } + impl IsPoolFromFactory { + const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; + 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 { + pool: 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.pool))]); + 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 IsPoolFromFactory { + const NAME: &'static str = "isPoolFromFactory"; + 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 IsPoolFromFactory { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[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 FactoryDisabled {} + impl FactoryDisabled { + const TOPIC_ID: [u8; 32] = [ + 67u8, 42u8, 203u8, 253u8, 102u8, 45u8, 187u8, 93u8, 139u8, 55u8, 131u8, 132u8, 166u8, + 113u8, 89u8, 180u8, 124u8, 169u8, 208u8, 241u8, 183u8, 159u8, 151u8, 207u8, 100u8, + 207u8, 133u8, 133u8, 250u8, 54u8, 45u8, 80u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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 {}) + } + } + impl substreams_ethereum::Event for FactoryDisabled { + const NAME: &'static str = "FactoryDisabled"; + 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 PoolCreated { + pub pool: Vec, + } + impl PoolCreated { + const TOPIC_ID: [u8; 32] = [ + 131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8, + 106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8, + 196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8, + ]; + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for PoolCreated { + const NAME: &'static str = "PoolCreated"; + 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 SiloLinearPoolCreated { + pub pool: Vec, + pub protocol_id: substreams::scalar::BigInt, + } + impl SiloLinearPoolCreated { + const TOPIC_ID: [u8; 32] = [ + 51u8, 255u8, 20u8, 158u8, 158u8, 34u8, 79u8, 133u8, 82u8, 43u8, 217u8, 79u8, 245u8, + 135u8, 189u8, 84u8, 170u8, 248u8, 170u8, 90u8, 22u8, 253u8, 146u8, 79u8, 240u8, 1u8, + 55u8, 93u8, 114u8, 156u8, 173u8, 41u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + protocol_id: { + let mut v = [0 as u8; 32]; + ethabi::decode( &[ethabi::ParamType::Uint(256usize)], log.topics[2usize].as_ref(), ) @@ -1670,20 +1429,18 @@ .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for SiloLinearPoolCreated { - const NAME: &'static str = "SiloLinearPoolCreated"; - 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) - } + } + impl substreams_ethereum::Event for SiloLinearPoolCreated { + const NAME: &'static str = "SiloLinearPoolCreated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - } \ No newline at end of file + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} diff --git a/substreams/ethereum-balancer/src/abi/vault.rs b/substreams/ethereum-balancer/src/abi/vault.rs index ec00beb..7502e66 100644 --- a/substreams/ethereum-balancer/src/abi/vault.rs +++ b/substreams/ethereum-balancer/src/abi/vault.rs @@ -1,3568 +1,153 @@ - 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 {}) + +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 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 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; } - 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 - } + 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::Function for Weth { + const NAME: &'static str = "WETH"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Weth { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { + Self::decode(call) } - #[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, + fn encode(&self) -> Vec { + self.encode() } - 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::rpc::RPCDecodable> for Weth { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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({ + } + #[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("one output data should have existed") + .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 { - 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); + }, + 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]; @@ -3582,13 +167,2167 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - tuple_elements[2usize] + { + 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_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - tuple_elements[3usize] + .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) @@ -3596,270 +2335,1219 @@ .to_vec(), { let mut v = [0 as u8; 32]; - tuple_elements[4usize] + 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[5usize] - .clone() - .into_bytes() - .expect(INTERNAL_ERR), ) - }, - funds: { - let tuple_elements = values - .pop() - .expect(INTERNAL_ERR) - .into_tuple() - .expect(INTERNAL_ERR); + }) + .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); ( - tuple_elements[0usize] - .clone() - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + { + 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_bool() - .expect(INTERNAL_ERR), - tuple_elements[2usize] + .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[3usize] + tuple_elements[4usize] .clone() - .into_bool() - .expect(INTERNAL_ERR), + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), ) - }, - 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() { + }) + .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::Uint( - ethabi::Uint::from_big_endian( - match self.deadline.clone().to_bytes_be() { + .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(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + .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, } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) + } + } + 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()); } - 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 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("one output data should have existed") + .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 { - 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 + }, + 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 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 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) } - 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; + 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()); } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { + 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(), @@ -3877,543 +3565,368 @@ .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) - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct ExternalBalanceTransfer { - pub token: Vec, - pub sender: Vec, - pub recipient: Vec, - pub amount: substreams::scalar::BigInt, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - 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; + } + #[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; } - 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(), + 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 ) - .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(), + })? + .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 ) - .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sender: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + .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 ) - .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(), + })? + .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 ) - .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(), + delta: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .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) - }, - }) - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_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) - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct InternalBalanceChanged { - pub user: Vec, - pub token: Vec, - pub delta: substreams::scalar::BigInt, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - 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; + } + #[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; } - 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) - }, - }) + if log.data.len() != 32usize { + return false; } + return log + .topics + .get(0) + .expect("bounds already checked") + .as_ref() + == Self::TOPIC_ID; } - 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) - } + 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), + }) } - #[derive(Debug, Clone, PartialEq)] - pub struct PausedStateChanged { - pub paused: bool, + } + 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) } - 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), - }) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - 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) + } + #[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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + if log.data.len() < 192usize { + return false; } + return log + .topics + .get(0) + .expect("bounds already checked") + .as_ref() + == Self::TOPIC_ID; } - #[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 { + 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( @@ -4490,779 +4003,586 @@ }) .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) - } + } + 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) } - #[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, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - 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; + } + #[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; } - 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(), + 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 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 'pool_id' from topic of type 'bytes32': {:?}", + e ) - .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(), + })? + .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 ) - .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(), + })? + .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 ) - .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(), + cash_delta: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .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) - }, - }) - } + .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 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) - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct RelayerApprovalChanged { - pub relayer: Vec, - pub sender: Vec, - pub approved: bool, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - 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; + } + #[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; } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - log.data.as_ref(), + 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 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 'pool_id' from topic of type 'bytes32': {:?}", + e ) - .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(), + })? + .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 ) - .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(), + })? + .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 ) - .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(), + })? + .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 ) - .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) - }, - }) - } + })? + .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 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) - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct TokensDeregistered { - pub pool_id: [u8; 32usize], - pub tokens: Vec>, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - 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; + } + #[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; } - 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(), + 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 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 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 ) - .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() + })? + .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) - .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(), - }) - } + .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) - } + } + 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) } - } \ No newline at end of file + 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) + } + } +} diff --git a/substreams/ethereum-balancer/src/abi/weighted_pool_factory.rs b/substreams/ethereum-balancer/src/abi/weighted_pool_factory.rs index db4e2bc..52e94bb 100644 --- a/substreams/ethereum-balancer/src/abi/weighted_pool_factory.rs +++ b/substreams/ethereum-balancer/src/abi/weighted_pool_factory.rs @@ -1,1511 +1,1316 @@ - 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 Create { - pub name: String, - pub symbol: String, - pub tokens: Vec>, - pub normalized_weights: Vec, - pub rate_providers: Vec>, - pub swap_fee_percentage: substreams::scalar::BigInt, - pub owner: Vec, - pub salt: [u8; 32usize], - } - impl Create { - const METHOD_ID: [u8; 4] = [33u8, 130u8, 200u8, 254u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Address), - ), - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Uint(256usize)), - ), - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Address), - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - 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(), - normalized_weights: 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(), - rate_providers: 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(), - swap_fee_percentage: { - let mut v = [0 as u8; 32]; - values - .pop() + +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 Create { + pub name: String, + pub symbol: String, + pub tokens: Vec>, + pub normalized_weights: Vec, + pub rate_providers: Vec>, + pub swap_fee_percentage: substreams::scalar::BigInt, + pub owner: Vec, + pub salt: [u8; 32usize], + } + impl Create { + const METHOD_ID: [u8; 4] = [33u8, 130u8, 200u8, 254u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::FixedBytes(32usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + 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(), + normalized_weights: 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) - }, - owner: values + }) + .collect(), + rate_providers: 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(), + swap_fee_percentage: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - salt: { - 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::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .tokens - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::Array(v) - }, - { - let v = self - .normalized_weights - .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) - }, - { - let v = self - .rate_providers - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::Array(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.swap_fee_percentage.clone().to_bytes_be() { + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + salt: { + 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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .tokens + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .normalized_weights + .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(), - ), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), - ethabi::Token::FixedBytes(self.salt.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, 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 + .as_slice(), + )) + }) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .rate_providers + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::Array(v) + }, + 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(), + )), + ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), + ethabi::Token::FixedBytes(self.salt.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, 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 Create { - const NAME: &'static str = "create"; - 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::Function for Create { + const NAME: &'static str = "create"; + 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 Create { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Disable {} + impl Disable { + const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; + 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::rpc::RPCDecodable> for Create { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + } + impl substreams_ethereum::Function for Disable { + const NAME: &'static str = "disable"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Disable {} - impl Disable { - const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; - 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, - } - } + fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for Disable { - const NAME: &'static str = "disable"; - 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() - } + 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(), - ) + } + #[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]; + values.reverse(); + Ok(Self { + selector: { + let mut result = [0u8; 4]; let v = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .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() - } + 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 } - impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for GetActionId { - fn output(data: &[u8]) -> Result<[u8; 32usize], String> { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) } - #[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(), - ) + 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( - 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 - } - } + 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, } } - 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) + 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; } - 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 GetCreationCode {} - impl GetCreationCode { - const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; - 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::Bytes], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bytes() - .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, + 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 } } - 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 GetCreationCode { - const NAME: &'static str = "getCreationCode"; - 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 GetCreationCode { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCreationCodeContracts {} - impl GetCreationCodeContracts { - const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], - 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(), - 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<(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 GetCreationCodeContracts { - const NAME: &'static str = "getCreationCodeContracts"; - 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 GetCreationCodeContracts { - fn output(data: &[u8]) -> Result<(Vec, Vec), String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPauseConfiguration {} - impl GetPauseConfiguration { - const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; - 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 GetPauseConfiguration { - const NAME: &'static str = "getPauseConfiguration"; - 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 GetPauseConfiguration { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolVersion {} - impl GetPoolVersion { - const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; - 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 GetPoolVersion { - const NAME: &'static str = "getPoolVersion"; - 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 GetPoolVersion { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetProtocolFeePercentagesProvider {} - impl GetProtocolFeePercentagesProvider { - const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { - const NAME: &'static str = "getProtocolFeePercentagesProvider"; - 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 GetProtocolFeePercentagesProvider { - fn output(data: &[u8]) -> Result, 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 IsDisabled {} - impl IsDisabled { - const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; - 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 IsDisabled { - const NAME: &'static str = "isDisabled"; - 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 IsDisabled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsPoolFromFactory { - pub pool: Vec, - } - impl IsPoolFromFactory { - const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; - 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 { - pool: 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.pool))], - ); - 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 IsPoolFromFactory { - const NAME: &'static str = "isPoolFromFactory"; - 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 IsPoolFromFactory { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[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 FactoryDisabled {} - impl FactoryDisabled { - const TOPIC_ID: [u8; 32] = [ - 67u8, - 42u8, - 203u8, - 253u8, - 102u8, - 45u8, - 187u8, - 93u8, - 139u8, - 55u8, - 131u8, - 132u8, - 166u8, - 113u8, - 89u8, - 180u8, - 124u8, - 169u8, - 208u8, - 241u8, - 183u8, - 159u8, - 151u8, - 207u8, - 100u8, - 207u8, - 133u8, - 133u8, - 250u8, - 54u8, - 45u8, - 80u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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 {}) + 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, } } - impl substreams_ethereum::Event for FactoryDisabled { - const NAME: &'static str = "FactoryDisabled"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCreated { - pub pool: Vec, + } + 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) } - impl PoolCreated { - const TOPIC_ID: [u8; 32] = [ - 131u8, - 164u8, - 143u8, - 188u8, - 252u8, - 153u8, - 19u8, - 53u8, - 49u8, - 78u8, - 116u8, - 208u8, - 73u8, - 106u8, - 171u8, - 106u8, - 25u8, - 135u8, - 233u8, - 146u8, - 221u8, - 200u8, - 93u8, - 221u8, - 188u8, - 196u8, - 214u8, - 221u8, - 110u8, - 242u8, - 233u8, - 252u8, - ]; - 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; + 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 GetCreationCode {} + impl GetCreationCode { + const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; + 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::Bytes], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok(values + .pop() + .expect("one output data should have existed") + .into_bytes() + .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 decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + } + 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 GetCreationCode { + const NAME: &'static str = "getCreationCode"; + 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 GetCreationCode { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCreationCodeContracts {} + impl GetCreationCodeContracts { + const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], + 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(), + 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<(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 GetCreationCodeContracts { + const NAME: &'static str = "getCreationCodeContracts"; + 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 GetCreationCodeContracts { + fn output(data: &[u8]) -> Result<(Vec, Vec), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPauseConfiguration {} + impl GetPauseConfiguration { + const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; + 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .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, } } - impl substreams_ethereum::Event for PoolCreated { - const NAME: &'static str = "PoolCreated"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 + } } } - } \ No newline at end of file + } + impl substreams_ethereum::Function for GetPauseConfiguration { + const NAME: &'static str = "getPauseConfiguration"; + 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 GetPauseConfiguration + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolVersion {} + impl GetPoolVersion { + const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; + 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 GetPoolVersion { + const NAME: &'static str = "getPoolVersion"; + 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 GetPoolVersion { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeePercentagesProvider {} + impl GetProtocolFeePercentagesProvider { + const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { + const NAME: &'static str = "getProtocolFeePercentagesProvider"; + 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 GetProtocolFeePercentagesProvider { + fn output(data: &[u8]) -> Result, 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 IsDisabled {} + impl IsDisabled { + const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; + 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 IsDisabled { + const NAME: &'static str = "isDisabled"; + 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 IsDisabled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsPoolFromFactory { + pub pool: Vec, + } + impl IsPoolFromFactory { + const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; + 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 { + pool: 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.pool))]); + 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 IsPoolFromFactory { + const NAME: &'static str = "isPoolFromFactory"; + 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 IsPoolFromFactory { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[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 FactoryDisabled {} + impl FactoryDisabled { + const TOPIC_ID: [u8; 32] = [ + 67u8, 42u8, 203u8, 253u8, 102u8, 45u8, 187u8, 93u8, 139u8, 55u8, 131u8, 132u8, 166u8, + 113u8, 89u8, 180u8, 124u8, 169u8, 208u8, 241u8, 183u8, 159u8, 151u8, 207u8, 100u8, + 207u8, 133u8, 133u8, 250u8, 54u8, 45u8, 80u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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 {}) + } + } + impl substreams_ethereum::Event for FactoryDisabled { + const NAME: &'static str = "FactoryDisabled"; + 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 PoolCreated { + pub pool: Vec, + } + impl PoolCreated { + const TOPIC_ID: [u8; 32] = [ + 131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8, + 106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8, + 196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8, + ]; + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for PoolCreated { + const NAME: &'static str = "PoolCreated"; + 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) + } + } +} diff --git a/substreams/ethereum-balancer/src/abi/weighted_pool_tokens_factory.rs b/substreams/ethereum-balancer/src/abi/weighted_pool_tokens_factory.rs index 95f7262..3d7ec40 100644 --- a/substreams/ethereum-balancer/src/abi/weighted_pool_tokens_factory.rs +++ b/substreams/ethereum-balancer/src/abi/weighted_pool_tokens_factory.rs @@ -1,641 +1,558 @@ - 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 Create { - pub name: String, - pub symbol: String, - pub tokens: Vec>, - pub weights: Vec, - pub swap_fee_percentage: substreams::scalar::BigInt, - pub oracle_enabled: bool, - pub owner: Vec, - } - impl Create { - const METHOD_ID: [u8; 4] = [21u8, 150u8, 1u8, 155u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Address), - ), - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Uint(256usize)), - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - 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(), - weights: 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(), - swap_fee_percentage: { - let mut v = [0 as u8; 32]; - values - .pop() + +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 Create { + pub name: String, + pub symbol: String, + pub tokens: Vec>, + pub weights: Vec, + pub swap_fee_percentage: substreams::scalar::BigInt, + pub oracle_enabled: bool, + pub owner: Vec, + } + impl Create { + const METHOD_ID: [u8; 4] = [21u8, 150u8, 1u8, 155u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, + ethabi::ParamType::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + 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(), + weights: 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) - }, - oracle_enabled: values + }) + .collect(), + swap_fee_percentage: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - owner: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .tokens - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::Array(v) - }, - { - let v = self - .weights - .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.swap_fee_percentage.clone().to_bytes_be() { + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + oracle_enabled: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + 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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .tokens + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .weights + .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(), - ), - ), - ethabi::Token::Bool(self.oracle_enabled.clone()), - 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, 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 Create { - const NAME: &'static str = "create"; - 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 Create { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPauseConfiguration {} - impl GetPauseConfiguration { - const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; - 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(( + .as_slice(), + )) + }) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .swap_fee_percentage + .clone() + .to_bytes_be() { - 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 + (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::Bool(self.oracle_enabled.clone()), + 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, 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 GetPauseConfiguration { - const NAME: &'static str = "getPauseConfiguration"; - 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 GetPauseConfiguration { - fn output( - data: &[u8], - ) -> Result< - (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 IsPoolFromFactory { - pub pool: Vec, - } - impl IsPoolFromFactory { - const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; - 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 { - pool: 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.pool))], - ); - 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 IsPoolFromFactory { - const NAME: &'static str = "isPoolFromFactory"; - 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 IsPoolFromFactory { - 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 PoolCreated { - pub pool: Vec, + impl substreams_ethereum::Function for Create { + const NAME: &'static str = "create"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl PoolCreated { - const TOPIC_ID: [u8; 32] = [ - 131u8, - 164u8, - 143u8, - 188u8, - 252u8, - 153u8, - 19u8, - 53u8, - 49u8, - 78u8, - 116u8, - 208u8, - 73u8, - 106u8, - 171u8, - 106u8, - 25u8, - 135u8, - 233u8, - 146u8, - 221u8, - 200u8, - 93u8, - 221u8, - 188u8, - 196u8, - 214u8, - 221u8, - 110u8, - 242u8, - 233u8, - 252u8, - ]; - 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 { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + 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 Create { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPauseConfiguration {} + impl GetPauseConfiguration { + const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; + 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .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, } } - impl substreams_ethereum::Event for PoolCreated { - const NAME: &'static str = "PoolCreated"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 + } } } - } \ No newline at end of file + } + impl substreams_ethereum::Function for GetPauseConfiguration { + const NAME: &'static str = "getPauseConfiguration"; + 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 GetPauseConfiguration + { + fn output( + data: &[u8], + ) -> Result<(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 IsPoolFromFactory { + pub pool: Vec, + } + impl IsPoolFromFactory { + const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; + 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 { + pool: 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.pool))]); + 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 IsPoolFromFactory { + const NAME: &'static str = "isPoolFromFactory"; + 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 IsPoolFromFactory { + 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 PoolCreated { + pub pool: Vec, + } + impl PoolCreated { + const TOPIC_ID: [u8; 32] = [ + 131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8, + 106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8, + 196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8, + ]; + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for PoolCreated { + const NAME: &'static str = "PoolCreated"; + 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) + } + } +} diff --git a/substreams/ethereum-balancer/src/abi/yearn_linear_pool_factory.rs b/substreams/ethereum-balancer/src/abi/yearn_linear_pool_factory.rs index b5fbe27..5fec933 100644 --- a/substreams/ethereum-balancer/src/abi/yearn_linear_pool_factory.rs +++ b/substreams/ethereum-balancer/src/abi/yearn_linear_pool_factory.rs @@ -1,1661 +1,1420 @@ - 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 Create { - pub name: String, - pub symbol: String, - pub main_token: Vec, - pub wrapped_token: Vec, - pub upper_target: substreams::scalar::BigInt, - pub swap_fee_percentage: substreams::scalar::BigInt, - pub owner: Vec, - pub protocol_id: substreams::scalar::BigInt, - pub salt: [u8; 32usize], - } - impl Create { - const METHOD_ID: [u8; 4] = [118u8, 137u8, 91u8, 231u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - main_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - wrapped_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - upper_target: { - 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) - }, - 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) - }, - owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - protocol_id: { - 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) - }, - salt: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - }) + +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 Create { + pub name: String, + pub symbol: String, + pub main_token: Vec, + pub wrapped_token: Vec, + pub upper_target: substreams::scalar::BigInt, + pub swap_fee_percentage: substreams::scalar::BigInt, + pub owner: Vec, + pub protocol_id: substreams::scalar::BigInt, + pub salt: [u8; 32usize], + } + impl Create { + const METHOD_ID: [u8; 4] = [118u8, 137u8, 91u8, 231u8]; + 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()); } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.main_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.wrapped_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.upper_target.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.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::Address(ethabi::Address::from_slice(&self.owner)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.protocol_id.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.salt.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, 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( + let mut values = ethabi::decode( + &[ + ethabi::ParamType::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedBytes(32usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + main_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + wrapped_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + upper_target: { + let mut v = [0 as u8; 32]; 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 Create { - const NAME: &'static str = "create"; - 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 Create { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Disable {} - impl Disable { - const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; - 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 Disable { - const NAME: &'static str = "disable"; - 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({ + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + 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) + }, + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + protocol_id: { + 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) + }, + salt: { let mut result = [0u8; 32]; let v = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .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 + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.main_token)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.wrapped_token)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.upper_target.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") + } } - } - } - } - 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 GetCreationCode {} - impl GetCreationCode { - const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; - 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::Bytes], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bytes() - .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 GetCreationCode { - const NAME: &'static str = "getCreationCode"; - 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 GetCreationCode { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCreationCodeContracts {} - impl GetCreationCodeContracts { - const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], - 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(), - 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<(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 GetCreationCodeContracts { - const NAME: &'static str = "getCreationCodeContracts"; - 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 GetCreationCodeContracts { - fn output(data: &[u8]) -> Result<(Vec, Vec), String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLastCreatedPool {} - impl GetLastCreatedPool { - const METHOD_ID: [u8; 4] = [94u8, 211u8, 18u8, 130u8]; - 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 GetLastCreatedPool { - const NAME: &'static str = "getLastCreatedPool"; - 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 GetLastCreatedPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPauseConfiguration {} - impl GetPauseConfiguration { - const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; - 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(( + .as_slice(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .swap_fee_percentage + .clone() + .to_bytes_be() { - 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 + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } } - } - } - } - impl substreams_ethereum::Function for GetPauseConfiguration { - const NAME: &'static str = "getPauseConfiguration"; - 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 GetPauseConfiguration { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolVersion {} - impl GetPoolVersion { - const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; - 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 + .as_slice(), + )), + ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.protocol_id.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.salt.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, 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 GetPoolVersion { - const NAME: &'static str = "getPoolVersion"; - 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 GetPoolVersion { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetProtocolFeePercentagesProvider {} - impl GetProtocolFeePercentagesProvider { - const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { - const NAME: &'static str = "getProtocolFeePercentagesProvider"; - 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 GetProtocolFeePercentagesProvider { - fn output(data: &[u8]) -> Result, 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 IsDisabled {} - impl IsDisabled { - const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; - 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 IsDisabled { - const NAME: &'static str = "isDisabled"; - 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 IsDisabled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsPoolFromFactory { - pub pool: Vec, - } - impl IsPoolFromFactory { - const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; - 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 { - pool: 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.pool))], - ); - 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 IsPoolFromFactory { - const NAME: &'static str = "isPoolFromFactory"; - 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 IsPoolFromFactory { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[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 FactoryDisabled {} - impl FactoryDisabled { - const TOPIC_ID: [u8; 32] = [ - 67u8, - 42u8, - 203u8, - 253u8, - 102u8, - 45u8, - 187u8, - 93u8, - 139u8, - 55u8, - 131u8, - 132u8, - 166u8, - 113u8, - 89u8, - 180u8, - 124u8, - 169u8, - 208u8, - 241u8, - 183u8, - 159u8, - 151u8, - 207u8, - 100u8, - 207u8, - 133u8, - 133u8, - 250u8, - 54u8, - 45u8, - 80u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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 {}) + impl substreams_ethereum::Function for Create { + const NAME: &'static str = "create"; + 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 Create { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Disable {} + impl Disable { + const METHOD_ID: [u8; 4] = [47u8, 39u8, 112u8, 219u8]; + 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::Event for FactoryDisabled { - const NAME: &'static str = "FactoryDisabled"; - 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) - } + } + impl substreams_ethereum::Function for Disable { + const NAME: &'static str = "disable"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCreated { - pub pool: Vec, + fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { + Self::decode(call) } - impl PoolCreated { - const TOPIC_ID: [u8; 32] = [ - 131u8, - 164u8, - 143u8, - 188u8, - 252u8, - 153u8, - 19u8, - 53u8, - 49u8, - 78u8, - 116u8, - 208u8, - 73u8, - 106u8, - 171u8, - 106u8, - 25u8, - 135u8, - 233u8, - 146u8, - 221u8, - 200u8, - 93u8, - 221u8, - 188u8, - 196u8, - 214u8, - 221u8, - 110u8, - 242u8, - 233u8, - 252u8, - ]; - 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; + 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()); } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + 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_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .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, } } - impl substreams_ethereum::Event for PoolCreated { - const NAME: &'static str = "PoolCreated"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct YearnLinearPoolCreated { - pub pool: Vec, - pub protocol_id: substreams::scalar::BigInt, - } - impl YearnLinearPoolCreated { - const TOPIC_ID: [u8; 32] = [ - 218u8, - 47u8, - 85u8, - 125u8, - 110u8, - 128u8, - 210u8, - 220u8, - 243u8, - 137u8, - 79u8, - 43u8, - 183u8, - 79u8, - 233u8, - 132u8, - 14u8, - 77u8, - 85u8, - 142u8, - 53u8, - 15u8, - 106u8, - 173u8, - 99u8, - 175u8, - 14u8, - 11u8, - 18u8, - 241u8, - 165u8, - 134u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; + 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 } - 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 { - pool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'pool' from topic of type 'address': {:?}", - e - ) - })? + } + } + 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 GetCreationCode {} + impl GetCreationCode { + const METHOD_ID: [u8; 4] = [0u8, 193u8, 148u8, 219u8]; + 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::Bytes], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok(values + .pop() + .expect("one output data should have existed") + .into_bytes() + .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 GetCreationCode { + const NAME: &'static str = "getCreationCode"; + 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 GetCreationCode { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCreationCodeContracts {} + impl GetCreationCodeContracts { + const METHOD_ID: [u8; 4] = [23u8, 68u8, 129u8, 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<(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::Address, ethabi::ParamType::Address], + 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(), + 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<(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 GetCreationCodeContracts { + const NAME: &'static str = "getCreationCodeContracts"; + 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 GetCreationCodeContracts { + fn output(data: &[u8]) -> Result<(Vec, Vec), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLastCreatedPool {} + impl GetLastCreatedPool { + const METHOD_ID: [u8; 4] = [94u8, 211u8, 18u8, 130u8]; + 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 GetLastCreatedPool { + const NAME: &'static str = "getLastCreatedPool"; + 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 GetLastCreatedPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPauseConfiguration {} + impl GetPauseConfiguration { + const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; + 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - protocol_id: { - let mut v = [0 as u8; 32]; - ethabi::decode( + .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 GetPauseConfiguration { + const NAME: &'static str = "getPauseConfiguration"; + 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 GetPauseConfiguration + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolVersion {} + impl GetPoolVersion { + const METHOD_ID: [u8; 4] = [63u8, 129u8, 155u8, 111u8]; + 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 GetPoolVersion { + const NAME: &'static str = "getPoolVersion"; + 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 GetPoolVersion { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetProtocolFeePercentagesProvider {} + impl GetProtocolFeePercentagesProvider { + const METHOD_ID: [u8; 4] = [115u8, 146u8, 56u8, 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 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 GetProtocolFeePercentagesProvider { + const NAME: &'static str = "getProtocolFeePercentagesProvider"; + 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 GetProtocolFeePercentagesProvider { + fn output(data: &[u8]) -> Result, 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 IsDisabled {} + impl IsDisabled { + const METHOD_ID: [u8; 4] = [108u8, 87u8, 245u8, 169u8]; + 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 IsDisabled { + const NAME: &'static str = "isDisabled"; + 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 IsDisabled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsPoolFromFactory { + pub pool: Vec, + } + impl IsPoolFromFactory { + const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; + 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 { + pool: 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.pool))]); + 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 IsPoolFromFactory { + const NAME: &'static str = "isPoolFromFactory"; + 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 IsPoolFromFactory { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[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 FactoryDisabled {} + impl FactoryDisabled { + const TOPIC_ID: [u8; 32] = [ + 67u8, 42u8, 203u8, 253u8, 102u8, 45u8, 187u8, 93u8, 139u8, 55u8, 131u8, 132u8, 166u8, + 113u8, 89u8, 180u8, 124u8, 169u8, 208u8, 241u8, 183u8, 159u8, 151u8, 207u8, 100u8, + 207u8, 133u8, 133u8, 250u8, 54u8, 45u8, 80u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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 {}) + } + } + impl substreams_ethereum::Event for FactoryDisabled { + const NAME: &'static str = "FactoryDisabled"; + 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 PoolCreated { + pub pool: Vec, + } + impl PoolCreated { + const TOPIC_ID: [u8; 32] = [ + 131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8, + 106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8, + 196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8, + ]; + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for PoolCreated { + const NAME: &'static str = "PoolCreated"; + 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 YearnLinearPoolCreated { + pub pool: Vec, + pub protocol_id: substreams::scalar::BigInt, + } + impl YearnLinearPoolCreated { + const TOPIC_ID: [u8; 32] = [ + 218u8, 47u8, 85u8, 125u8, 110u8, 128u8, 210u8, 220u8, 243u8, 137u8, 79u8, 43u8, 183u8, + 79u8, 233u8, 132u8, 14u8, 77u8, 85u8, 142u8, 53u8, 15u8, 106u8, 173u8, 99u8, 175u8, + 14u8, 11u8, 18u8, 241u8, 165u8, 134u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + 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 { + pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'pool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + protocol_id: { + let mut v = [0 as u8; 32]; + ethabi::decode( &[ethabi::ParamType::Uint(256usize)], log.topics[2usize].as_ref(), ) @@ -1670,20 +1429,18 @@ .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for YearnLinearPoolCreated { - const NAME: &'static str = "YearnLinearPoolCreated"; - 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) - } + } + impl substreams_ethereum::Event for YearnLinearPoolCreated { + const NAME: &'static str = "YearnLinearPoolCreated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - } \ No newline at end of file + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} diff --git a/substreams/ethereum-balancer/src/modules.rs b/substreams/ethereum-balancer/src/modules.rs index 3804bd8..99f28f6 100644 --- a/substreams/ethereum-balancer/src/modules.rs +++ b/substreams/ethereum-balancer/src/modules.rs @@ -176,14 +176,17 @@ pub fn map_protocol_changes( .or_insert_with(|| TransactionChangesBuilder::new(tx)); // iterate over individual components created within this tx - tx_component.components.iter().for_each(|component| { - builder.add_protocol_component(component); - let entity_change = EntityChanges { - component_id: component.id.clone(), - attributes: default_attributes.clone(), - }; - builder.add_entity_change(&entity_change) - }); + tx_component + .components + .iter() + .for_each(|component| { + builder.add_protocol_component(component); + let entity_change = EntityChanges { + component_id: component.id.clone(), + attributes: default_attributes.clone(), + }; + builder.add_entity_change(&entity_change) + }); }); // Balance changes are gathered by the `StoreDelta` based on `PoolBalanceChanged` creating @@ -196,7 +199,9 @@ pub fn map_protocol_changes( let builder = transaction_changes .entry(tx.index) .or_insert_with(|| TransactionChangesBuilder::new(&tx)); - balances.values().for_each(|bc| builder.add_balance_change(bc)); + balances + .values() + .for_each(|bc| builder.add_balance_change(bc)); }); // Extract and insert any storage changes that happened for any of the components. @@ -211,16 +216,23 @@ pub fn map_protocol_changes( &mut transaction_changes, ); - transaction_changes.iter_mut().for_each(|(_, change)| { - // this indirection is necessary due to borrowing rules. - let addresses = change.changed_contracts().map(|e| e.to_vec()).collect::>(); - addresses.into_iter().for_each(|address| { - if address != VAULT_ADDRESS { - // We reconstruct the component_id from the address here - change.mark_component_as_updated(&format!("0x{}", hex::encode(address))) - } - }) - }); + transaction_changes + .iter_mut() + .for_each(|(_, change)| { + // this indirection is necessary due to borrowing rules. + let addresses = change + .changed_contracts() + .map(|e| e.to_vec()) + .collect::>(); + addresses + .into_iter() + .for_each(|address| { + if address != VAULT_ADDRESS { + // We reconstruct the component_id from the address here + change.mark_component_as_updated(&format!("0x{}", hex::encode(address))) + } + }) + }); // Process all `transaction_changes` for final output in the `BlockChanges`, // sorted by transaction index (the key). @@ -229,9 +241,7 @@ pub fn map_protocol_changes( changes: transaction_changes .drain() .sorted_unstable_by_key(|(index, _)| *index) - .filter_map(|(_, builder)| { - builder.build() - }) + .filter_map(|(_, builder)| builder.build()) .collect::>(), }) } diff --git a/substreams/ethereum-curve/src/abi/crypto_pool_factory.rs b/substreams/ethereum-curve/src/abi/crypto_pool_factory.rs index ed4ab59..87158e2 100644 --- a/substreams/ethereum-curve/src/abi/crypto_pool_factory.rs +++ b/substreams/ethereum-curve/src/abi/crypto_pool_factory.rs @@ -1,3551 +1,3023 @@ - 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 AcceptTransferOwnership {} - impl AcceptTransferOwnership { - const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 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 AcceptTransferOwnership { - const NAME: &'static str = "accept_transfer_ownership"; - 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 Admin {} - impl Admin { - const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; - 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 Admin { - const NAME: &'static str = "admin"; - 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 Admin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitTransferOwnership { - pub addr: Vec, - } - impl CommitTransferOwnership { - const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; - 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 { - addr: 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.addr))], - ); - 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 CommitTransferOwnership { - const NAME: &'static str = "commit_transfer_ownership"; - 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 DeployGauge { - pub pool: Vec, - } - impl DeployGauge { - const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; - 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 { - pool: 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.pool))], - ); - 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 DeployGauge { - const NAME: &'static str = "deploy_gauge"; - 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 DeployGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPool { - pub name: String, - pub symbol: String, - pub coins: [Vec; 2usize], - pub a: substreams::scalar::BigInt, - pub gamma: substreams::scalar::BigInt, - pub mid_fee: substreams::scalar::BigInt, - pub out_fee: substreams::scalar::BigInt, - pub allowed_extra_profit: substreams::scalar::BigInt, - pub fee_gamma: substreams::scalar::BigInt, - pub adjustment_step: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - pub ma_half_time: substreams::scalar::BigInt, - pub initial_price: substreams::scalar::BigInt, - } - impl DeployPool { - const METHOD_ID: [u8; 4] = [201u8, 85u8, 250u8, 4u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - 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 { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - a: { - 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) - }, - gamma: { - 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) - }, - mid_fee: { - 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) - }, - out_fee: { - 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) - }, - allowed_extra_profit: { - 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_gamma: { - 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) - }, - adjustment_step: { - 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) - }, - admin_fee: { - 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) - }, - ma_half_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) - }, - initial_price: { - 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::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .coins - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.gamma.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.mid_fee.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.out_fee.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.allowed_extra_profit.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.fee_gamma.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.adjustment_step.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.admin_fee.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.ma_half_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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.initial_price.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::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 DeployPool { - const NAME: &'static str = "deploy_pool"; - 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 DeployPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FeeReceiver {} - impl FeeReceiver { - const METHOD_ID: [u8; 4] = [202u8, 180u8, 211u8, 219u8]; - 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 FeeReceiver { - const NAME: &'static str = "fee_receiver"; - 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 FeeReceiver { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub from: Vec, - pub to: Vec, - } - impl FindPoolForCoins1 { - const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 FindPoolForCoins1 { - const NAME: &'static str = "find_pool_for_coins1"; - 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 FindPoolForCoins1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins2 { - pub from: Vec, - pub to: Vec, - pub i: substreams::scalar::BigInt, - } - impl FindPoolForCoins2 { - const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { - 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.i.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::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 FindPoolForCoins2 { - const NAME: &'static str = "find_pool_for_coins2"; - 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 FindPoolForCoins2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdmin {} - impl FutureAdmin { - const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; - 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 FutureAdmin { - const NAME: &'static str = "future_admin"; - 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 FutureAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeImplementation {} - impl GaugeImplementation { - const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; - 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 GaugeImplementation { - const NAME: &'static str = "gauge_implementation"; - 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 GaugeImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub pool: Vec, - } - impl GetBalances { - const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; - 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 { - pool: 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.pool))], - ); - 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; 2usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [iter.next().expect(INTERNAL_ERR), iter.next().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<[substreams::scalar::BigInt; 2usize]> { - 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 GetBalances { - const NAME: &'static str = "get_balances"; - 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; 2usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub pool: Vec, - pub from: Vec, - pub to: Vec, - } - impl GetCoinIndices { - const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; - 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::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.pool)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 GetCoinIndices { - const NAME: &'static str = "get_coin_indices"; - 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 GetCoinIndices { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins { - pub pool: Vec, - } - impl GetCoins { - const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; - 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 { - pool: 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.pool))], - ); - 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; 2usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 2usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [iter.next().expect(INTERNAL_ERR), iter.next().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<[Vec; 2usize]> { - 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 GetCoins { - const NAME: &'static str = "get_coins"; - 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; 2usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub pool: Vec, - } - impl GetDecimals { - const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; - 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 { - pool: 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.pool))], - ); - 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; 2usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [iter.next().expect(INTERNAL_ERR), iter.next().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<[substreams::scalar::BigInt; 2usize]> { - 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 GetDecimals { - const NAME: &'static str = "get_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<[substreams::scalar::BigInt; 2usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetEthIndex { - pub pool: Vec, - } - impl GetEthIndex { - const METHOD_ID: [u8; 4] = [204u8, 177u8, 86u8, 5u8]; - 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 { - pool: 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.pool))], - ); - 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 GetEthIndex { - const NAME: &'static str = "get_eth_index"; - 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 GetEthIndex { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauge { - pub pool: Vec, - } - impl GetGauge { - const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; - 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 { - pool: 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.pool))], - ); - 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 GetGauge { - const NAME: &'static str = "get_gauge"; - 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 GetGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetToken { - pub pool: Vec, - } - impl GetToken { - const METHOD_ID: [u8; 4] = [151u8, 125u8, 145u8, 34u8]; - 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 { - pool: 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.pool))], - ); - 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 GetToken { - const NAME: &'static str = "get_token"; - 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 GetToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCount {} - impl PoolCount { - const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { - const NAME: &'static str = "pool_count"; - 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 PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolImplementation {} - impl PoolImplementation { - const METHOD_ID: [u8; 4] = [36u8, 137u8, 162u8, 195u8]; - 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 PoolImplementation { - const NAME: &'static str = "pool_implementation"; - 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 PoolImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub arg0: substreams::scalar::BigInt, - } - impl PoolList { - const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; - 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 { - arg0: { - 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.arg0.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::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 PoolList { - const NAME: &'static str = "pool_list"; - 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 PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetFeeReceiver { - pub fee_receiver: Vec, - } - impl SetFeeReceiver { - const METHOD_ID: [u8; 4] = [228u8, 26u8, 183u8, 113u8]; - 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 { - fee_receiver: 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.fee_receiver), - ), - ], - ); - 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 SetFeeReceiver { - const NAME: &'static str = "set_fee_receiver"; - 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 SetGaugeImplementation { - pub gauge_implementation: Vec, - } - impl SetGaugeImplementation { - const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; - 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 { - gauge_implementation: 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.gauge_implementation), - ), - ], - ); - 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 SetGaugeImplementation { - const NAME: &'static str = "set_gauge_implementation"; - 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 SetPoolImplementation { - pub pool_implementation: Vec, - } - impl SetPoolImplementation { - const METHOD_ID: [u8; 4] = [158u8, 215u8, 150u8, 208u8]; - 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 { - pool_implementation: 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.pool_implementation), - ), - ], - ); - 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 SetPoolImplementation { - const NAME: &'static str = "set_pool_implementation"; - 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 SetTokenImplementation { - pub token_implementation: Vec, - } - impl SetTokenImplementation { - const METHOD_ID: [u8; 4] = [101u8, 48u8, 35u8, 194u8]; - 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_implementation: 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_implementation), - ), - ], - ); - 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 SetTokenImplementation { - const NAME: &'static str = "set_token_implementation"; - 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 TokenImplementation {} - impl TokenImplementation { - const METHOD_ID: [u8; 4] = [53u8, 33u8, 77u8, 129u8]; - 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 TokenImplementation { - const NAME: &'static str = "token_implementation"; - 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 TokenImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + +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 AcceptTransferOwnership {} + impl AcceptTransferOwnership { + const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct CryptoPoolDeployed { - pub token: Vec, - pub coins: [Vec; 2usize], - pub a: substreams::scalar::BigInt, - pub gamma: substreams::scalar::BigInt, - pub mid_fee: substreams::scalar::BigInt, - pub out_fee: substreams::scalar::BigInt, - pub allowed_extra_profit: substreams::scalar::BigInt, - pub fee_gamma: substreams::scalar::BigInt, - pub adjustment_step: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - pub ma_half_time: substreams::scalar::BigInt, - pub initial_price: substreams::scalar::BigInt, - pub deployer: Vec, + impl substreams_ethereum::Function for AcceptTransferOwnership { + const NAME: &'static str = "accept_transfer_ownership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl CryptoPoolDeployed { - const TOPIC_ID: [u8; 32] = [ - 3u8, - 148u8, - 203u8, - 64u8, - 215u8, - 219u8, - 226u8, - 141u8, - 173u8, - 29u8, - 78u8, - 232u8, - 144u8, - 189u8, - 211u8, - 91u8, - 187u8, - 13u8, - 137u8, - 225u8, - 121u8, - 36u8, - 168u8, - 10u8, - 84u8, - 37u8, - 53u8, - 232u8, - 61u8, - 84u8, - 186u8, - 20u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 448usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; + 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 Admin {} + impl Admin { + const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; + 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 decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - token: values + } + 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 Admin { + const NAME: &'static str = "admin"; + 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 Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitTransferOwnership { + pub addr: Vec, + } + impl CommitTransferOwnership { + const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; + 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 { + addr: 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.addr))]); + 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 CommitTransferOwnership { + const NAME: &'static str = "commit_transfer_ownership"; + 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 DeployGauge { + pub pool: Vec, + } + impl DeployGauge { + const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; + 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 { + pool: 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.pool))]); + 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 DeployGauge { + const NAME: &'static str = "deploy_gauge"; + 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 DeployGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPool { + pub name: String, + pub symbol: String, + pub coins: [Vec; 2usize], + pub a: substreams::scalar::BigInt, + pub gamma: substreams::scalar::BigInt, + pub mid_fee: substreams::scalar::BigInt, + pub out_fee: substreams::scalar::BigInt, + pub allowed_extra_profit: substreams::scalar::BigInt, + pub fee_gamma: substreams::scalar::BigInt, + pub adjustment_step: substreams::scalar::BigInt, + pub admin_fee: substreams::scalar::BigInt, + pub ma_half_time: substreams::scalar::BigInt, + pub initial_price: substreams::scalar::BigInt, + } + impl DeployPool { + const METHOD_ID: [u8; 4] = [201u8, 85u8, 250u8, 4u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 2usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + 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 { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - a: { + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR)] + }, + a: { + 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) + }, + gamma: { + 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) + }, + mid_fee: { + 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) + }, + out_fee: { + 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) + }, + allowed_extra_profit: { + 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_gamma: { + 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) + }, + adjustment_step: { + 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) + }, + admin_fee: { + 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) + }, + ma_half_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) + }, + initial_price: { + 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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .coins + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.gamma.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.mid_fee.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.out_fee.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 + .allowed_extra_profit + .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.fee_gamma.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 + .adjustment_step + .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.admin_fee.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.ma_half_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(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.initial_price.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::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 DeployPool { + const NAME: &'static str = "deploy_pool"; + 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 DeployPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FeeReceiver {} + impl FeeReceiver { + const METHOD_ID: [u8; 4] = [202u8, 180u8, 211u8, 219u8]; + 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 FeeReceiver { + const NAME: &'static str = "fee_receiver"; + 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 FeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub from: Vec, + pub to: Vec, + } + impl FindPoolForCoins1 { + const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 FindPoolForCoins1 { + const NAME: &'static str = "find_pool_for_coins1"; + 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 FindPoolForCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins2 { + pub from: Vec, + pub to: Vec, + pub i: substreams::scalar::BigInt, + } + impl FindPoolForCoins2 { + const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + i: { + 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.i.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::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 FindPoolForCoins2 { + const NAME: &'static str = "find_pool_for_coins2"; + 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 FindPoolForCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAdmin {} + impl FutureAdmin { + const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; + 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 FutureAdmin { + const NAME: &'static str = "future_admin"; + 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 FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeImplementation {} + impl GaugeImplementation { + const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; + 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 GaugeImplementation { + const NAME: &'static str = "gauge_implementation"; + 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 GaugeImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub pool: Vec, + } + impl GetBalances { + const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; + 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 { + pool: 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.pool))]); + 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; 2usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) + inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - gamma: { - let mut v = [0 as u8; 32]; - values - .pop() + }); + [iter.next().expect(INTERNAL_ERR), iter.next().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<[substreams::scalar::BigInt; 2usize]> { + 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 GetBalances { + const NAME: &'static str = "get_balances"; + 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; 2usize]> for GetBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub pool: Vec, + pub from: Vec, + pub to: Vec, + } + impl GetCoinIndices { + const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; + 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::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 GetCoinIndices { + const NAME: &'static str = "get_coin_indices"; + 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 GetCoinIndices + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins { + pub pool: Vec, + } + impl GetCoins { + const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; + 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 { + pool: 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.pool))]); + 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; 2usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 2usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [iter.next().expect(INTERNAL_ERR), iter.next().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<[Vec; 2usize]> { + 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 GetCoins { + const NAME: &'static str = "get_coins"; + 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; 2usize]> for GetCoins { + fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub pool: Vec, + } + impl GetDecimals { + const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; + 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 { + pool: 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.pool))]); + 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; 2usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) - }, - mid_fee: { - 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) - }, - out_fee: { - 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) - }, - allowed_extra_profit: { - 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_gamma: { - 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) - }, - adjustment_step: { - 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) - }, - admin_fee: { - 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) - }, - ma_half_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) - }, - initial_price: { - 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) - }, - deployer: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + }); + [iter.next().expect(INTERNAL_ERR), iter.next().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, } } - impl substreams_ethereum::Event for CryptoPoolDeployed { - const NAME: &'static str = "CryptoPoolDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + pub fn call(&self, address: Vec) -> Option<[substreams::scalar::BigInt; 2usize]> { + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct LiquidityGaugeDeployed { - pub pool: Vec, - pub token: Vec, - pub gauge: Vec, - } - impl LiquidityGaugeDeployed { - const TOPIC_ID: [u8; 32] = [ - 29u8, - 98u8, - 71u8, - 234u8, - 230u8, - 155u8, - 95u8, - 235u8, - 150u8, - 179u8, - 11u8, - 231u8, - 133u8, - 82u8, - 243u8, - 93u8, - 228u8, - 95u8, - 97u8, - 253u8, - 182u8, - 214u8, - 215u8, - 225u8, - 176u8, - 138u8, - 174u8, - 21u8, - 155u8, - 98u8, - 38u8, - 175u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 96usize { - return false; + } + } + } + impl substreams_ethereum::Function for GetDecimals { + const NAME: &'static str = "get_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<[substreams::scalar::BigInt; 2usize]> for GetDecimals { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetEthIndex { + pub pool: Vec, + } + impl GetEthIndex { + const METHOD_ID: [u8; 4] = [204u8, 177u8, 86u8, 5u8]; + 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 { + pool: 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.pool))]); + 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 } - 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::Address, - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for LiquidityGaugeDeployed { - const NAME: &'static str = "LiquidityGaugeDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + } + impl substreams_ethereum::Function for GetEthIndex { + const NAME: &'static str = "get_eth_index"; + 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 GetEthIndex { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauge { + pub pool: Vec, + } + impl GetGauge { + const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; + 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()); } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 { + pool: 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.pool))]); + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferOwnership { - pub old_owner: Vec, - pub new_owner: Vec, - } - impl TransferOwnership { - const TOPIC_ID: [u8; 32] = [ - 92u8, - 72u8, - 101u8, - 40u8, - 236u8, - 62u8, - 63u8, - 14u8, - 169u8, - 17u8, - 129u8, - 207u8, - 248u8, - 17u8, - 111u8, - 2u8, - 191u8, - 163u8, - 80u8, - 224u8, - 59u8, - 139u8, - 111u8, - 18u8, - 224u8, - 7u8, - 101u8, - 173u8, - 187u8, - 90u8, - 248u8, - 92u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for GetGauge { + const NAME: &'static str = "get_gauge"; + 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 GetGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetToken { + pub pool: Vec, + } + impl GetToken { + const METHOD_ID: [u8; 4] = [151u8, 125u8, 145u8, 34u8]; + 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 { + pool: 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.pool))]); + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for TransferOwnership { - const NAME: &'static str = "TransferOwnership"; - 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) + } + impl substreams_ethereum::Function for GetToken { + const NAME: &'static str = "get_token"; + 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 GetToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolCount {} + impl PoolCount { + const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateFeeReceiver { - pub old_fee_receiver: Vec, - pub new_fee_receiver: Vec, - } - impl UpdateFeeReceiver { - const TOPIC_ID: [u8; 32] = [ - 40u8, - 97u8, - 68u8, - 134u8, - 120u8, - 240u8, - 190u8, - 103u8, - 241u8, - 27u8, - 251u8, - 84u8, - 129u8, - 179u8, - 227u8, - 180u8, - 207u8, - 235u8, - 58u8, - 204u8, - 97u8, - 38u8, - 173u8, - 96u8, - 160u8, - 95u8, - 149u8, - 191u8, - 198u8, - 83u8, - 6u8, - 102u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for PoolCount { + const NAME: &'static str = "pool_count"; + 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 PoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolImplementation {} + impl PoolImplementation { + const METHOD_ID: [u8; 4] = [36u8, 137u8, 162u8, 195u8]; + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_fee_receiver: values + } + } + impl substreams_ethereum::Function for PoolImplementation { + const NAME: &'static str = "pool_implementation"; + 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 PoolImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolList { + pub arg0: substreams::scalar::BigInt, + } + impl PoolList { + const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; + 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 { + arg0: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for UpdateFeeReceiver { - const NAME: &'static str = "UpdateFeeReceiver"; - 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 UpdateGaugeImplementation { - pub old_gauge_implementation: Vec, - pub new_gauge_implementation: Vec, - } - impl UpdateGaugeImplementation { - const TOPIC_ID: [u8; 32] = [ - 31u8, - 215u8, - 5u8, - 249u8, - 199u8, - 112u8, - 83u8, - 150u8, - 42u8, - 80u8, - 63u8, - 47u8, - 47u8, - 87u8, - 240u8, - 134u8, - 43u8, - 76u8, - 58u8, - 246u8, - 135u8, - 194u8, - 86u8, - 21u8, - 193u8, - 56u8, - 23u8, - 168u8, - 105u8, - 70u8, - 195u8, - 89u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.arg0.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") + } } - if log.data.len() != 64usize { - return false; + .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::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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_gauge_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_gauge_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for UpdateGaugeImplementation { - const NAME: &'static str = "UpdateGaugeImplementation"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + } + impl substreams_ethereum::Function for PoolList { + const NAME: &'static str = "pool_list"; + 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 PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub fee_receiver: Vec, + } + impl SetFeeReceiver { + const METHOD_ID: [u8; 4] = [228u8, 26u8, 183u8, 113u8]; + 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()); } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 { + fee_receiver: 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.fee_receiver, + ))]); + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdatePoolImplementation { - pub old_pool_implementation: Vec, - pub new_pool_implementation: Vec, + } + impl substreams_ethereum::Function for SetFeeReceiver { + const NAME: &'static str = "set_fee_receiver"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl UpdatePoolImplementation { - const TOPIC_ID: [u8; 32] = [ - 6u8, - 23u8, - 253u8, - 49u8, - 170u8, - 90u8, - 185u8, - 94u8, - 200u8, - 14u8, - 239u8, - 193u8, - 235u8, - 97u8, - 162u8, - 196u8, - 119u8, - 170u8, - 65u8, - 157u8, - 29u8, - 118u8, - 27u8, - 78u8, - 70u8, - 245u8, - 240u8, - 119u8, - 228u8, - 120u8, - 82u8, - 170u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 SetGaugeImplementation { + pub gauge_implementation: Vec, + } + impl SetGaugeImplementation { + const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; + 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 { + gauge_implementation: 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.gauge_implementation, + ))]); + 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 SetGaugeImplementation { + const NAME: &'static str = "set_gauge_implementation"; + 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 SetPoolImplementation { + pub pool_implementation: Vec, + } + impl SetPoolImplementation { + const METHOD_ID: [u8; 4] = [158u8, 215u8, 150u8, 208u8]; + 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 { + pool_implementation: 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.pool_implementation, + ))]); + 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 SetPoolImplementation { + const NAME: &'static str = "set_pool_implementation"; + 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 SetTokenImplementation { + pub token_implementation: Vec, + } + impl SetTokenImplementation { + const METHOD_ID: [u8; 4] = [101u8, 48u8, 35u8, 194u8]; + 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_implementation: 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_implementation, + ))]); + 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 SetTokenImplementation { + const NAME: &'static str = "set_token_implementation"; + 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 TokenImplementation {} + impl TokenImplementation { + const METHOD_ID: [u8; 4] = [53u8, 33u8, 77u8, 129u8]; + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_pool_implementation: values + } + } + impl substreams_ethereum::Function for TokenImplementation { + const NAME: &'static str = "token_implementation"; + 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 TokenImplementation { + fn output(data: &[u8]) -> Result, String> { + 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 CryptoPoolDeployed { + pub token: Vec, + pub coins: [Vec; 2usize], + pub a: substreams::scalar::BigInt, + pub gamma: substreams::scalar::BigInt, + pub mid_fee: substreams::scalar::BigInt, + pub out_fee: substreams::scalar::BigInt, + pub allowed_extra_profit: substreams::scalar::BigInt, + pub fee_gamma: substreams::scalar::BigInt, + pub adjustment_step: substreams::scalar::BigInt, + pub admin_fee: substreams::scalar::BigInt, + pub ma_half_time: substreams::scalar::BigInt, + pub initial_price: substreams::scalar::BigInt, + pub deployer: Vec, + } + impl CryptoPoolDeployed { + const TOPIC_ID: [u8; 32] = [ + 3u8, 148u8, 203u8, 64u8, 215u8, 219u8, 226u8, 141u8, 173u8, 29u8, 78u8, 232u8, 144u8, + 189u8, 211u8, 91u8, 187u8, 13u8, 137u8, 225u8, 121u8, 36u8, 168u8, 10u8, 84u8, 37u8, + 53u8, 232u8, 61u8, 84u8, 186u8, 20u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 448usize { + 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::FixedArray(Box::new(ethabi::ParamType::Address), 2usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + coins: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_pool_implementation: values + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR)] + }, + a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for UpdatePoolImplementation { - const NAME: &'static str = "UpdatePoolImplementation"; - 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 UpdateTokenImplementation { - pub old_token_implementation: Vec, - pub new_token_implementation: Vec, - } - impl UpdateTokenImplementation { - const TOPIC_ID: [u8; 32] = [ - 28u8, - 196u8, - 248u8, - 226u8, - 11u8, - 12u8, - 211u8, - 229u8, - 16u8, - 158u8, - 177u8, - 86u8, - 202u8, - 220u8, - 253u8, - 58u8, - 84u8, - 150u8, - 172u8, - 7u8, - 148u8, - 198u8, - 8u8, - 92u8, - 160u8, - 42u8, - 253u8, - 125u8, - 113u8, - 13u8, - 213u8, - 102u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_token_implementation: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + gamma: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_token_implementation: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + mid_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + out_fee: { + 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) + }, + allowed_extra_profit: { + 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_gamma: { + 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) + }, + adjustment_step: { + 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) + }, + admin_fee: { + 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) + }, + ma_half_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) + }, + initial_price: { + 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) + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Event for UpdateTokenImplementation { - const NAME: &'static str = "UpdateTokenImplementation"; - 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) - } + } + impl substreams_ethereum::Event for CryptoPoolDeployed { + const NAME: &'static str = "CryptoPoolDeployed"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - } \ No newline at end of file + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct LiquidityGaugeDeployed { + pub pool: Vec, + pub token: Vec, + pub gauge: Vec, + } + impl LiquidityGaugeDeployed { + const TOPIC_ID: [u8; 32] = [ + 29u8, 98u8, 71u8, 234u8, 230u8, 155u8, 95u8, 235u8, 150u8, 179u8, 11u8, 231u8, 133u8, + 82u8, 243u8, 93u8, 228u8, 95u8, 97u8, 253u8, 182u8, 214u8, 215u8, 225u8, 176u8, 138u8, + 174u8, 21u8, 155u8, 98u8, 38u8, 175u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 96usize { + 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::Address, + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for LiquidityGaugeDeployed { + const NAME: &'static str = "LiquidityGaugeDeployed"; + 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 TransferOwnership { + pub old_owner: Vec, + pub new_owner: Vec, + } + impl TransferOwnership { + const TOPIC_ID: [u8; 32] = [ + 92u8, 72u8, 101u8, 40u8, 236u8, 62u8, 63u8, 14u8, 169u8, 17u8, 129u8, 207u8, 248u8, + 17u8, 111u8, 2u8, 191u8, 163u8, 80u8, 224u8, 59u8, 139u8, 111u8, 18u8, 224u8, 7u8, + 101u8, 173u8, 187u8, 90u8, 248u8, 92u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for TransferOwnership { + const NAME: &'static str = "TransferOwnership"; + 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 UpdateFeeReceiver { + pub old_fee_receiver: Vec, + pub new_fee_receiver: Vec, + } + impl UpdateFeeReceiver { + const TOPIC_ID: [u8; 32] = [ + 40u8, 97u8, 68u8, 134u8, 120u8, 240u8, 190u8, 103u8, 241u8, 27u8, 251u8, 84u8, 129u8, + 179u8, 227u8, 180u8, 207u8, 235u8, 58u8, 204u8, 97u8, 38u8, 173u8, 96u8, 160u8, 95u8, + 149u8, 191u8, 198u8, 83u8, 6u8, 102u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateFeeReceiver { + const NAME: &'static str = "UpdateFeeReceiver"; + 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 UpdateGaugeImplementation { + pub old_gauge_implementation: Vec, + pub new_gauge_implementation: Vec, + } + impl UpdateGaugeImplementation { + const TOPIC_ID: [u8; 32] = [ + 31u8, 215u8, 5u8, 249u8, 199u8, 112u8, 83u8, 150u8, 42u8, 80u8, 63u8, 47u8, 47u8, 87u8, + 240u8, 134u8, 43u8, 76u8, 58u8, 246u8, 135u8, 194u8, 86u8, 21u8, 193u8, 56u8, 23u8, + 168u8, 105u8, 70u8, 195u8, 89u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_gauge_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_gauge_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateGaugeImplementation { + const NAME: &'static str = "UpdateGaugeImplementation"; + 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 UpdatePoolImplementation { + pub old_pool_implementation: Vec, + pub new_pool_implementation: Vec, + } + impl UpdatePoolImplementation { + const TOPIC_ID: [u8; 32] = [ + 6u8, 23u8, 253u8, 49u8, 170u8, 90u8, 185u8, 94u8, 200u8, 14u8, 239u8, 193u8, 235u8, + 97u8, 162u8, 196u8, 119u8, 170u8, 65u8, 157u8, 29u8, 118u8, 27u8, 78u8, 70u8, 245u8, + 240u8, 119u8, 228u8, 120u8, 82u8, 170u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdatePoolImplementation { + const NAME: &'static str = "UpdatePoolImplementation"; + 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 UpdateTokenImplementation { + pub old_token_implementation: Vec, + pub new_token_implementation: Vec, + } + impl UpdateTokenImplementation { + const TOPIC_ID: [u8; 32] = [ + 28u8, 196u8, 248u8, 226u8, 11u8, 12u8, 211u8, 229u8, 16u8, 158u8, 177u8, 86u8, 202u8, + 220u8, 253u8, 58u8, 84u8, 150u8, 172u8, 7u8, 148u8, 198u8, 8u8, 92u8, 160u8, 42u8, + 253u8, 125u8, 113u8, 13u8, 213u8, 102u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_token_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_token_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateTokenImplementation { + const NAME: &'static str = "UpdateTokenImplementation"; + 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) + } + } +} diff --git a/substreams/ethereum-curve/src/abi/crypto_swap_ng_factory.rs b/substreams/ethereum-curve/src/abi/crypto_swap_ng_factory.rs index 6f900b6..7fec29e 100644 --- a/substreams/ethereum-curve/src/abi/crypto_swap_ng_factory.rs +++ b/substreams/ethereum-curve/src/abi/crypto_swap_ng_factory.rs @@ -1,879 +1,637 @@ - 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 AcceptTransferOwnership {} - impl AcceptTransferOwnership { - const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } + +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 AcceptTransferOwnership {} + impl AcceptTransferOwnership { + const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 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 AcceptTransferOwnership { - const NAME: &'static str = "accept_transfer_ownership"; - 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::Function for AcceptTransferOwnership { + const NAME: &'static str = "accept_transfer_ownership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AddAssetType { - pub id: substreams::scalar::BigInt, - pub name: String, + fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { + Self::decode(call) } - impl AddAssetType { - const METHOD_ID: [u8; 4] = [78u8, 152u8, 129u8, 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::Uint(8usize), ethabi::ParamType::String], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - id: { - 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) - }, - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.id.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::String(self.name.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, - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for AddAssetType { - const NAME: &'static str = "add_asset_type"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddAssetType { + pub id: substreams::scalar::BigInt, + pub name: String, + } + impl AddAssetType { + const METHOD_ID: [u8; 4] = [78u8, 152u8, 129u8, 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()); } - 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 AddBasePool { - pub base_pool: Vec, - pub base_lp_token: Vec, - pub asset_types: Vec, - pub n_coins: substreams::scalar::BigInt, - } - impl AddBasePool { - const METHOD_ID: [u8; 4] = [169u8, 168u8, 239u8, 68u8]; - 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::Array( - Box::new(ethabi::ParamType::Uint(8usize)), - ), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - base_lp_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - asset_types: 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(), - n_coins: { - 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.base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.base_lp_token), - ), - { - let v = self - .asset_types - .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.n_coins.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 AddBasePool { - const NAME: &'static str = "add_base_pool"; - 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 Admin {} - impl Admin { - const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; - 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 Admin { - const NAME: &'static str = "admin"; - 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 Admin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AssetTypes { - pub arg0: substreams::scalar::BigInt, - } - impl AssetTypes { - const METHOD_ID: [u8; 4] = [241u8, 241u8, 1u8, 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::Uint(8usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - arg0: { - 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.arg0.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::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 AssetTypes { - const NAME: &'static str = "asset_types"; - 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 AssetTypes { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolAssets { - pub arg0: Vec, - } - impl BasePoolAssets { - const METHOD_ID: [u8; 4] = [16u8, 160u8, 2u8, 223u8]; - 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 { - arg0: 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.arg0))], - ); - 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 BasePoolAssets { - const NAME: &'static str = "base_pool_assets"; - 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 BasePoolAssets { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolCount {} - impl BasePoolCount { - const METHOD_ID: [u8; 4] = [222u8, 94u8, 74u8, 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 values = ethabi::decode( + &[ethabi::ParamType::Uint(8usize), ethabi::ParamType::String], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + id: { let mut v = [0 as u8; 32]; values .pop() - .expect("one output data should have existed") + .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 { - 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 + }, + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.id.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::String(self.name.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 AddAssetType { + const NAME: &'static str = "add_asset_type"; + 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 AddBasePool { + pub base_pool: Vec, + pub base_lp_token: Vec, + pub asset_types: Vec, + pub n_coins: substreams::scalar::BigInt, + } + impl AddBasePool { + const METHOD_ID: [u8; 4] = [169u8, 168u8, 239u8, 68u8]; + 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::Array(Box::new(ethabi::ParamType::Uint(8usize))), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + base_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + asset_types: 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(), + n_coins: { + 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.base_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.base_lp_token)), + { + let v = self + .asset_types + .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.n_coins.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 AddBasePool { + const NAME: &'static str = "add_base_pool"; + 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 Admin {} + impl Admin { + const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; + 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 BasePoolCount { - const NAME: &'static str = "base_pool_count"; - 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::Function for Admin { + const NAME: &'static str = "admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for BasePoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) + 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 Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AssetTypes { + pub arg0: substreams::scalar::BigInt, + } + impl AssetTypes { + const METHOD_ID: [u8; 4] = [241u8, 241u8, 1u8, 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()); } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolData { - pub arg0: Vec, - } - impl BasePoolData { - const METHOD_ID: [u8; 4] = [237u8, 135u8, 73u8, 64u8]; - 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(), - ) + 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 { - arg0: values + values.reverse(); + Ok(Self { + arg0: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.arg0))], - ); - 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, - substreams::scalar::BigInt, - Vec, - ), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ( - Vec, - Vec>, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - Vec, - ), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Tuple( - vec![ - ethabi::ParamType::Address, - ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(8usize))) - ], - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let tuple_elements = values - .pop() - .expect("one output data should have existed") - .into_tuple() - .expect(INTERNAL_ERR); - ( - tuple_elements[0usize] - .clone() - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - tuple_elements[1usize] - .clone() - .into_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }) - .collect(), - { - 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_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>, - 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 + .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.arg0.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::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, } } - impl substreams_ethereum::Function for BasePoolData { - const NAME: &'static str = "base_pool_data"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + 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; } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + 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::rpc::RPCDecodable< + } + impl substreams_ethereum::Function for AssetTypes { + const NAME: &'static str = "asset_types"; + 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 AssetTypes { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolAssets { + pub arg0: Vec, + } + impl BasePoolAssets { + const METHOD_ID: [u8; 4] = [16u8, 160u8, 2u8, 223u8]; + 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 { + arg0: 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.arg0))]); + 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 BasePoolAssets { + const NAME: &'static str = "base_pool_assets"; + 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 BasePoolAssets { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolCount {} + impl BasePoolCount { + const METHOD_ID: [u8; 4] = [222u8, 94u8, 74u8, 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 BasePoolCount { + const NAME: &'static str = "base_pool_count"; + 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 BasePoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolData { + pub arg0: Vec, + } + impl BasePoolData { + const METHOD_ID: [u8; 4] = [237u8, 135u8, 73u8, 64u8]; + 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 { + arg0: 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.arg0))]); + 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>, @@ -881,5293 +639,4764 @@ substreams::scalar::BigInt, Vec, ), - > for BasePoolData { - fn output( - data: &[u8], - ) -> Result< + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + Vec, + Vec>, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + ), + String, + > { + let mut values = ethabi::decode( + &[ethabi::ParamType::Tuple(vec![ + ethabi::ParamType::Address, + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(8usize))), + ])], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let tuple_elements = values + .pop() + .expect("one output data should have existed") + .into_tuple() + .expect(INTERNAL_ERR); ( - Vec, - Vec>, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - Vec, - ), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolList { - pub arg0: substreams::scalar::BigInt, - } - impl BasePoolList { - const METHOD_ID: [u8; 4] = [34u8, 254u8, 86u8, 113u8]; - 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 { - arg0: { + tuple_elements[0usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + tuple_elements[1usize] + .clone() + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }) + .collect(), + { let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) + 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_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 encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.arg0.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 call( + &self, + address: Vec, + ) -> Option<( + Vec, + Vec>, + 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; } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) + 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 + } } - 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( + } + } + impl substreams_ethereum::Function for BasePoolData { + const NAME: &'static str = "base_pool_data"; + 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, + substreams::scalar::BigInt, + Vec, + )> for BasePoolData + { + fn output( + data: &[u8], + ) -> Result< + ( + Vec, + Vec>, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + ), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolList { + pub arg0: substreams::scalar::BigInt, + } + impl BasePoolList { + const METHOD_ID: [u8; 4] = [34u8, 254u8, 86u8, 113u8]; + 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 { + arg0: { + let mut v = [0 as u8; 32]; 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 + .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.arg0.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::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, } } - impl substreams_ethereum::Function for BasePoolList { - const NAME: &'static str = "base_pool_list"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + 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; } - 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 BasePoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitTransferOwnership { - pub addr: Vec, - } - impl CommitTransferOwnership { - const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; - 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 { - addr: 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.addr))], - ); - 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, + 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 CommitTransferOwnership { - const NAME: &'static str = "commit_transfer_ownership"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + } + impl substreams_ethereum::Function for BasePoolList { + const NAME: &'static str = "base_pool_list"; + 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 BasePoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitTransferOwnership { + pub addr: Vec, + } + impl CommitTransferOwnership { + const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; + 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()); } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + 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 { + addr: 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.addr))]); + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge { - pub pool: Vec, + } + impl substreams_ethereum::Function for CommitTransferOwnership { + const NAME: &'static str = "commit_transfer_ownership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl DeployGauge { - const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; - 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()); + 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 DeployGauge { + pub pool: Vec, + } + impl DeployGauge { + const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; + 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 { + pool: 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.pool))]); + 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 } - 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 { - pool: 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.pool))], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + } + } + impl substreams_ethereum::Function for DeployGauge { + const NAME: &'static str = "deploy_gauge"; + 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 DeployGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool { + pub base_pool: Vec, + pub name: String, + pub symbol: String, + pub coin: Vec, + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub offpeg_fee_multiplier: substreams::scalar::BigInt, + pub ma_exp_time: substreams::scalar::BigInt, + pub implementation_idx: substreams::scalar::BigInt, + pub asset_type: substreams::scalar::BigInt, + pub method_id: [u8; 4usize], + pub oracle: Vec, + } + impl DeployMetapool { + const METHOD_ID: [u8; 4] = [223u8, 140u8, 93u8, 115u8]; + 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()); } - 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( + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(8usize), + ethabi::ParamType::FixedBytes(4usize), + ethabi::ParamType::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + a: { + let mut v = [0 as u8; 32]; 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 + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + fee: { + 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) + }, + offpeg_fee_multiplier: { + 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) + }, + ma_exp_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) + }, + implementation_idx: { + 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) + }, + asset_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) + }, + method_id: { + let mut result = [0u8; 4]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + oracle: 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.base_pool)), + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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 + .offpeg_fee_multiplier + .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.ma_exp_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(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .implementation_idx + .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.asset_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(), + )), + ethabi::Token::FixedBytes(self.method_id.as_ref().to_vec()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.oracle)), + ]); + 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 DeployGauge { - const NAME: &'static str = "deploy_gauge"; - 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::Function for DeployMetapool { + const NAME: &'static str = "deploy_metapool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + 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 DeployMetapool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool { + pub name: String, + pub symbol: String, + pub coins: Vec>, + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub offpeg_fee_multiplier: substreams::scalar::BigInt, + pub ma_exp_time: substreams::scalar::BigInt, + pub implementation_idx: substreams::scalar::BigInt, + pub asset_types: Vec, + pub method_ids: Vec<[u8; 4usize]>, + pub oracles: Vec>, + } + impl DeployPlainPool { + const METHOD_ID: [u8; 4] = [91u8, 205u8, 61u8, 131u8]; + 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()); } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployMetapool { - pub base_pool: Vec, - pub name: String, - pub symbol: String, - pub coin: Vec, - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub offpeg_fee_multiplier: substreams::scalar::BigInt, - pub ma_exp_time: substreams::scalar::BigInt, - pub implementation_idx: substreams::scalar::BigInt, - pub asset_type: substreams::scalar::BigInt, - pub method_id: [u8; 4usize], - pub oracle: Vec, - } - impl DeployMetapool { - const METHOD_ID: [u8; 4] = [223u8, 140u8, 93u8, 115u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(8usize), - ethabi::ParamType::FixedBytes(4usize), - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - base_pool: values + let mut values = ethabi::decode( + &[ + ethabi::ParamType::String, + ethabi::ParamType::String, + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(8usize))), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::FixedBytes(4usize))), + 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 { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: 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(), + a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - name: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + offpeg_fee_multiplier: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coin: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + ma_exp_time: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - a: { + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + implementation_idx: { + 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) + }, + asset_types: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) + inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - fee: { - 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) - }, - offpeg_fee_multiplier: { - 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) - }, - ma_exp_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) - }, - implementation_idx: { - 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) - }, - asset_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) - }, - method_id: { + }) + .collect(), + method_ids: values + .pop() + .expect(INTERNAL_ERR) + .into_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { let mut result = [0u8; 4]; - let v = values - .pop() - .expect(INTERNAL_ERR) + let v = inner .into_fixed_bytes() .expect(INTERNAL_ERR); result.copy_from_slice(&v); result - }, - oracle: 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.base_pool), - ), - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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.offpeg_fee_multiplier.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.ma_exp_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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.implementation_idx.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.asset_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(), - ), - ), - ethabi::Token::FixedBytes(self.method_id.as_ref().to_vec()), - ethabi::Token::Address(ethabi::Address::from_slice(&self.oracle)), - ], - ); - 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 + }) + .collect(), + oracles: 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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .coins + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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") + } } - } - } - } - impl substreams_ethereum::Function for DeployMetapool { - const NAME: &'static str = "deploy_metapool"; - 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 DeployMetapool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPlainPool { - pub name: String, - pub symbol: String, - pub coins: Vec>, - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub offpeg_fee_multiplier: substreams::scalar::BigInt, - pub ma_exp_time: substreams::scalar::BigInt, - pub implementation_idx: substreams::scalar::BigInt, - pub asset_types: Vec, - pub method_ids: Vec<[u8; 4usize]>, - pub oracles: Vec>, - } - impl DeployPlainPool { - const METHOD_ID: [u8; 4] = [91u8, 205u8, 61u8, 131u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Address), - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Uint(8usize)), - ), - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::FixedBytes(4usize)), - ), - 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 { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: 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(), - a: { - 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: { - 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) - }, - offpeg_fee_multiplier: { - 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) - }, - ma_exp_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) - }, - implementation_idx: { - 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) - }, - asset_types: 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(), - method_ids: values - .pop() - .expect(INTERNAL_ERR) - .into_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - let mut result = [0u8; 4]; - let v = inner.into_fixed_bytes().expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }) - .collect(), - oracles: 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::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .coins - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::Array(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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.offpeg_fee_multiplier.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.ma_exp_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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.implementation_idx.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 - .asset_types - .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) - }, - { - let v = self - .method_ids - .iter() - .map(|inner| ethabi::Token::FixedBytes( - inner.as_ref().to_vec(), - )) - .collect(); - ethabi::Token::Array(v) - }, - { - let v = self - .oracles - .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::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 + .as_slice(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.fee.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") + } } - } - } - } - impl substreams_ethereum::Function for DeployPlainPool { - const NAME: &'static str = "deploy_plain_pool"; - 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 DeployPlainPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FeeReceiver {} - impl FeeReceiver { - const METHOD_ID: [u8; 4] = [202u8, 180u8, 211u8, 219u8]; - 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 FeeReceiver { - const NAME: &'static str = "fee_receiver"; - 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 FeeReceiver { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub from: Vec, - pub to: Vec, - } - impl FindPoolForCoins1 { - const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 FindPoolForCoins1 { - const NAME: &'static str = "find_pool_for_coins1"; - 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 FindPoolForCoins1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins2 { - pub from: Vec, - pub to: Vec, - pub i: substreams::scalar::BigInt, - } - impl FindPoolForCoins2 { - const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { - 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.i.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::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 FindPoolForCoins2 { - const NAME: &'static str = "find_pool_for_coins2"; - 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 FindPoolForCoins2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdmin {} - impl FutureAdmin { - const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; - 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 FutureAdmin { - const NAME: &'static str = "future_admin"; - 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 FutureAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeImplementation {} - impl GaugeImplementation { - const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; - 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 GaugeImplementation { - const NAME: &'static str = "gauge_implementation"; - 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 GaugeImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetA { - pub pool: Vec, - } - impl GetA { - const METHOD_ID: [u8; 4] = [85u8, 179u8, 11u8, 25u8]; - 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 { - pool: 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.pool))], - ); - 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 GetA { - const NAME: &'static str = "get_A"; - 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 GetA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances { - pub pool: Vec, - } - impl GetAdminBalances { - const METHOD_ID: [u8; 4] = [193u8, 30u8, 69u8, 184u8]; - 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 { - pool: 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.pool))], - ); - 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 GetAdminBalances { - const NAME: &'static str = "get_admin_balances"; - 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 GetAdminBalances { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub pool: Vec, - } - impl GetBalances { - const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; - 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 { - pool: 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.pool))], - ); - 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 GetBalances { - const NAME: &'static str = "get_balances"; - 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 GetBalances { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBasePool { - pub pool: Vec, - } - impl GetBasePool { - const METHOD_ID: [u8; 4] = [111u8, 32u8, 214u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: 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.pool))], - ); - 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 GetBasePool { - const NAME: &'static str = "get_base_pool"; - 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 GetBasePool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub pool: Vec, - pub from: Vec, - pub to: Vec, - } - impl GetCoinIndices { - const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; - 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::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.pool)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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, bool), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Bool, - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( + .as_slice(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .offpeg_fee_multiplier + .clone() + .to_bytes_be() { - 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) - }, + (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.ma_exp_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(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .implementation_idx + .clone() + .to_bytes_be() { - 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) - }, - values.pop().expect(INTERNAL_ERR).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<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> { - 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 + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } } - } - } - } - impl substreams_ethereum::Function for GetCoinIndices { - const NAME: &'static str = "get_coin_indices"; - 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, bool), - > for GetCoinIndices { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins { - pub pool: Vec, - } - impl GetCoins { - const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; - 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 { - pool: 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.pool))], - ); - 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() + .as_slice(), + )), + { + let v = self + .asset_types + .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 GetCoins { - const NAME: &'static str = "get_coins"; - 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 GetCoins { - fn output(data: &[u8]) -> Result>, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub pool: Vec, - } - impl GetDecimals { - const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; - 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 { - pool: 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.pool))], - ); - 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 GetDecimals { - const NAME: &'static str = "get_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 GetDecimals { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFees { - pub pool: Vec, - } - impl GetFees { - const METHOD_ID: [u8; 4] = [124u8, 219u8, 114u8, 176u8]; - 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 { - pool: 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.pool))], - ); - 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 GetFees { - const NAME: &'static str = "get_fees"; - 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 GetFees { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauge { - pub pool: Vec, - } - impl GetGauge { - const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; - 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 { - pool: 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.pool))], - ); - 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 GetGauge { - const NAME: &'static str = "get_gauge"; - 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 GetGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetImplementationAddress { - pub pool: Vec, - } - impl GetImplementationAddress { - const METHOD_ID: [u8; 4] = [81u8, 13u8, 152u8, 164u8]; - 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 { - pool: 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.pool))], - ); - 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 GetImplementationAddress { - const NAME: &'static str = "get_implementation_address"; - 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 GetImplementationAddress { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetMetaNCoins { - pub pool: Vec, - } - impl GetMetaNCoins { - const METHOD_ID: [u8; 4] = [235u8, 115u8, 243u8, 125u8]; - 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 { - pool: 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.pool))], - ); - 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 GetMetaNCoins { - const NAME: &'static str = "get_meta_n_coins"; - 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 GetMetaNCoins { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetMetapoolRates { - pub pool: Vec, - } - impl GetMetapoolRates { - const METHOD_ID: [u8; 4] = [6u8, 216u8, 241u8, 96u8]; - 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 { - pool: 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.pool))], - ); - 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 GetMetapoolRates { - const NAME: &'static str = "get_metapool_rates"; - 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 GetMetapoolRates { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins { - pub pool: Vec, - } - impl GetNCoins { - const METHOD_ID: [u8; 4] = [148u8, 4u8, 148u8, 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 { - pool: 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.pool))], - ); - 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 GetNCoins { - const NAME: &'static str = "get_n_coins"; - 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 GetNCoins { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolAssetTypes { - pub pool: Vec, - } - impl GetPoolAssetTypes { - const METHOD_ID: [u8; 4] = [168u8, 15u8, 36u8, 100u8]; - 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 { - pool: 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.pool))], - ); - 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(8usize)), - ), - ], - 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 GetPoolAssetTypes { - const NAME: &'static str = "get_pool_asset_types"; - 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 GetPoolAssetTypes { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances { - pub pool: Vec, - } - impl GetUnderlyingBalances { - const METHOD_ID: [u8; 4] = [89u8, 244u8, 243u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: 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.pool))], - ); - 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 GetUnderlyingBalances { - const NAME: &'static str = "get_underlying_balances"; - 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 GetUnderlyingBalances { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins { - pub pool: Vec, - } - impl GetUnderlyingCoins { - const METHOD_ID: [u8; 4] = [167u8, 117u8, 118u8, 239u8]; - 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 { - pool: 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.pool))], - ); - 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 GetUnderlyingCoins { - const NAME: &'static str = "get_underlying_coins"; - 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 GetUnderlyingCoins { - fn output(data: &[u8]) -> Result>, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingDecimals { - pub pool: Vec, - } - impl GetUnderlyingDecimals { - const METHOD_ID: [u8; 4] = [76u8, 176u8, 136u8, 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 { - pool: 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.pool))], - ); - 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 GetUnderlyingDecimals { - const NAME: &'static str = "get_underlying_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 GetUnderlyingDecimals { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsMeta { - pub pool: Vec, - } - impl IsMeta { - const METHOD_ID: [u8; 4] = [228u8, 211u8, 50u8, 169u8]; - 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 { - pool: 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.pool))], - ); - 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 IsMeta { - const NAME: &'static str = "is_meta"; - 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 IsMeta { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct MathImplementation {} - impl MathImplementation { - const METHOD_ID: [u8; 4] = [161u8, 60u8, 143u8, 129u8]; - 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 MathImplementation { - const NAME: &'static str = "math_implementation"; - 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 MathImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct MetapoolImplementations { - pub arg0: substreams::scalar::BigInt, - } - impl MetapoolImplementations { - const METHOD_ID: [u8; 4] = [207u8, 239u8, 29u8, 107u8]; - 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 { - arg0: { - 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.arg0.clone().to_bytes_be() { + 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(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + .as_slice(), + )) + }) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .method_ids + .iter() + .map(|inner| ethabi::Token::FixedBytes(inner.as_ref().to_vec())) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .oracles + .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::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 output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) + } + 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; } - 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, + 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 } } - 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 MetapoolImplementations { - const NAME: &'static str = "metapool_implementations"; - 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 MetapoolImplementations { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCount {} - impl PoolCount { - const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { - const NAME: &'static str = "pool_count"; - 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 PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolImplementations { - pub arg0: substreams::scalar::BigInt, - } - impl PoolImplementations { - const METHOD_ID: [u8; 4] = [50u8, 115u8, 255u8, 71u8]; - 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 { - arg0: { - 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.arg0.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::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 PoolImplementations { - const NAME: &'static str = "pool_implementations"; - 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 PoolImplementations { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub arg0: substreams::scalar::BigInt, - } - impl PoolList { - const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; - 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 { - arg0: { - 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.arg0.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::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 PoolList { - const NAME: &'static str = "pool_list"; - 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 PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetFeeReceiver { - pub pool: Vec, - pub fee_receiver: Vec, - } - impl SetFeeReceiver { - const METHOD_ID: [u8; 4] = [54u8, 210u8, 183u8, 122u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - fee_receiver: 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.pool)), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.fee_receiver), - ), - ], - ); - 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 SetFeeReceiver { - const NAME: &'static str = "set_fee_receiver"; - 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 SetGaugeImplementation { - pub gauge_implementation: Vec, - } - impl SetGaugeImplementation { - const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; - 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 { - gauge_implementation: 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.gauge_implementation), - ), - ], - ); - 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 SetGaugeImplementation { - const NAME: &'static str = "set_gauge_implementation"; - 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 SetMathImplementation { - pub math_implementation: Vec, - } - impl SetMathImplementation { - const METHOD_ID: [u8; 4] = [176u8, 116u8, 38u8, 244u8]; - 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 { - math_implementation: 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.math_implementation), - ), - ], - ); - 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 SetMathImplementation { - const NAME: &'static str = "set_math_implementation"; - 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 SetMetapoolImplementations { - pub implementation_index: substreams::scalar::BigInt, - pub implementation: Vec, - } - impl SetMetapoolImplementations { - const METHOD_ID: [u8; 4] = [28u8, 179u8, 3u8, 153u8]; - 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - implementation_index: { - 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) - }, - implementation: 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::Uint( - ethabi::Uint::from_big_endian( - match self.implementation_index.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.implementation), - ), - ], - ); - 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 SetMetapoolImplementations { - const NAME: &'static str = "set_metapool_implementations"; - 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 SetPoolImplementations { - pub implementation_index: substreams::scalar::BigInt, - pub implementation: Vec, - } - impl SetPoolImplementations { - const METHOD_ID: [u8; 4] = [77u8, 192u8, 92u8, 251u8]; - 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - implementation_index: { - 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) - }, - implementation: 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::Uint( - ethabi::Uint::from_big_endian( - match self.implementation_index.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.implementation), - ), - ], - ); - 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 SetPoolImplementations { - const NAME: &'static str = "set_pool_implementations"; - 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 SetViewsImplementation { - pub views_implementation: Vec, - } - impl SetViewsImplementation { - const METHOD_ID: [u8; 4] = [246u8, 250u8, 147u8, 127u8]; - 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 { - views_implementation: 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.views_implementation), - ), - ], - ); - 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 SetViewsImplementation { - const NAME: &'static str = "set_views_implementation"; - 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 ViewsImplementation {} - impl ViewsImplementation { - const METHOD_ID: [u8; 4] = [227u8, 21u8, 147u8, 216u8]; - 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 ViewsImplementation { - const NAME: &'static str = "views_implementation"; - 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 ViewsImplementation { - fn output(data: &[u8]) -> Result, String> { - 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 BasePoolAdded { - pub base_pool: Vec, + impl substreams_ethereum::Function for DeployPlainPool { + const NAME: &'static str = "deploy_plain_pool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl BasePoolAdded { - const TOPIC_ID: [u8; 32] = [ - 204u8, - 106u8, - 253u8, - 254u8, - 199u8, - 157u8, - 166u8, - 190u8, - 8u8, - 20u8, - 46u8, - 206u8, - 226u8, - 92u8, - 241u8, - 75u8, - 102u8, - 89u8, - 97u8, - 226u8, - 93u8, - 48u8, - 216u8, - 235u8, - 164u8, - 89u8, - 89u8, - 190u8, - 149u8, - 71u8, - 99u8, - 95u8, - ]; - 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; + 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 DeployPlainPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FeeReceiver {} + impl FeeReceiver { + const METHOD_ID: [u8; 4] = [202u8, 180u8, 211u8, 219u8]; + 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 decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - base_pool: values + } + 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 FeeReceiver { + const NAME: &'static str = "fee_receiver"; + 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 FeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub from: Vec, + pub to: Vec, + } + impl FindPoolForCoins1 { + const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 FindPoolForCoins1 { + const NAME: &'static str = "find_pool_for_coins1"; + 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 FindPoolForCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins2 { + pub from: Vec, + pub to: Vec, + pub i: substreams::scalar::BigInt, + } + impl FindPoolForCoins2 { + const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + i: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + .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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.i.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::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 FindPoolForCoins2 { + const NAME: &'static str = "find_pool_for_coins2"; + 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 FindPoolForCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAdmin {} + impl FutureAdmin { + const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; + 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 FutureAdmin { + const NAME: &'static str = "future_admin"; + 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 FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeImplementation {} + impl GaugeImplementation { + const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; + 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 GaugeImplementation { + const NAME: &'static str = "gauge_implementation"; + 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 GaugeImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetA { + pub pool: Vec, + } + impl GetA { + const METHOD_ID: [u8; 4] = [85u8, 179u8, 11u8, 25u8]; + 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 { + pool: 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.pool))]); + 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 GetA { + const NAME: &'static str = "get_A"; + 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 GetA { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAdminBalances { + pub pool: Vec, + } + impl GetAdminBalances { + const METHOD_ID: [u8; 4] = [193u8, 30u8, 69u8, 184u8]; + 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 { + pool: 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.pool))]); + 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, } } - impl substreams_ethereum::Event for BasePoolAdded { - const NAME: &'static str = "BasePoolAdded"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct LiquidityGaugeDeployed { - pub pool: Vec, - pub gauge: Vec, - } - impl LiquidityGaugeDeployed { - const TOPIC_ID: [u8; 32] = [ - 101u8, - 107u8, - 179u8, - 76u8, - 32u8, - 73u8, - 25u8, - 112u8, - 168u8, - 193u8, - 99u8, - 243u8, - 189u8, - 98u8, - 234u8, - 216u8, - 32u8, - 34u8, - 179u8, - 121u8, - 195u8, - 146u8, - 73u8, - 96u8, - 236u8, - 96u8, - 246u8, - 219u8, - 252u8, - 90u8, - 171u8, - 59u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() + } + } + impl substreams_ethereum::Function for GetAdminBalances { + const NAME: &'static str = "get_admin_balances"; + 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 GetAdminBalances { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub pool: Vec, + } + impl GetBalances { + const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; + 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 { + pool: 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.pool))]); + 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) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + .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, } } - impl substreams_ethereum::Event for LiquidityGaugeDeployed { - const NAME: &'static str = "LiquidityGaugeDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct MetaPoolDeployed { - pub coin: Vec, - pub base_pool: Vec, - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub deployer: Vec, - } - impl MetaPoolDeployed { - const TOPIC_ID: [u8; 32] = [ - 1u8, - 243u8, - 28u8, - 210u8, - 171u8, - 222u8, - 180u8, - 229u8, - 225u8, - 11u8, - 165u8, - 0u8, - 242u8, - 219u8, - 15u8, - 147u8, - 125u8, - 158u8, - 140u8, - 115u8, - 90u8, - 176u8, - 70u8, - 129u8, - 146u8, - 84u8, - 65u8, - 180u8, - 234u8, - 55u8, - 237u8, - 165u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 160usize { - 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::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - coin: values + } + } + impl substreams_ethereum::Function for GetBalances { + const NAME: &'static str = "get_balances"; + 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 GetBalances { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasePool { + pub pool: Vec, + } + impl GetBasePool { + const METHOD_ID: [u8; 4] = [111u8, 32u8, 214u8, 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], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: 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.pool))]); + 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 GetBasePool { + const NAME: &'static str = "get_base_pool"; + 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 GetBasePool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub pool: Vec, + pub from: Vec, + pub to: Vec, + } + impl GetCoinIndices { + const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; + 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::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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, bool), String> + { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Bool, + ], + 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_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + { + 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) + }, + values + .pop() + .expect(INTERNAL_ERR) + .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<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> { + 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 GetCoinIndices { + const NAME: &'static str = "get_coin_indices"; + 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, + bool, + )> for GetCoinIndices + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins { + pub pool: Vec, + } + impl GetCoins { + const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; + 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 { + pool: 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.pool))]); + 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(), - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - a: { - 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: { - 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) - }, - deployer: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + .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, } } - impl substreams_ethereum::Event for MetaPoolDeployed { - const NAME: &'static str = "MetaPoolDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PlainPoolDeployed { - pub coins: Vec>, - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub deployer: Vec, - } - impl PlainPoolDeployed { - const TOPIC_ID: [u8; 32] = [ - 209u8, - 214u8, - 13u8, - 70u8, - 17u8, - 228u8, - 9u8, - 27u8, - 178u8, - 229u8, - 246u8, - 153u8, - 238u8, - 183u8, - 145u8, - 54u8, - 194u8, - 26u8, - 194u8, - 48u8, - 90u8, - 214u8, - 9u8, - 243u8, - 222u8, - 86u8, - 154u8, - 252u8, - 52u8, - 113u8, - 238u8, - 204u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() < 160usize { - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - coins: values + } + } + impl substreams_ethereum::Function for GetCoins { + const NAME: &'static str = "get_coins"; + 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 GetCoins { + fn output(data: &[u8]) -> Result>, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub pool: Vec, + } + impl GetDecimals { + const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; + 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 { + pool: 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.pool))]); + 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 GetDecimals { + const NAME: &'static str = "get_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 GetDecimals { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees { + pub pool: Vec, + } + impl GetFees { + const METHOD_ID: [u8; 4] = [124u8, 219u8, 114u8, 176u8]; + 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 { + pool: 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.pool))]); + 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_array() + .into_uint() .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }) - .collect(), - a: { - 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: { - 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) - }, - deployer: values + .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 GetFees { + const NAME: &'static str = "get_fees"; + 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 GetFees + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauge { + pub pool: Vec, + } + impl GetGauge { + const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; + 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 { + pool: 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.pool))]); + 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 GetGauge { + const NAME: &'static str = "get_gauge"; + 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 GetGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetImplementationAddress { + pub pool: Vec, + } + impl GetImplementationAddress { + const METHOD_ID: [u8; 4] = [81u8, 13u8, 152u8, 164u8]; + 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 { + pool: 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.pool))]); + 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 GetImplementationAddress { + const NAME: &'static str = "get_implementation_address"; + 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 GetImplementationAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMetaNCoins { + pub pool: Vec, + } + impl GetMetaNCoins { + const METHOD_ID: [u8; 4] = [235u8, 115u8, 243u8, 125u8]; + 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 { + pool: 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.pool))]); + 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 GetMetaNCoins { + const NAME: &'static str = "get_meta_n_coins"; + 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 GetMetaNCoins + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMetapoolRates { + pub pool: Vec, + } + impl GetMetapoolRates { + const METHOD_ID: [u8; 4] = [6u8, 216u8, 241u8, 96u8]; + 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 { + pool: 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.pool))]); + 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 GetMetapoolRates { + const NAME: &'static str = "get_metapool_rates"; + 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 GetMetapoolRates { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNCoins { + pub pool: Vec, + } + impl GetNCoins { + const METHOD_ID: [u8; 4] = [148u8, 4u8, 148u8, 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 { + pool: 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.pool))]); + 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 GetNCoins { + const NAME: &'static str = "get_n_coins"; + 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 GetNCoins { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolAssetTypes { + pub pool: Vec, + } + impl GetPoolAssetTypes { + const METHOD_ID: [u8; 4] = [168u8, 15u8, 36u8, 100u8]; + 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 { + pool: 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.pool))]); + 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(8usize)))], + 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 GetPoolAssetTypes { + const NAME: &'static str = "get_pool_asset_types"; + 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 GetPoolAssetTypes { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingBalances { + pub pool: Vec, + } + impl GetUnderlyingBalances { + const METHOD_ID: [u8; 4] = [89u8, 244u8, 243u8, 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], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: 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.pool))]); + 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 GetUnderlyingBalances { + const NAME: &'static str = "get_underlying_balances"; + 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 GetUnderlyingBalances + { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingCoins { + pub pool: Vec, + } + impl GetUnderlyingCoins { + const METHOD_ID: [u8; 4] = [167u8, 117u8, 118u8, 239u8]; + 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 { + pool: 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.pool))]); + 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(), + .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, } } - impl substreams_ethereum::Event for PlainPoolDeployed { - const NAME: &'static str = "PlainPoolDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 + } } } - } \ No newline at end of file + } + impl substreams_ethereum::Function for GetUnderlyingCoins { + const NAME: &'static str = "get_underlying_coins"; + 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 GetUnderlyingCoins { + fn output(data: &[u8]) -> Result>, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingDecimals { + pub pool: Vec, + } + impl GetUnderlyingDecimals { + const METHOD_ID: [u8; 4] = [76u8, 176u8, 136u8, 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 { + pool: 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.pool))]); + 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 GetUnderlyingDecimals { + const NAME: &'static str = "get_underlying_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 GetUnderlyingDecimals + { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsMeta { + pub pool: Vec, + } + impl IsMeta { + const METHOD_ID: [u8; 4] = [228u8, 211u8, 50u8, 169u8]; + 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 { + pool: 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.pool))]); + 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 IsMeta { + const NAME: &'static str = "is_meta"; + 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 IsMeta { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MathImplementation {} + impl MathImplementation { + const METHOD_ID: [u8; 4] = [161u8, 60u8, 143u8, 129u8]; + 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 MathImplementation { + const NAME: &'static str = "math_implementation"; + 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 MathImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MetapoolImplementations { + pub arg0: substreams::scalar::BigInt, + } + impl MetapoolImplementations { + const METHOD_ID: [u8; 4] = [207u8, 239u8, 29u8, 107u8]; + 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 { + arg0: { + 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.arg0.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::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 MetapoolImplementations { + const NAME: &'static str = "metapool_implementations"; + 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 MetapoolImplementations { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolCount {} + impl PoolCount { + const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { + const NAME: &'static str = "pool_count"; + 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 PoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolImplementations { + pub arg0: substreams::scalar::BigInt, + } + impl PoolImplementations { + const METHOD_ID: [u8; 4] = [50u8, 115u8, 255u8, 71u8]; + 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 { + arg0: { + 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.arg0.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::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 PoolImplementations { + const NAME: &'static str = "pool_implementations"; + 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 PoolImplementations { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolList { + pub arg0: substreams::scalar::BigInt, + } + impl PoolList { + const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; + 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 { + arg0: { + 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.arg0.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::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 PoolList { + const NAME: &'static str = "pool_list"; + 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 PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub pool: Vec, + pub fee_receiver: Vec, + } + impl SetFeeReceiver { + const METHOD_ID: [u8; 4] = [54u8, 210u8, 183u8, 122u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + fee_receiver: 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.pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.fee_receiver)), + ]); + 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 SetFeeReceiver { + const NAME: &'static str = "set_fee_receiver"; + 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 SetGaugeImplementation { + pub gauge_implementation: Vec, + } + impl SetGaugeImplementation { + const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; + 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 { + gauge_implementation: 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.gauge_implementation, + ))]); + 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 SetGaugeImplementation { + const NAME: &'static str = "set_gauge_implementation"; + 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 SetMathImplementation { + pub math_implementation: Vec, + } + impl SetMathImplementation { + const METHOD_ID: [u8; 4] = [176u8, 116u8, 38u8, 244u8]; + 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 { + math_implementation: 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.math_implementation, + ))]); + 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 SetMathImplementation { + const NAME: &'static str = "set_math_implementation"; + 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 SetMetapoolImplementations { + pub implementation_index: substreams::scalar::BigInt, + pub implementation: Vec, + } + impl SetMetapoolImplementations { + const METHOD_ID: [u8; 4] = [28u8, 179u8, 3u8, 153u8]; + 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + implementation_index: { + 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) + }, + implementation: 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::Uint(ethabi::Uint::from_big_endian( + match self + .implementation_index + .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.implementation)), + ]); + 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 SetMetapoolImplementations { + const NAME: &'static str = "set_metapool_implementations"; + 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 SetPoolImplementations { + pub implementation_index: substreams::scalar::BigInt, + pub implementation: Vec, + } + impl SetPoolImplementations { + const METHOD_ID: [u8; 4] = [77u8, 192u8, 92u8, 251u8]; + 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + implementation_index: { + 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) + }, + implementation: 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::Uint(ethabi::Uint::from_big_endian( + match self + .implementation_index + .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.implementation)), + ]); + 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 SetPoolImplementations { + const NAME: &'static str = "set_pool_implementations"; + 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 SetViewsImplementation { + pub views_implementation: Vec, + } + impl SetViewsImplementation { + const METHOD_ID: [u8; 4] = [246u8, 250u8, 147u8, 127u8]; + 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 { + views_implementation: 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.views_implementation, + ))]); + 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 SetViewsImplementation { + const NAME: &'static str = "set_views_implementation"; + 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 ViewsImplementation {} + impl ViewsImplementation { + const METHOD_ID: [u8; 4] = [227u8, 21u8, 147u8, 216u8]; + 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 ViewsImplementation { + const NAME: &'static str = "views_implementation"; + 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 ViewsImplementation { + fn output(data: &[u8]) -> Result, String> { + 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 BasePoolAdded { + pub base_pool: Vec, + } + impl BasePoolAdded { + const TOPIC_ID: [u8; 32] = [ + 204u8, 106u8, 253u8, 254u8, 199u8, 157u8, 166u8, 190u8, 8u8, 20u8, 46u8, 206u8, 226u8, + 92u8, 241u8, 75u8, 102u8, 89u8, 97u8, 226u8, 93u8, 48u8, 216u8, 235u8, 164u8, 89u8, + 89u8, 190u8, 149u8, 71u8, 99u8, 95u8, + ]; + 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::Address], log.data.as_ref()) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for BasePoolAdded { + const NAME: &'static str = "BasePoolAdded"; + 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 LiquidityGaugeDeployed { + pub pool: Vec, + pub gauge: Vec, + } + impl LiquidityGaugeDeployed { + const TOPIC_ID: [u8; 32] = [ + 101u8, 107u8, 179u8, 76u8, 32u8, 73u8, 25u8, 112u8, 168u8, 193u8, 99u8, 243u8, 189u8, + 98u8, 234u8, 216u8, 32u8, 34u8, 179u8, 121u8, 195u8, 146u8, 73u8, 96u8, 236u8, 96u8, + 246u8, 219u8, 252u8, 90u8, 171u8, 59u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for LiquidityGaugeDeployed { + const NAME: &'static str = "LiquidityGaugeDeployed"; + 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 MetaPoolDeployed { + pub coin: Vec, + pub base_pool: Vec, + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub deployer: Vec, + } + impl MetaPoolDeployed { + const TOPIC_ID: [u8; 32] = [ + 1u8, 243u8, 28u8, 210u8, 171u8, 222u8, 180u8, 229u8, 225u8, 11u8, 165u8, 0u8, 242u8, + 219u8, 15u8, 147u8, 125u8, 158u8, 140u8, 115u8, 90u8, 176u8, 70u8, 129u8, 146u8, 84u8, + 65u8, 180u8, 234u8, 55u8, 237u8, 165u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 160usize { + 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::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + a: { + 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: { + 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) + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for MetaPoolDeployed { + const NAME: &'static str = "MetaPoolDeployed"; + 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 PlainPoolDeployed { + pub coins: Vec>, + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub deployer: Vec, + } + impl PlainPoolDeployed { + const TOPIC_ID: [u8; 32] = [ + 209u8, 214u8, 13u8, 70u8, 17u8, 228u8, 9u8, 27u8, 178u8, 229u8, 246u8, 153u8, 238u8, + 183u8, 145u8, 54u8, 194u8, 26u8, 194u8, 48u8, 90u8, 214u8, 9u8, 243u8, 222u8, 86u8, + 154u8, 252u8, 52u8, 113u8, 238u8, 204u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() < 160usize { + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + coins: 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(), + a: { + 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: { + 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) + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for PlainPoolDeployed { + const NAME: &'static str = "PlainPoolDeployed"; + 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) + } + } +} diff --git a/substreams/ethereum-curve/src/abi/erc20.rs b/substreams/ethereum-curve/src/abi/erc20.rs index 5dd70ca..5ea9219 100644 --- a/substreams/ethereum-curve/src/abi/erc20.rs +++ b/substreams/ethereum-curve/src/abi/erc20.rs @@ -929,8 +929,8 @@ pub mod events { .topics .get(0) .expect("bounds already checked") - .as_ref() == - Self::TOPIC_ID; + .as_ref() + == Self::TOPIC_ID; } pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { let mut values = @@ -1009,8 +1009,8 @@ pub mod events { .topics .get(0) .expect("bounds already checked") - .as_ref() == - Self::TOPIC_ID; + .as_ref() + == Self::TOPIC_ID; } pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { let mut values = diff --git a/substreams/ethereum-curve/src/abi/meta_pool_factory.rs b/substreams/ethereum-curve/src/abi/meta_pool_factory.rs index 84b1c3f..c96a410 100644 --- a/substreams/ethereum-curve/src/abi/meta_pool_factory.rs +++ b/substreams/ethereum-curve/src/abi/meta_pool_factory.rs @@ -1,6618 +1,5806 @@ - 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 AcceptTransferOwnership {} - impl AcceptTransferOwnership { - const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 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 AcceptTransferOwnership { - const NAME: &'static str = "accept_transfer_ownership"; - 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 AddBasePool { - pub base_pool: Vec, - pub fee_receiver: Vec, - pub asset_type: substreams::scalar::BigInt, - pub implementations: [Vec; 10usize], - } - impl AddBasePool { - const METHOD_ID: [u8; 4] = [47u8, 192u8, 86u8, 83u8]; - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - asset_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) - }, - implementations: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.fee_receiver), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.asset_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 v = self - .implementations - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(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 AddBasePool { - const NAME: &'static str = "add_base_pool"; - 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 AddExistingMetapools { - pub pools: [Vec; 10usize], - } - impl AddExistingMetapools { - const METHOD_ID: [u8; 4] = [219u8, 137u8, 250u8, 188u8]; - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pools: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(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 { - 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 AddExistingMetapools { - const NAME: &'static str = "add_existing_metapools"; - 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 AddExistingMetapools { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Admin {} - impl Admin { - const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; - 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 Admin { - const NAME: &'static str = "admin"; - 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 Admin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolAssets { - pub arg0: Vec, - } - impl BasePoolAssets { - const METHOD_ID: [u8; 4] = [16u8, 160u8, 2u8, 223u8]; - 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 { - arg0: 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.arg0))], - ); - 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 BasePoolAssets { - const NAME: &'static str = "base_pool_assets"; - 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 BasePoolAssets { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolCount {} - impl BasePoolCount { - const METHOD_ID: [u8; 4] = [222u8, 94u8, 74u8, 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 BasePoolCount { - const NAME: &'static str = "base_pool_count"; - 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 BasePoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolList { - pub arg0: substreams::scalar::BigInt, - } - impl BasePoolList { - const METHOD_ID: [u8; 4] = [34u8, 254u8, 86u8, 113u8]; - 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 { - arg0: { - 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.arg0.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::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 BasePoolList { - const NAME: &'static str = "base_pool_list"; - 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 BasePoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BatchSetPoolAssetType { - pub pools: [Vec; 32usize], - pub asset_types: [substreams::scalar::BigInt; 32usize], - } - impl BatchSetPoolAssetType { - const METHOD_ID: [u8; 4] = [117u8, 66u8, 240u8, 120u8]; - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 32usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 32usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pools: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - asset_types: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .asset_types - .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::FixedArray(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 BatchSetPoolAssetType { - const NAME: &'static str = "batch_set_pool_asset_type"; - 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 CommitTransferOwnership { - pub addr: Vec, - } - impl CommitTransferOwnership { - const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; - 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 { - addr: 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.addr))], - ); - 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 CommitTransferOwnership { - const NAME: &'static str = "commit_transfer_ownership"; - 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 ConvertMetapoolFees {} - impl ConvertMetapoolFees { - const METHOD_ID: [u8; 4] = [188u8, 201u8, 129u8, 210u8]; - 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 ConvertMetapoolFees { - const NAME: &'static str = "convert_metapool_fees"; - 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 ConvertMetapoolFees { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge { - pub pool: Vec, - } - impl DeployGauge { - const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; - 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 { - pool: 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.pool))], - ); - 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 DeployGauge { - const NAME: &'static str = "deploy_gauge"; - 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 DeployGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployMetapool1 { - pub base_pool: Vec, - pub name: String, - pub symbol: String, - pub coin: Vec, - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - } - impl DeployMetapool1 { - const METHOD_ID: [u8; 4] = [227u8, 57u8, 235u8, 79u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - 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 { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - a: { - 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: { - 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.base_pool), - ), - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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::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 DeployMetapool1 { - const NAME: &'static str = "deploy_metapool1"; - 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 DeployMetapool1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployMetapool2 { - pub base_pool: Vec, - pub name: String, - pub symbol: String, - pub coin: Vec, - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub implementation_idx: substreams::scalar::BigInt, - } - impl DeployMetapool2 { - const METHOD_ID: [u8; 4] = [222u8, 127u8, 227u8, 191u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - 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 { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - a: { - 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: { - 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) - }, - implementation_idx: { - 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.base_pool), - ), - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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.implementation_idx.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::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 DeployMetapool2 { - const NAME: &'static str = "deploy_metapool2"; - 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 DeployMetapool2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPlainPool1 { - pub name: String, - pub symbol: String, - pub coins: [Vec; 4usize], - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - } - impl DeployPlainPool1 { - const METHOD_ID: [u8; 4] = [205u8, 65u8, 155u8, 181u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 4usize, - ), - 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 { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - a: { - 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: { - 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::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .coins - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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::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 DeployPlainPool1 { - const NAME: &'static str = "deploy_plain_pool1"; - 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 DeployPlainPool1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPlainPool2 { - pub name: String, - pub symbol: String, - pub coins: [Vec; 4usize], - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub asset_type: substreams::scalar::BigInt, - } - impl DeployPlainPool2 { - const METHOD_ID: [u8; 4] = [92u8, 22u8, 72u8, 123u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 4usize, - ), - 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 { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - a: { - 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: { - 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) - }, - asset_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::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .coins - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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.asset_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, 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 DeployPlainPool2 { - const NAME: &'static str = "deploy_plain_pool2"; - 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 DeployPlainPool2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPlainPool3 { - pub name: String, - pub symbol: String, - pub coins: [Vec; 4usize], - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub asset_type: substreams::scalar::BigInt, - pub implementation_idx: substreams::scalar::BigInt, - } - impl DeployPlainPool3 { - const METHOD_ID: [u8; 4] = [82u8, 242u8, 219u8, 105u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 4usize, - ), - ethabi::ParamType::Uint(256usize), - 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 { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - a: { - 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: { - 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) - }, - asset_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) - }, - implementation_idx: { - 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::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .coins - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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.asset_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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.implementation_idx.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::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 DeployPlainPool3 { - const NAME: &'static str = "deploy_plain_pool3"; - 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 DeployPlainPool3 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub from: Vec, - pub to: Vec, - } - impl FindPoolForCoins1 { - const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 FindPoolForCoins1 { - const NAME: &'static str = "find_pool_for_coins1"; - 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 FindPoolForCoins1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins2 { - pub from: Vec, - pub to: Vec, - pub i: substreams::scalar::BigInt, - } - impl FindPoolForCoins2 { - const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { - 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.i.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::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 FindPoolForCoins2 { - const NAME: &'static str = "find_pool_for_coins2"; - 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 FindPoolForCoins2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdmin {} - impl FutureAdmin { - const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; - 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 FutureAdmin { - const NAME: &'static str = "future_admin"; - 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 FutureAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeImplementation {} - impl GaugeImplementation { - const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; - 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 GaugeImplementation { - const NAME: &'static str = "gauge_implementation"; - 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 GaugeImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetA { - pub pool: Vec, - } - impl GetA { - const METHOD_ID: [u8; 4] = [85u8, 179u8, 11u8, 25u8]; - 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 { - pool: 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.pool))], - ); - 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 GetA { - const NAME: &'static str = "get_A"; - 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 GetA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances { - pub pool: Vec, - } - impl GetAdminBalances { - const METHOD_ID: [u8; 4] = [193u8, 30u8, 69u8, 184u8]; - 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 { - pool: 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.pool))], - ); - 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; 4usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 4usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 4usize]> { - 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 GetAdminBalances { - const NAME: &'static str = "get_admin_balances"; - 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; 4usize]> - for GetAdminBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub pool: Vec, - } - impl GetBalances { - const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; - 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 { - pool: 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.pool))], - ); - 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; 4usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 4usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 4usize]> { - 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 GetBalances { - const NAME: &'static str = "get_balances"; - 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; 4usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBasePool { - pub pool: Vec, - } - impl GetBasePool { - const METHOD_ID: [u8; 4] = [111u8, 32u8, 214u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: 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.pool))], - ); - 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 GetBasePool { - const NAME: &'static str = "get_base_pool"; - 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 GetBasePool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub pool: Vec, - pub from: Vec, - pub to: Vec, - } - impl GetCoinIndices { - const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; - 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::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.pool)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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, bool), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Bool, - ], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_bytes_be(&v) - }, - { - 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) - }, - values.pop().expect(INTERNAL_ERR).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<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> { - 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 GetCoinIndices { - const NAME: &'static str = "get_coin_indices"; - 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, bool), - > for GetCoinIndices { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins { - pub pool: Vec, - } - impl GetCoins { - const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; - 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 { - pool: 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.pool))], - ); - 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; 4usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 4usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 4usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 4usize]> { - 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 GetCoins { - const NAME: &'static str = "get_coins"; - 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; 4usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 4usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub pool: Vec, - } - impl GetDecimals { - const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; - 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 { - pool: 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.pool))], - ); - 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; 4usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 4usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 4usize]> { - 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 GetDecimals { - const NAME: &'static str = "get_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<[substreams::scalar::BigInt; 4usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFeeReceiver { - pub pool: Vec, - } - impl GetFeeReceiver { - const METHOD_ID: [u8; 4] = [21u8, 74u8, 168u8, 245u8]; - 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 { - pool: 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.pool))], - ); - 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 GetFeeReceiver { - const NAME: &'static str = "get_fee_receiver"; - 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 GetFeeReceiver { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFees { - pub pool: Vec, - } - impl GetFees { - const METHOD_ID: [u8; 4] = [124u8, 219u8, 114u8, 176u8]; - 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 { - pool: 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.pool))], - ); - 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 GetFees { - const NAME: &'static str = "get_fees"; - 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 GetFees { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauge { - pub pool: Vec, - } - impl GetGauge { - const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; - 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 { - pool: 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.pool))], - ); - 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 GetGauge { - const NAME: &'static str = "get_gauge"; - 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 GetGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetImplementationAddress { - pub pool: Vec, - } - impl GetImplementationAddress { - const METHOD_ID: [u8; 4] = [81u8, 13u8, 152u8, 164u8]; - 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 { - pool: 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.pool))], - ); - 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 GetImplementationAddress { - const NAME: &'static str = "get_implementation_address"; - 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 GetImplementationAddress { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetMetaNCoins { - pub pool: Vec, - } - impl GetMetaNCoins { - const METHOD_ID: [u8; 4] = [235u8, 115u8, 243u8, 125u8]; - 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 { - pool: 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.pool))], - ); - 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 GetMetaNCoins { - const NAME: &'static str = "get_meta_n_coins"; - 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 GetMetaNCoins { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetMetapoolRates { - pub pool: Vec, - } - impl GetMetapoolRates { - const METHOD_ID: [u8; 4] = [6u8, 216u8, 241u8, 96u8]; - 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 { - pool: 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.pool))], - ); - 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; 2usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [iter.next().expect(INTERNAL_ERR), iter.next().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<[substreams::scalar::BigInt; 2usize]> { - 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 GetMetapoolRates { - const NAME: &'static str = "get_metapool_rates"; - 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; 2usize]> - for GetMetapoolRates { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins { - pub pool: Vec, - } - impl GetNCoins { - const METHOD_ID: [u8; 4] = [148u8, 4u8, 148u8, 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 { - pool: 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.pool))], - ); - 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 GetNCoins { - const NAME: &'static str = "get_n_coins"; - 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 GetNCoins { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolAssetType { - pub pool: Vec, - } - impl GetPoolAssetType { - const METHOD_ID: [u8; 4] = [102u8, 211u8, 150u8, 108u8]; - 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 { - pool: 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.pool))], - ); - 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 GetPoolAssetType { - const NAME: &'static str = "get_pool_asset_type"; - 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 GetPoolAssetType { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances { - pub pool: Vec, - } - impl GetUnderlyingBalances { - const METHOD_ID: [u8; 4] = [89u8, 244u8, 243u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetUnderlyingBalances { - const NAME: &'static str = "get_underlying_balances"; - 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; 8usize]> - for GetUnderlyingBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins { - pub pool: Vec, - } - impl GetUnderlyingCoins { - const METHOD_ID: [u8; 4] = [167u8, 117u8, 118u8, 239u8]; - 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 { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 8usize]> { - 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 GetUnderlyingCoins { - const NAME: &'static str = "get_underlying_coins"; - 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; 8usize]> - for GetUnderlyingCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingDecimals { - pub pool: Vec, - } - impl GetUnderlyingDecimals { - const METHOD_ID: [u8; 4] = [76u8, 176u8, 136u8, 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 { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetUnderlyingDecimals { - const NAME: &'static str = "get_underlying_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<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsMeta { - pub pool: Vec, - } - impl IsMeta { - const METHOD_ID: [u8; 4] = [228u8, 211u8, 50u8, 169u8]; - 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 { - pool: 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.pool))], - ); - 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 IsMeta { - const NAME: &'static str = "is_meta"; - 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 IsMeta { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Manager {} - impl Manager { - const METHOD_ID: [u8; 4] = [72u8, 28u8, 106u8, 117u8]; - 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 Manager { - const NAME: &'static str = "manager"; - 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 Manager { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct MetapoolImplementations { - pub base_pool: Vec, - } - impl MetapoolImplementations { - const METHOD_ID: [u8; 4] = [151u8, 15u8, 163u8, 243u8]; - 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 { - base_pool: 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.base_pool), - ), - ], - ); - 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; 10usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 10usize]> { - 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 MetapoolImplementations { - const NAME: &'static str = "metapool_implementations"; - 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; 10usize]> - for MetapoolImplementations { - fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PlainImplementations { - pub arg0: substreams::scalar::BigInt, - pub arg1: substreams::scalar::BigInt, - } - impl PlainImplementations { - const METHOD_ID: [u8; 4] = [49u8, 164u8, 248u8, 101u8]; - 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 { - arg0: { - 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) - }, - arg1: { - 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.arg0.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.arg1.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::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 PlainImplementations { - const NAME: &'static str = "plain_implementations"; - 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 PlainImplementations { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCount {} - impl PoolCount { - const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { - const NAME: &'static str = "pool_count"; - 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 PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub arg0: substreams::scalar::BigInt, - } - impl PoolList { - const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; - 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 { - arg0: { - 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.arg0.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::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 PoolList { - const NAME: &'static str = "pool_list"; - 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 PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetFeeReceiver { - pub base_pool: Vec, - pub fee_receiver: Vec, - } - impl SetFeeReceiver { - const METHOD_ID: [u8; 4] = [54u8, 210u8, 183u8, 122u8]; - 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 { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - fee_receiver: 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.base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.fee_receiver), - ), - ], - ); - 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 SetFeeReceiver { - const NAME: &'static str = "set_fee_receiver"; - 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 SetGaugeImplementation { - pub gauge_implementation: Vec, - } - impl SetGaugeImplementation { - const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; - 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 { - gauge_implementation: 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.gauge_implementation), - ), - ], - ); - 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 SetGaugeImplementation { - const NAME: &'static str = "set_gauge_implementation"; - 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 SetManager { - pub manager: Vec, - } - impl SetManager { - const METHOD_ID: [u8; 4] = [154u8, 236u8, 232u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - manager: 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.manager))], - ); - 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 SetManager { - const NAME: &'static str = "set_manager"; - 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 SetMetapoolImplementations { - pub base_pool: Vec, - pub implementations: [Vec; 10usize], - } - impl SetMetapoolImplementations { - const METHOD_ID: [u8; 4] = [203u8, 149u8, 107u8, 70u8]; - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - implementations: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.base_pool), - ), - { - let v = self - .implementations - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(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 SetMetapoolImplementations { - const NAME: &'static str = "set_metapool_implementations"; - 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 SetPlainImplementations { - pub n_coins: substreams::scalar::BigInt, - pub implementations: [Vec; 10usize], - } - impl SetPlainImplementations { - const METHOD_ID: [u8; 4] = [157u8, 219u8, 244u8, 185u8]; - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - n_coins: { - 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) - }, - implementations: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.n_coins.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 - .implementations - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(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 SetPlainImplementations { - const NAME: &'static str = "set_plain_implementations"; - 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() + +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 AcceptTransferOwnership {} + impl AcceptTransferOwnership { + const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolAdded { - pub base_pool: Vec, + impl substreams_ethereum::Function for AcceptTransferOwnership { + const NAME: &'static str = "accept_transfer_ownership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl BasePoolAdded { - const TOPIC_ID: [u8; 32] = [ - 204u8, - 106u8, - 253u8, - 254u8, - 199u8, - 157u8, - 166u8, - 190u8, - 8u8, - 20u8, - 46u8, - 206u8, - 226u8, - 92u8, - 241u8, - 75u8, - 102u8, - 89u8, - 97u8, - 226u8, - 93u8, - 48u8, - 216u8, - 235u8, - 164u8, - 89u8, - 89u8, - 190u8, - 149u8, - 71u8, - 99u8, - 95u8, - ]; - 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; + 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 AddBasePool { + pub base_pool: Vec, + pub fee_receiver: Vec, + pub asset_type: substreams::scalar::BigInt, + pub implementations: [Vec; 10usize], + } + impl AddBasePool { + const METHOD_ID: [u8; 4] = [47u8, 192u8, 86u8, 83u8]; + 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()); } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - base_pool: values + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 10usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + asset_type: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for BasePoolAdded { - const NAME: &'static str = "BasePoolAdded"; - 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 LiquidityGaugeDeployed { - pub pool: Vec, - pub gauge: Vec, - } - impl LiquidityGaugeDeployed { - const TOPIC_ID: [u8; 32] = [ - 101u8, - 107u8, - 179u8, - 76u8, - 32u8, - 73u8, - 25u8, - 112u8, - 168u8, - 193u8, - 99u8, - 243u8, - 189u8, - 98u8, - 234u8, - 216u8, - 32u8, - 34u8, - 179u8, - 121u8, - 195u8, - 146u8, - 73u8, - 96u8, - 236u8, - 96u8, - 246u8, - 219u8, - 252u8, - 90u8, - 171u8, - 59u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + implementations: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge: values + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.base_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.fee_receiver)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.asset_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 v = self + .implementations + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(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 AddBasePool { + const NAME: &'static str = "add_base_pool"; + 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 AddExistingMetapools { + pub pools: [Vec; 10usize], + } + impl AddExistingMetapools { + const METHOD_ID: [u8; 4] = [219u8, 137u8, 250u8, 188u8]; + 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::FixedArray(Box::new(ethabi::ParamType::Address), 10usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pools: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[{ + let v = self + .pools + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(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 { + 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, } } - impl substreams_ethereum::Event for LiquidityGaugeDeployed { - const NAME: &'static str = "LiquidityGaugeDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct MetaPoolDeployed { - pub coin: Vec, - pub base_pool: Vec, - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub deployer: Vec, - } - impl MetaPoolDeployed { - const TOPIC_ID: [u8; 32] = [ - 1u8, - 243u8, - 28u8, - 210u8, - 171u8, - 222u8, - 180u8, - 229u8, - 225u8, - 11u8, - 165u8, - 0u8, - 242u8, - 219u8, - 15u8, - 147u8, - 125u8, - 158u8, - 140u8, - 115u8, - 90u8, - 176u8, - 70u8, - 129u8, - 146u8, - 84u8, - 65u8, - 180u8, - 234u8, - 55u8, - 237u8, - 165u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 160usize { - 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::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - coin: values + } + } + impl substreams_ethereum::Function for AddExistingMetapools { + const NAME: &'static str = "add_existing_metapools"; + 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 AddExistingMetapools { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Admin {} + impl Admin { + const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; + 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 Admin { + const NAME: &'static str = "admin"; + 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 Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolAssets { + pub arg0: Vec, + } + impl BasePoolAssets { + const METHOD_ID: [u8; 4] = [16u8, 160u8, 2u8, 223u8]; + 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 { + arg0: 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.arg0))]); + 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 BasePoolAssets { + const NAME: &'static str = "base_pool_assets"; + 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 BasePoolAssets { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolCount {} + impl BasePoolCount { + const METHOD_ID: [u8; 4] = [222u8, 94u8, 74u8, 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 BasePoolCount { + const NAME: &'static str = "base_pool_count"; + 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 BasePoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolList { + pub arg0: substreams::scalar::BigInt, + } + impl BasePoolList { + const METHOD_ID: [u8; 4] = [34u8, 254u8, 86u8, 113u8]; + 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 { + arg0: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - base_pool: values + .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.arg0.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::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 BasePoolList { + const NAME: &'static str = "base_pool_list"; + 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 BasePoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BatchSetPoolAssetType { + pub pools: [Vec; 32usize], + pub asset_types: [substreams::scalar::BigInt; 32usize], + } + impl BatchSetPoolAssetType { + const METHOD_ID: [u8; 4] = [117u8, 66u8, 240u8, 120u8]; + 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::FixedArray(Box::new(ethabi::ParamType::Address), 32usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 32usize, + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pools: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - a: { + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + asset_types: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + { + let v = self + .pools + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + { + let v = self + .asset_types + .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::FixedArray(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 BatchSetPoolAssetType { + const NAME: &'static str = "batch_set_pool_asset_type"; + 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 CommitTransferOwnership { + pub addr: Vec, + } + impl CommitTransferOwnership { + const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; + 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 { + addr: 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.addr))]); + 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 CommitTransferOwnership { + const NAME: &'static str = "commit_transfer_ownership"; + 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 ConvertMetapoolFees {} + impl ConvertMetapoolFees { + const METHOD_ID: [u8; 4] = [188u8, 201u8, 129u8, 210u8]; + 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 ConvertMetapoolFees { + const NAME: &'static str = "convert_metapool_fees"; + 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 ConvertMetapoolFees { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployGauge { + pub pool: Vec, + } + impl DeployGauge { + const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; + 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 { + pool: 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.pool))]); + 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 DeployGauge { + const NAME: &'static str = "deploy_gauge"; + 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 DeployGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool1 { + pub base_pool: Vec, + pub name: String, + pub symbol: String, + pub coin: Vec, + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + } + impl DeployMetapool1 { + const METHOD_ID: [u8; 4] = [227u8, 57u8, 235u8, 79u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + 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 { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + a: { + 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: { + 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.base_pool)), + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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::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 DeployMetapool1 { + const NAME: &'static str = "deploy_metapool1"; + 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 DeployMetapool1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool2 { + pub base_pool: Vec, + pub name: String, + pub symbol: String, + pub coin: Vec, + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub implementation_idx: substreams::scalar::BigInt, + } + impl DeployMetapool2 { + const METHOD_ID: [u8; 4] = [222u8, 127u8, 227u8, 191u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + 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 { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + a: { + 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: { + 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) + }, + implementation_idx: { + 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.base_pool)), + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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 + .implementation_idx + .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::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 DeployMetapool2 { + const NAME: &'static str = "deploy_metapool2"; + 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 DeployMetapool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool1 { + pub name: String, + pub symbol: String, + pub coins: [Vec; 4usize], + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + } + impl DeployPlainPool1 { + const METHOD_ID: [u8; 4] = [205u8, 65u8, 155u8, 181u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize), + 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 { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + a: { + 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: { + 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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .coins + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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::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 DeployPlainPool1 { + const NAME: &'static str = "deploy_plain_pool1"; + 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 DeployPlainPool1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool2 { + pub name: String, + pub symbol: String, + pub coins: [Vec; 4usize], + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub asset_type: substreams::scalar::BigInt, + } + impl DeployPlainPool2 { + const METHOD_ID: [u8; 4] = [92u8, 22u8, 72u8, 123u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize), + 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 { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + a: { + 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: { + 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) + }, + asset_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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .coins + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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.asset_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, 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 DeployPlainPool2 { + const NAME: &'static str = "deploy_plain_pool2"; + 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 DeployPlainPool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool3 { + pub name: String, + pub symbol: String, + pub coins: [Vec; 4usize], + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub asset_type: substreams::scalar::BigInt, + pub implementation_idx: substreams::scalar::BigInt, + } + impl DeployPlainPool3 { + const METHOD_ID: [u8; 4] = [82u8, 242u8, 219u8, 105u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize), + ethabi::ParamType::Uint(256usize), + 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 { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + a: { + 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: { + 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) + }, + asset_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) + }, + implementation_idx: { + 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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .coins + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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.asset_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(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .implementation_idx + .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::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 DeployPlainPool3 { + const NAME: &'static str = "deploy_plain_pool3"; + 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 DeployPlainPool3 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub from: Vec, + pub to: Vec, + } + impl FindPoolForCoins1 { + const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 FindPoolForCoins1 { + const NAME: &'static str = "find_pool_for_coins1"; + 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 FindPoolForCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins2 { + pub from: Vec, + pub to: Vec, + pub i: substreams::scalar::BigInt, + } + impl FindPoolForCoins2 { + const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + i: { + 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.i.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::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 FindPoolForCoins2 { + const NAME: &'static str = "find_pool_for_coins2"; + 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 FindPoolForCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAdmin {} + impl FutureAdmin { + const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; + 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 FutureAdmin { + const NAME: &'static str = "future_admin"; + 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 FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeImplementation {} + impl GaugeImplementation { + const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; + 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 GaugeImplementation { + const NAME: &'static str = "gauge_implementation"; + 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 GaugeImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetA { + pub pool: Vec, + } + impl GetA { + const METHOD_ID: [u8; 4] = [85u8, 179u8, 11u8, 25u8]; + 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 { + pool: 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.pool))]); + 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 GetA { + const NAME: &'static str = "get_A"; + 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 GetA { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAdminBalances { + pub pool: Vec, + } + impl GetAdminBalances { + const METHOD_ID: [u8; 4] = [193u8, 30u8, 69u8, 184u8]; + 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 { + pool: 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.pool))]); + 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; 4usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 4usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) + inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - fee: { + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 4usize]> { + 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 GetAdminBalances { + const NAME: &'static str = "get_admin_balances"; + 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; 4usize]> + for GetAdminBalances + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub pool: Vec, + } + impl GetBalances { + const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; + 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 { + pool: 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.pool))]); + 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; 4usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 4usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) + inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - deployer: values + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 4usize]> { + 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 GetBalances { + const NAME: &'static str = "get_balances"; + 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; 4usize]> for GetBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasePool { + pub pool: Vec, + } + impl GetBasePool { + const METHOD_ID: [u8; 4] = [111u8, 32u8, 214u8, 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], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: 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.pool))]); + 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 GetBasePool { + const NAME: &'static str = "get_base_pool"; + 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 GetBasePool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub pool: Vec, + pub from: Vec, + pub to: Vec, + } + impl GetCoinIndices { + const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; + 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::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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, bool), String> + { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Bool, + ], + 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_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for MetaPoolDeployed { - const NAME: &'static str = "MetaPoolDeployed"; - 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 PlainPoolDeployed { - pub coins: [Vec; 4usize], - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub deployer: Vec, - } - impl PlainPoolDeployed { - const TOPIC_ID: [u8; 32] = [ - 91u8, - 74u8, - 40u8, - 201u8, - 64u8, - 40u8, - 43u8, - 91u8, - 241u8, - 131u8, - 223u8, - 106u8, - 4u8, - 107u8, - 129u8, - 25u8, - 207u8, - 110u8, - 222u8, - 182u8, - 40u8, - 89u8, - 247u8, - 94u8, - 131u8, - 94u8, - 183u8, - 186u8, - 131u8, - 76u8, - 206u8, - 141u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 224usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 4usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - a: { - 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: { - 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) - }, - deployer: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + values + .pop() + .expect(INTERNAL_ERR) + .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, } } - impl substreams_ethereum::Event for PlainPoolDeployed { - const NAME: &'static str = "PlainPoolDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + pub fn call( + &self, + address: Vec, + ) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> { + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 + } } } - } \ No newline at end of file + } + impl substreams_ethereum::Function for GetCoinIndices { + const NAME: &'static str = "get_coin_indices"; + 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, + bool, + )> for GetCoinIndices + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins { + pub pool: Vec, + } + impl GetCoins { + const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; + 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 { + pool: 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.pool))]); + 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; 4usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 4usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 4usize]> { + 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 GetCoins { + const NAME: &'static str = "get_coins"; + 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; 4usize]> for GetCoins { + fn output(data: &[u8]) -> Result<[Vec; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub pool: Vec, + } + impl GetDecimals { + const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; + 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 { + pool: 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.pool))]); + 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; 4usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 4usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 4usize]> { + 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 GetDecimals { + const NAME: &'static str = "get_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<[substreams::scalar::BigInt; 4usize]> for GetDecimals { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFeeReceiver { + pub pool: Vec, + } + impl GetFeeReceiver { + const METHOD_ID: [u8; 4] = [21u8, 74u8, 168u8, 245u8]; + 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 { + pool: 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.pool))]); + 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 GetFeeReceiver { + const NAME: &'static str = "get_fee_receiver"; + 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 GetFeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees { + pub pool: Vec, + } + impl GetFees { + const METHOD_ID: [u8; 4] = [124u8, 219u8, 114u8, 176u8]; + 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 { + pool: 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.pool))]); + 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 GetFees { + const NAME: &'static str = "get_fees"; + 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 GetFees + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauge { + pub pool: Vec, + } + impl GetGauge { + const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; + 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 { + pool: 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.pool))]); + 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 GetGauge { + const NAME: &'static str = "get_gauge"; + 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 GetGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetImplementationAddress { + pub pool: Vec, + } + impl GetImplementationAddress { + const METHOD_ID: [u8; 4] = [81u8, 13u8, 152u8, 164u8]; + 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 { + pool: 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.pool))]); + 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 GetImplementationAddress { + const NAME: &'static str = "get_implementation_address"; + 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 GetImplementationAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMetaNCoins { + pub pool: Vec, + } + impl GetMetaNCoins { + const METHOD_ID: [u8; 4] = [235u8, 115u8, 243u8, 125u8]; + 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 { + pool: 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.pool))]); + 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 GetMetaNCoins { + const NAME: &'static str = "get_meta_n_coins"; + 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 GetMetaNCoins + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMetapoolRates { + pub pool: Vec, + } + impl GetMetapoolRates { + const METHOD_ID: [u8; 4] = [6u8, 216u8, 241u8, 96u8]; + 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 { + pool: 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.pool))]); + 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; 2usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [iter.next().expect(INTERNAL_ERR), iter.next().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<[substreams::scalar::BigInt; 2usize]> { + 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 GetMetapoolRates { + const NAME: &'static str = "get_metapool_rates"; + 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; 2usize]> + for GetMetapoolRates + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNCoins { + pub pool: Vec, + } + impl GetNCoins { + const METHOD_ID: [u8; 4] = [148u8, 4u8, 148u8, 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 { + pool: 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.pool))]); + 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 GetNCoins { + const NAME: &'static str = "get_n_coins"; + 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 GetNCoins { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolAssetType { + pub pool: Vec, + } + impl GetPoolAssetType { + const METHOD_ID: [u8; 4] = [102u8, 211u8, 150u8, 108u8]; + 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 { + pool: 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.pool))]); + 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 GetPoolAssetType { + const NAME: &'static str = "get_pool_asset_type"; + 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 GetPoolAssetType { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingBalances { + pub pool: Vec, + } + impl GetUnderlyingBalances { + const METHOD_ID: [u8; 4] = [89u8, 244u8, 243u8, 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], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetUnderlyingBalances { + const NAME: &'static str = "get_underlying_balances"; + 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; 8usize]> + for GetUnderlyingBalances + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingCoins { + pub pool: Vec, + } + impl GetUnderlyingCoins { + const METHOD_ID: [u8; 4] = [167u8, 117u8, 118u8, 239u8]; + 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 { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 8usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 8usize]> { + 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 GetUnderlyingCoins { + const NAME: &'static str = "get_underlying_coins"; + 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; 8usize]> for GetUnderlyingCoins { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingDecimals { + pub pool: Vec, + } + impl GetUnderlyingDecimals { + const METHOD_ID: [u8; 4] = [76u8, 176u8, 136u8, 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 { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetUnderlyingDecimals { + const NAME: &'static str = "get_underlying_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<[substreams::scalar::BigInt; 8usize]> + for GetUnderlyingDecimals + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsMeta { + pub pool: Vec, + } + impl IsMeta { + const METHOD_ID: [u8; 4] = [228u8, 211u8, 50u8, 169u8]; + 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 { + pool: 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.pool))]); + 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 IsMeta { + const NAME: &'static str = "is_meta"; + 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 IsMeta { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Manager {} + impl Manager { + const METHOD_ID: [u8; 4] = [72u8, 28u8, 106u8, 117u8]; + 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 Manager { + const NAME: &'static str = "manager"; + 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 Manager { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MetapoolImplementations { + pub base_pool: Vec, + } + impl MetapoolImplementations { + const METHOD_ID: [u8; 4] = [151u8, 15u8, 163u8, 243u8]; + 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 { + base_pool: 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.base_pool, + ))]); + 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; 10usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 10usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 10usize]> { + 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 MetapoolImplementations { + const NAME: &'static str = "metapool_implementations"; + 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; 10usize]> for MetapoolImplementations { + fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PlainImplementations { + pub arg0: substreams::scalar::BigInt, + pub arg1: substreams::scalar::BigInt, + } + impl PlainImplementations { + const METHOD_ID: [u8; 4] = [49u8, 164u8, 248u8, 101u8]; + 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 { + arg0: { + 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) + }, + arg1: { + 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.arg0.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.arg1.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::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 PlainImplementations { + const NAME: &'static str = "plain_implementations"; + 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 PlainImplementations { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolCount {} + impl PoolCount { + const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { + const NAME: &'static str = "pool_count"; + 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 PoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolList { + pub arg0: substreams::scalar::BigInt, + } + impl PoolList { + const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; + 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 { + arg0: { + 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.arg0.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::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 PoolList { + const NAME: &'static str = "pool_list"; + 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 PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub base_pool: Vec, + pub fee_receiver: Vec, + } + impl SetFeeReceiver { + const METHOD_ID: [u8; 4] = [54u8, 210u8, 183u8, 122u8]; + 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 { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + fee_receiver: 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.base_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.fee_receiver)), + ]); + 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 SetFeeReceiver { + const NAME: &'static str = "set_fee_receiver"; + 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 SetGaugeImplementation { + pub gauge_implementation: Vec, + } + impl SetGaugeImplementation { + const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; + 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 { + gauge_implementation: 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.gauge_implementation, + ))]); + 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 SetGaugeImplementation { + const NAME: &'static str = "set_gauge_implementation"; + 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 SetManager { + pub manager: Vec, + } + impl SetManager { + const METHOD_ID: [u8; 4] = [154u8, 236u8, 232u8, 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], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + manager: 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.manager, + ))]); + 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 SetManager { + const NAME: &'static str = "set_manager"; + 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 SetMetapoolImplementations { + pub base_pool: Vec, + pub implementations: [Vec; 10usize], + } + impl SetMetapoolImplementations { + const METHOD_ID: [u8; 4] = [203u8, 149u8, 107u8, 70u8]; + 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::FixedArray(Box::new(ethabi::ParamType::Address), 10usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + implementations: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.base_pool)), + { + let v = self + .implementations + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(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 SetMetapoolImplementations { + const NAME: &'static str = "set_metapool_implementations"; + 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 SetPlainImplementations { + pub n_coins: substreams::scalar::BigInt, + pub implementations: [Vec; 10usize], + } + impl SetPlainImplementations { + const METHOD_ID: [u8; 4] = [157u8, 219u8, 244u8, 185u8]; + 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::FixedArray(Box::new(ethabi::ParamType::Address), 10usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + n_coins: { + 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) + }, + implementations: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.n_coins.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 + .implementations + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(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 SetPlainImplementations { + const NAME: &'static str = "set_plain_implementations"; + 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() + } + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolAdded { + pub base_pool: Vec, + } + impl BasePoolAdded { + const TOPIC_ID: [u8; 32] = [ + 204u8, 106u8, 253u8, 254u8, 199u8, 157u8, 166u8, 190u8, 8u8, 20u8, 46u8, 206u8, 226u8, + 92u8, 241u8, 75u8, 102u8, 89u8, 97u8, 226u8, 93u8, 48u8, 216u8, 235u8, 164u8, 89u8, + 89u8, 190u8, 149u8, 71u8, 99u8, 95u8, + ]; + 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::Address], log.data.as_ref()) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for BasePoolAdded { + const NAME: &'static str = "BasePoolAdded"; + 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 LiquidityGaugeDeployed { + pub pool: Vec, + pub gauge: Vec, + } + impl LiquidityGaugeDeployed { + const TOPIC_ID: [u8; 32] = [ + 101u8, 107u8, 179u8, 76u8, 32u8, 73u8, 25u8, 112u8, 168u8, 193u8, 99u8, 243u8, 189u8, + 98u8, 234u8, 216u8, 32u8, 34u8, 179u8, 121u8, 195u8, 146u8, 73u8, 96u8, 236u8, 96u8, + 246u8, 219u8, 252u8, 90u8, 171u8, 59u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for LiquidityGaugeDeployed { + const NAME: &'static str = "LiquidityGaugeDeployed"; + 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 MetaPoolDeployed { + pub coin: Vec, + pub base_pool: Vec, + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub deployer: Vec, + } + impl MetaPoolDeployed { + const TOPIC_ID: [u8; 32] = [ + 1u8, 243u8, 28u8, 210u8, 171u8, 222u8, 180u8, 229u8, 225u8, 11u8, 165u8, 0u8, 242u8, + 219u8, 15u8, 147u8, 125u8, 158u8, 140u8, 115u8, 90u8, 176u8, 70u8, 129u8, 146u8, 84u8, + 65u8, 180u8, 234u8, 55u8, 237u8, 165u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 160usize { + 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::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + a: { + 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: { + 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) + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for MetaPoolDeployed { + const NAME: &'static str = "MetaPoolDeployed"; + 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 PlainPoolDeployed { + pub coins: [Vec; 4usize], + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub deployer: Vec, + } + impl PlainPoolDeployed { + const TOPIC_ID: [u8; 32] = [ + 91u8, 74u8, 40u8, 201u8, 64u8, 40u8, 43u8, 91u8, 241u8, 131u8, 223u8, 106u8, 4u8, + 107u8, 129u8, 25u8, 207u8, 110u8, 222u8, 182u8, 40u8, 89u8, 247u8, 94u8, 131u8, 94u8, + 183u8, 186u8, 131u8, 76u8, 206u8, 141u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 224usize { + 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::FixedArray(Box::new(ethabi::ParamType::Address), 4usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + coins: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + a: { + 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: { + 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) + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for PlainPoolDeployed { + const NAME: &'static str = "PlainPoolDeployed"; + 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) + } + } +} diff --git a/substreams/ethereum-curve/src/abi/meta_registry.rs b/substreams/ethereum-curve/src/abi/meta_registry.rs index d436b8d..c072b8d 100644 --- a/substreams/ethereum-curve/src/abi/meta_registry.rs +++ b/substreams/ethereum-curve/src/abi/meta_registry.rs @@ -1,8019 +1,7129 @@ - 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 AddRegistryHandler { - pub registry_handler: Vec, - } - impl AddRegistryHandler { - const METHOD_ID: [u8; 4] = [34u8, 245u8, 149u8, 200u8]; - 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 { - registry_handler: 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.registry_handler), - ), - ], - ); - 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 AddRegistryHandler { - const NAME: &'static str = "add_registry_handler"; - 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 AddressProvider {} - impl AddressProvider { - const METHOD_ID: [u8; 4] = [206u8, 80u8, 194u8, 231u8]; - 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 AddressProvider { - const NAME: &'static str = "address_provider"; - 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 AddressProvider { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub from: Vec, - pub to: Vec, - } - impl FindPoolForCoins1 { - const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 FindPoolForCoins1 { - const NAME: &'static str = "find_pool_for_coins1"; - 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 FindPoolForCoins1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins2 { - pub from: Vec, - pub to: Vec, - pub i: substreams::scalar::BigInt, - } - impl FindPoolForCoins2 { - const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { - 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.i.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::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 FindPoolForCoins2 { - const NAME: &'static str = "find_pool_for_coins2"; - 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 FindPoolForCoins2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolsForCoins { - pub from: Vec, - pub to: Vec, - } - impl FindPoolsForCoins { - const METHOD_ID: [u8; 4] = [160u8, 100u8, 7u8, 43u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 FindPoolsForCoins { - const NAME: &'static str = "find_pools_for_coins"; - 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 FindPoolsForCoins { - fn output(data: &[u8]) -> Result>, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances1 { - pub pool: Vec, - } - impl GetAdminBalances1 { - const METHOD_ID: [u8; 4] = [193u8, 30u8, 69u8, 184u8]; - 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 { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetAdminBalances1 { - const NAME: &'static str = "get_admin_balances1"; - 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; 8usize]> - for GetAdminBalances1 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetAdminBalances2 { - const METHOD_ID: [u8; 4] = [192u8, 191u8, 76u8, 191u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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<[substreams::scalar::BigInt; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetAdminBalances2 { - const NAME: &'static str = "get_admin_balances2"; - 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; 8usize]> - for GetAdminBalances2 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances1 { - pub pool: Vec, - } - impl GetBalances1 { - const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; - 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 { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetBalances1 { - const NAME: &'static str = "get_balances1"; - 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; 8usize]> - for GetBalances1 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetBalances2 { - const METHOD_ID: [u8; 4] = [170u8, 133u8, 22u8, 156u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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<[substreams::scalar::BigInt; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetBalances2 { - const NAME: &'static str = "get_balances2"; - 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; 8usize]> - for GetBalances2 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBasePool1 { - pub pool: Vec, - } - impl GetBasePool1 { - const METHOD_ID: [u8; 4] = [111u8, 32u8, 214u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: 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.pool))], - ); - 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 GetBasePool1 { - const NAME: &'static str = "get_base_pool1"; - 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 GetBasePool1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBasePool2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetBasePool2 { - const METHOD_ID: [u8; 4] = [165u8, 78u8, 58u8, 222u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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::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 GetBasePool2 { - const NAME: &'static str = "get_base_pool2"; - 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 GetBasePool2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBaseRegistry { - pub registry_handler: Vec, - } - impl GetBaseRegistry { - const METHOD_ID: [u8; 4] = [132u8, 225u8, 113u8, 13u8]; - 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 { - registry_handler: 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.registry_handler), - ), - ], - ); - 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 GetBaseRegistry { - const NAME: &'static str = "get_base_registry"; - 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 GetBaseRegistry { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices1 { - pub pool: Vec, - pub from: Vec, - pub to: Vec, - } - impl GetCoinIndices1 { - const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; - 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::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.pool)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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, bool), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Bool, - ], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_bytes_be(&v) - }, - { - 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) - }, - values.pop().expect(INTERNAL_ERR).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<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> { - 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 GetCoinIndices1 { - const NAME: &'static str = "get_coin_indices1"; - 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, bool), - > for GetCoinIndices1 { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices2 { - pub pool: Vec, - pub from: Vec, - pub to: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetCoinIndices2 { - const METHOD_ID: [u8; 4] = [99u8, 251u8, 61u8, 219u8]; - 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::Address, - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Bool, - ], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_bytes_be(&v) - }, - { - 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) - }, - values.pop().expect(INTERNAL_ERR).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<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> { - 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 GetCoinIndices2 { - const NAME: &'static str = "get_coin_indices2"; - 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, bool), - > for GetCoinIndices2 { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins1 { - pub pool: Vec, - } - impl GetCoins1 { - const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; - 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 { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 8usize]> { - 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 GetCoins1 { - const NAME: &'static str = "get_coins1"; - 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; 8usize]> for GetCoins1 { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetCoins2 { - const METHOD_ID: [u8; 4] = [110u8, 190u8, 81u8, 252u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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<[Vec; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 8usize]> { - 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 GetCoins2 { - const NAME: &'static str = "get_coins2"; - 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; 8usize]> for GetCoins2 { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals1 { - pub pool: Vec, - } - impl GetDecimals1 { - const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; - 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 { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetDecimals1 { - const NAME: &'static str = "get_decimals1"; - 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; 8usize]> - for GetDecimals1 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetDecimals2 { - const METHOD_ID: [u8; 4] = [64u8, 63u8, 80u8, 47u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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<[substreams::scalar::BigInt; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetDecimals2 { - const NAME: &'static str = "get_decimals2"; - 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; 8usize]> - for GetDecimals2 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFees1 { - pub pool: Vec, - } - impl GetFees1 { - const METHOD_ID: [u8; 4] = [124u8, 219u8, 114u8, 176u8]; - 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 { - pool: 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.pool))], - ); - 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; 10usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 10usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 10usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 10usize]> { - 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 GetFees1 { - const NAME: &'static str = "get_fees1"; - 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; 10usize], - > for GetFees1 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 10usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFees2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetFees2 { - const METHOD_ID: [u8; 4] = [14u8, 213u8, 164u8, 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::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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<[substreams::scalar::BigInt; 10usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 10usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 10usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 10usize]> { - 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 GetFees2 { - const NAME: &'static str = "get_fees2"; - 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; 10usize], - > for GetFees2 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 10usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauge1 { - pub pool: Vec, - } - impl GetGauge1 { - const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; - 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 { - pool: 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.pool))], - ); - 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 GetGauge1 { - const NAME: &'static str = "get_gauge1"; - 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 GetGauge1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauge2 { - pub pool: Vec, - pub gauge_idx: substreams::scalar::BigInt, - } - impl GetGauge2 { - const METHOD_ID: [u8; 4] = [228u8, 8u8, 18u8, 32u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge_idx: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.gauge_idx.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::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 GetGauge2 { - const NAME: &'static str = "get_gauge2"; - 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 GetGauge2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauge3 { - pub pool: Vec, - pub gauge_idx: substreams::scalar::BigInt, - pub handler_id: substreams::scalar::BigInt, - } - impl GetGauge3 { - const METHOD_ID: [u8; 4] = [119u8, 63u8, 183u8, 227u8]; - 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), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge_idx: { - 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) - }, - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.gauge_idx.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.handler_id.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::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 GetGauge3 { - const NAME: &'static str = "get_gauge3"; - 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 GetGauge3 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGaugeType1 { - pub pool: Vec, - } - impl GetGaugeType1 { - const METHOD_ID: [u8; 4] = [37u8, 250u8, 93u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: 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.pool))], - ); - 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::Int(128usize)], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_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 GetGaugeType1 { - const NAME: &'static str = "get_gauge_type1"; - 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 GetGaugeType1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGaugeType2 { - pub pool: Vec, - pub gauge_idx: substreams::scalar::BigInt, - } - impl GetGaugeType2 { - const METHOD_ID: [u8; 4] = [124u8, 81u8, 219u8, 85u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge_idx: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.gauge_idx.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::Int(128usize)], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_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 GetGaugeType2 { - const NAME: &'static str = "get_gauge_type2"; - 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 GetGaugeType2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGaugeType3 { - pub pool: Vec, - pub gauge_idx: substreams::scalar::BigInt, - pub handler_id: substreams::scalar::BigInt, - } - impl GetGaugeType3 { - const METHOD_ID: [u8; 4] = [248u8, 182u8, 97u8, 226u8]; - 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), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge_idx: { - 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) - }, - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.gauge_idx.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.handler_id.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::Int(128usize)], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_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 GetGaugeType3 { - const NAME: &'static str = "get_gauge_type3"; - 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 GetGaugeType3 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLpToken1 { - pub pool: Vec, - } - impl GetLpToken1 { - const METHOD_ID: [u8; 4] = [55u8, 149u8, 16u8, 73u8]; - 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 { - pool: 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.pool))], - ); - 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 GetLpToken1 { - const NAME: &'static str = "get_lp_token1"; - 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 GetLpToken1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLpToken2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetLpToken2 { - const METHOD_ID: [u8; 4] = [8u8, 129u8, 113u8, 95u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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::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 GetLpToken2 { - const NAME: &'static str = "get_lp_token2"; - 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 GetLpToken2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins1 { - pub pool: Vec, - } - impl GetNCoins1 { - const METHOD_ID: [u8; 4] = [148u8, 4u8, 148u8, 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 { - pool: 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.pool))], - ); - 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 GetNCoins1 { - const NAME: &'static str = "get_n_coins1"; - 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 GetNCoins1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetNCoins2 { - const METHOD_ID: [u8; 4] = [17u8, 216u8, 18u8, 121u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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 GetNCoins2 { - const NAME: &'static str = "get_n_coins2"; - 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 GetNCoins2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNUnderlyingCoins1 { - pub pool: Vec, - } - impl GetNUnderlyingCoins1 { - const METHOD_ID: [u8; 4] = [10u8, 112u8, 12u8, 8u8]; - 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 { - pool: 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.pool))], - ); - 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 GetNUnderlyingCoins1 { - const NAME: &'static str = "get_n_underlying_coins1"; - 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 GetNUnderlyingCoins1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNUnderlyingCoins2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetNUnderlyingCoins2 { - const METHOD_ID: [u8; 4] = [222u8, 205u8, 246u8, 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, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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 GetNUnderlyingCoins2 { - const NAME: &'static str = "get_n_underlying_coins2"; - 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 GetNUnderlyingCoins2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolAssetType1 { - pub pool: Vec, - } - impl GetPoolAssetType1 { - const METHOD_ID: [u8; 4] = [102u8, 211u8, 150u8, 108u8]; - 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 { - pool: 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.pool))], - ); - 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 GetPoolAssetType1 { - const NAME: &'static str = "get_pool_asset_type1"; - 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 GetPoolAssetType1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolAssetType2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetPoolAssetType2 { - const METHOD_ID: [u8; 4] = [144u8, 209u8, 221u8, 45u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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 GetPoolAssetType2 { - const NAME: &'static str = "get_pool_asset_type2"; - 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 GetPoolAssetType2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolFromLpToken1 { - pub token: Vec, - } - impl GetPoolFromLpToken1 { - const METHOD_ID: [u8; 4] = [189u8, 244u8, 117u8, 195u8]; - 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, 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 GetPoolFromLpToken1 { - const NAME: &'static str = "get_pool_from_lp_token1"; - 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 GetPoolFromLpToken1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolFromLpToken2 { - pub token: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetPoolFromLpToken2 { - const METHOD_ID: [u8; 4] = [54u8, 103u8, 139u8, 128u8]; - 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(), - handler_id: { - 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.handler_id.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::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 GetPoolFromLpToken2 { - const NAME: &'static str = "get_pool_from_lp_token2"; - 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 GetPoolFromLpToken2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolName1 { - pub pool: Vec, - } - impl GetPoolName1 { - const METHOD_ID: [u8; 4] = [92u8, 145u8, 23u8, 65u8]; - 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 { - pool: 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.pool))], - ); - 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 GetPoolName1 { - const NAME: &'static str = "get_pool_name1"; - 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 GetPoolName1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolName2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetPoolName2 { - const METHOD_ID: [u8; 4] = [146u8, 35u8, 79u8, 69u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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::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 GetPoolName2 { - const NAME: &'static str = "get_pool_name2"; - 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 GetPoolName2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolParams1 { - pub pool: Vec, - } - impl GetPoolParams1 { - const METHOD_ID: [u8; 4] = [104u8, 133u8, 50u8, 170u8]; - 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 { - pool: 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.pool))], - ); - 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; 20usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 20usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 20usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 20usize]> { - 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 GetPoolParams1 { - const NAME: &'static str = "get_pool_params1"; - 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; 20usize], - > for GetPoolParams1 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 20usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolParams2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetPoolParams2 { - const METHOD_ID: [u8; 4] = [122u8, 101u8, 210u8, 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::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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<[substreams::scalar::BigInt; 20usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 20usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 20usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 20usize]> { - 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 GetPoolParams2 { - const NAME: &'static str = "get_pool_params2"; - 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; 20usize], - > for GetPoolParams2 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 20usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetRegistry { - pub arg0: substreams::scalar::BigInt, - } - impl GetRegistry { - const METHOD_ID: [u8; 4] = [145u8, 61u8, 155u8, 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::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - arg0: { - 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.arg0.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::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 GetRegistry { - const NAME: &'static str = "get_registry"; - 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 GetRegistry { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetRegistryHandlersFromPool { - pub pool: Vec, - } - impl GetRegistryHandlersFromPool { - const METHOD_ID: [u8; 4] = [48u8, 141u8, 27u8, 109u8]; - 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 { - pool: 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.pool))], - ); - 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; 10usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 10usize]> { - 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 GetRegistryHandlersFromPool { - const NAME: &'static str = "get_registry_handlers_from_pool"; - 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; 10usize]> - for GetRegistryHandlersFromPool { - fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances1 { - pub pool: Vec, - } - impl GetUnderlyingBalances1 { - const METHOD_ID: [u8; 4] = [89u8, 244u8, 243u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetUnderlyingBalances1 { - const NAME: &'static str = "get_underlying_balances1"; - 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; 8usize]> - for GetUnderlyingBalances1 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetUnderlyingBalances2 { - const METHOD_ID: [u8; 4] = [135u8, 97u8, 18u8, 230u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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<[substreams::scalar::BigInt; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetUnderlyingBalances2 { - const NAME: &'static str = "get_underlying_balances2"; - 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; 8usize]> - for GetUnderlyingBalances2 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins1 { - pub pool: Vec, - } - impl GetUnderlyingCoins1 { - const METHOD_ID: [u8; 4] = [167u8, 117u8, 118u8, 239u8]; - 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 { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 8usize]> { - 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 GetUnderlyingCoins1 { - const NAME: &'static str = "get_underlying_coins1"; - 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; 8usize]> - for GetUnderlyingCoins1 { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetUnderlyingCoins2 { - const METHOD_ID: [u8; 4] = [47u8, 201u8, 11u8, 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::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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<[Vec; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 8usize]> { - 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 GetUnderlyingCoins2 { - const NAME: &'static str = "get_underlying_coins2"; - 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; 8usize]> - for GetUnderlyingCoins2 { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingDecimals1 { - pub pool: Vec, - } - impl GetUnderlyingDecimals1 { - const METHOD_ID: [u8; 4] = [76u8, 176u8, 136u8, 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 { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetUnderlyingDecimals1 { - const NAME: &'static str = "get_underlying_decimals1"; - 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; 8usize]> - for GetUnderlyingDecimals1 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingDecimals2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetUnderlyingDecimals2 { - const METHOD_ID: [u8; 4] = [98u8, 45u8, 100u8, 244u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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<[substreams::scalar::BigInt; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetUnderlyingDecimals2 { - const NAME: &'static str = "get_underlying_decimals2"; - 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; 8usize]> - for GetUnderlyingDecimals2 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetVirtualPriceFromLpToken1 { - pub token: Vec, - } - impl GetVirtualPriceFromLpToken1 { - const METHOD_ID: [u8; 4] = [197u8, 183u8, 7u8, 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::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 GetVirtualPriceFromLpToken1 { - const NAME: &'static str = "get_virtual_price_from_lp_token1"; - 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 GetVirtualPriceFromLpToken1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetVirtualPriceFromLpToken2 { - pub token: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl GetVirtualPriceFromLpToken2 { - const METHOD_ID: [u8; 4] = [68u8, 96u8, 246u8, 111u8]; - 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(), - handler_id: { - 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.handler_id.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 GetVirtualPriceFromLpToken2 { - const NAME: &'static str = "get_virtual_price_from_lp_token2"; - 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 GetVirtualPriceFromLpToken2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsMeta1 { - pub pool: Vec, - } - impl IsMeta1 { - const METHOD_ID: [u8; 4] = [228u8, 211u8, 50u8, 169u8]; - 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 { - pool: 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.pool))], - ); - 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 IsMeta1 { - const NAME: &'static str = "is_meta1"; - 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 IsMeta1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsMeta2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl IsMeta2 { - const METHOD_ID: [u8; 4] = [166u8, 68u8, 133u8, 161u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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 IsMeta2 { - const NAME: &'static str = "is_meta2"; - 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 IsMeta2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsRegistered1 { - pub pool: Vec, - } - impl IsRegistered1 { - const METHOD_ID: [u8; 4] = [97u8, 158u8, 168u8, 6u8]; - 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 { - pool: 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.pool))], - ); - 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 IsRegistered1 { - const NAME: &'static str = "is_registered1"; - 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 IsRegistered1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsRegistered2 { - pub pool: Vec, - pub handler_id: substreams::scalar::BigInt, - } - impl IsRegistered2 { - const METHOD_ID: [u8; 4] = [201u8, 196u8, 243u8, 236u8]; - 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 { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - handler_id: { - 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.pool)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.handler_id.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 IsRegistered2 { - const NAME: &'static str = "is_registered2"; - 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 IsRegistered2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Owner {} - impl Owner { - const METHOD_ID: [u8; 4] = [141u8, 165u8, 203u8, 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, 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 Owner { - const NAME: &'static str = "owner"; - 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 Owner { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCount {} - impl PoolCount { - const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { - const NAME: &'static str = "pool_count"; - 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 PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub index: substreams::scalar::BigInt, - } - impl PoolList { - const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; - 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 { - index: { - 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.index.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::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 PoolList { - const NAME: &'static str = "pool_list"; - 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 PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RegistryLength {} - impl RegistryLength { - const METHOD_ID: [u8; 4] = [8u8, 50u8, 151u8, 210u8]; - 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 RegistryLength { - const NAME: &'static str = "registry_length"; - 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 RegistryLength { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateRegistryHandler { - pub index: substreams::scalar::BigInt, - pub registry_handler: Vec, - } - impl UpdateRegistryHandler { - const METHOD_ID: [u8; 4] = [13u8, 189u8, 201u8, 255u8]; - 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - index: { - 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) - }, - registry_handler: 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::Uint( - ethabi::Uint::from_big_endian( - match self.index.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.registry_handler), - ), - ], - ); - 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 UpdateRegistryHandler { - const NAME: &'static str = "update_registry_handler"; - 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() + +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 AddRegistryHandler { + pub registry_handler: Vec, + } + impl AddRegistryHandler { + const METHOD_ID: [u8; 4] = [34u8, 245u8, 149u8, 200u8]; + 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 { + registry_handler: 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.registry_handler, + ))]); + 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, } } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct CommitNewAdmin { - pub deadline: substreams::scalar::BigInt, - pub admin: Vec, + impl substreams_ethereum::Function for AddRegistryHandler { + const NAME: &'static str = "add_registry_handler"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl CommitNewAdmin { - const TOPIC_ID: [u8; 32] = [ - 24u8, - 26u8, - 163u8, - 170u8, - 23u8, - 212u8, - 203u8, - 249u8, - 146u8, - 101u8, - 221u8, - 68u8, - 67u8, - 235u8, - 160u8, - 9u8, - 67u8, - 61u8, - 60u8, - 222u8, - 121u8, - 214u8, - 1u8, - 100u8, - 253u8, - 225u8, - 209u8, - 161u8, - 146u8, - 190u8, - 185u8, - 53u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 0usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; + 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 AddressProvider {} + impl AddressProvider { + const METHOD_ID: [u8; 4] = [206u8, 80u8, 194u8, 231u8]; + 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 decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Ok(Self { - deadline: { + } + 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 AddressProvider { + const NAME: &'static str = "address_provider"; + 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 AddressProvider { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub from: Vec, + pub to: Vec, + } + impl FindPoolForCoins1 { + const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 FindPoolForCoins1 { + const NAME: &'static str = "find_pool_for_coins1"; + 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 FindPoolForCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins2 { + pub from: Vec, + pub to: Vec, + pub i: substreams::scalar::BigInt, + } + impl FindPoolForCoins2 { + const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + i: { + 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.i.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::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 FindPoolForCoins2 { + const NAME: &'static str = "find_pool_for_coins2"; + 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 FindPoolForCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolsForCoins { + pub from: Vec, + pub to: Vec, + } + impl FindPoolsForCoins { + const METHOD_ID: [u8; 4] = [160u8, 100u8, 7u8, 43u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 FindPoolsForCoins { + const NAME: &'static str = "find_pools_for_coins"; + 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 FindPoolsForCoins { + fn output(data: &[u8]) -> Result>, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAdminBalances1 { + pub pool: Vec, + } + impl GetAdminBalances1 { + const METHOD_ID: [u8; 4] = [193u8, 30u8, 69u8, 184u8]; + 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 { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { 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 'deadline' from topic of type 'uint256': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) + inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - admin: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'admin' from topic of type 'address': {:?}", - e - ) - })? + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetAdminBalances1 { + const NAME: &'static str = "get_admin_balances1"; + 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; 8usize]> + for GetAdminBalances1 + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAdminBalances2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetAdminBalances2 { + const METHOD_ID: [u8; 4] = [192u8, 191u8, 76u8, 191u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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<[substreams::scalar::BigInt; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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, } } - impl substreams_ethereum::Event for CommitNewAdmin { - const NAME: &'static str = "CommitNewAdmin"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + pub fn call(&self, address: Vec) -> Option<[substreams::scalar::BigInt; 8usize]> { + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct NewAdmin { - pub admin: Vec, - } - impl NewAdmin { - const TOPIC_ID: [u8; 32] = [ - 113u8, - 97u8, - 64u8, - 113u8, - 184u8, - 141u8, - 238u8, - 94u8, - 11u8, - 42u8, - 229u8, - 120u8, - 169u8, - 221u8, - 123u8, - 46u8, - 187u8, - 233u8, - 174u8, - 131u8, - 43u8, - 164u8, - 25u8, - 220u8, - 2u8, - 66u8, - 205u8, - 6u8, - 90u8, - 41u8, - 11u8, - 108u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; + 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 } - 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 { - admin: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'admin' from topic of type 'address': {:?}", - e - ) - })? + } + } + impl substreams_ethereum::Function for GetAdminBalances2 { + const NAME: &'static str = "get_admin_balances2"; + 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; 8usize]> + for GetAdminBalances2 + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances1 { + pub pool: Vec, + } + impl GetBalances1 { + const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; + 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 { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetBalances1 { + const NAME: &'static str = "get_balances1"; + 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; 8usize]> for GetBalances1 { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetBalances2 { + const METHOD_ID: [u8; 4] = [170u8, 133u8, 22u8, 156u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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<[substreams::scalar::BigInt; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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, } } - impl substreams_ethereum::Event for NewAdmin { - const NAME: &'static str = "NewAdmin"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + pub fn call(&self, address: Vec) -> Option<[substreams::scalar::BigInt; 8usize]> { + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 + } } } - } \ No newline at end of file + } + impl substreams_ethereum::Function for GetBalances2 { + const NAME: &'static str = "get_balances2"; + 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; 8usize]> for GetBalances2 { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasePool1 { + pub pool: Vec, + } + impl GetBasePool1 { + const METHOD_ID: [u8; 4] = [111u8, 32u8, 214u8, 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], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: 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.pool))]); + 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 GetBasePool1 { + const NAME: &'static str = "get_base_pool1"; + 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 GetBasePool1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasePool2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetBasePool2 { + const METHOD_ID: [u8; 4] = [165u8, 78u8, 58u8, 222u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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::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 GetBasePool2 { + const NAME: &'static str = "get_base_pool2"; + 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 GetBasePool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBaseRegistry { + pub registry_handler: Vec, + } + impl GetBaseRegistry { + const METHOD_ID: [u8; 4] = [132u8, 225u8, 113u8, 13u8]; + 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 { + registry_handler: 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.registry_handler, + ))]); + 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 GetBaseRegistry { + const NAME: &'static str = "get_base_registry"; + 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 GetBaseRegistry { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices1 { + pub pool: Vec, + pub from: Vec, + pub to: Vec, + } + impl GetCoinIndices1 { + const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; + 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::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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, bool), String> + { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Bool, + ], + 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_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + { + 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) + }, + values + .pop() + .expect(INTERNAL_ERR) + .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<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> { + 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 GetCoinIndices1 { + const NAME: &'static str = "get_coin_indices1"; + 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, + bool, + )> for GetCoinIndices1 + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices2 { + pub pool: Vec, + pub from: Vec, + pub to: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetCoinIndices2 { + const METHOD_ID: [u8; 4] = [99u8, 251u8, 61u8, 219u8]; + 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::Address, + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Bool, + ], + 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_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + { + 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) + }, + values + .pop() + .expect(INTERNAL_ERR) + .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<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> { + 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 GetCoinIndices2 { + const NAME: &'static str = "get_coin_indices2"; + 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, + bool, + )> for GetCoinIndices2 + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins1 { + pub pool: Vec, + } + impl GetCoins1 { + const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; + 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 { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 8usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 8usize]> { + 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 GetCoins1 { + const NAME: &'static str = "get_coins1"; + 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; 8usize]> for GetCoins1 { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetCoins2 { + const METHOD_ID: [u8; 4] = [110u8, 190u8, 81u8, 252u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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<[Vec; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 8usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 8usize]> { + 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 GetCoins2 { + const NAME: &'static str = "get_coins2"; + 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; 8usize]> for GetCoins2 { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals1 { + pub pool: Vec, + } + impl GetDecimals1 { + const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; + 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 { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetDecimals1 { + const NAME: &'static str = "get_decimals1"; + 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; 8usize]> for GetDecimals1 { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetDecimals2 { + const METHOD_ID: [u8; 4] = [64u8, 63u8, 80u8, 47u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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<[substreams::scalar::BigInt; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetDecimals2 { + const NAME: &'static str = "get_decimals2"; + 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; 8usize]> for GetDecimals2 { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees1 { + pub pool: Vec, + } + impl GetFees1 { + const METHOD_ID: [u8; 4] = [124u8, 219u8, 114u8, 176u8]; + 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 { + pool: 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.pool))]); + 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; 10usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 10usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 10usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 10usize]> { + 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 GetFees1 { + const NAME: &'static str = "get_fees1"; + 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; 10usize]> for GetFees1 { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 10usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetFees2 { + const METHOD_ID: [u8; 4] = [14u8, 213u8, 164u8, 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::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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<[substreams::scalar::BigInt; 10usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 10usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 10usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 10usize]> { + 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 GetFees2 { + const NAME: &'static str = "get_fees2"; + 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; 10usize]> for GetFees2 { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 10usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauge1 { + pub pool: Vec, + } + impl GetGauge1 { + const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; + 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 { + pool: 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.pool))]); + 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 GetGauge1 { + const NAME: &'static str = "get_gauge1"; + 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 GetGauge1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauge2 { + pub pool: Vec, + pub gauge_idx: substreams::scalar::BigInt, + } + impl GetGauge2 { + const METHOD_ID: [u8; 4] = [228u8, 8u8, 18u8, 32u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge_idx: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.gauge_idx.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::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 GetGauge2 { + const NAME: &'static str = "get_gauge2"; + 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 GetGauge2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauge3 { + pub pool: Vec, + pub gauge_idx: substreams::scalar::BigInt, + pub handler_id: substreams::scalar::BigInt, + } + impl GetGauge3 { + const METHOD_ID: [u8; 4] = [119u8, 63u8, 183u8, 227u8]; + 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), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge_idx: { + 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) + }, + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.gauge_idx.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.handler_id.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::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 GetGauge3 { + const NAME: &'static str = "get_gauge3"; + 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 GetGauge3 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGaugeType1 { + pub pool: Vec, + } + impl GetGaugeType1 { + const METHOD_ID: [u8; 4] = [37u8, 250u8, 93u8, 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::Address], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: 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.pool))]); + 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::Int(128usize)], 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_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_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 GetGaugeType1 { + const NAME: &'static str = "get_gauge_type1"; + 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 GetGaugeType1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGaugeType2 { + pub pool: Vec, + pub gauge_idx: substreams::scalar::BigInt, + } + impl GetGaugeType2 { + const METHOD_ID: [u8; 4] = [124u8, 81u8, 219u8, 85u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge_idx: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.gauge_idx.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::Int(128usize)], 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_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_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 GetGaugeType2 { + const NAME: &'static str = "get_gauge_type2"; + 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 GetGaugeType2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGaugeType3 { + pub pool: Vec, + pub gauge_idx: substreams::scalar::BigInt, + pub handler_id: substreams::scalar::BigInt, + } + impl GetGaugeType3 { + const METHOD_ID: [u8; 4] = [248u8, 182u8, 97u8, 226u8]; + 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), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge_idx: { + 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) + }, + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.gauge_idx.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.handler_id.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::Int(128usize)], 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_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_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 GetGaugeType3 { + const NAME: &'static str = "get_gauge_type3"; + 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 GetGaugeType3 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLpToken1 { + pub pool: Vec, + } + impl GetLpToken1 { + const METHOD_ID: [u8; 4] = [55u8, 149u8, 16u8, 73u8]; + 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 { + pool: 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.pool))]); + 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 GetLpToken1 { + const NAME: &'static str = "get_lp_token1"; + 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 GetLpToken1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLpToken2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetLpToken2 { + const METHOD_ID: [u8; 4] = [8u8, 129u8, 113u8, 95u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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::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 GetLpToken2 { + const NAME: &'static str = "get_lp_token2"; + 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 GetLpToken2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNCoins1 { + pub pool: Vec, + } + impl GetNCoins1 { + const METHOD_ID: [u8; 4] = [148u8, 4u8, 148u8, 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 { + pool: 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.pool))]); + 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 GetNCoins1 { + const NAME: &'static str = "get_n_coins1"; + 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 GetNCoins1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNCoins2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetNCoins2 { + const METHOD_ID: [u8; 4] = [17u8, 216u8, 18u8, 121u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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 GetNCoins2 { + const NAME: &'static str = "get_n_coins2"; + 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 GetNCoins2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNUnderlyingCoins1 { + pub pool: Vec, + } + impl GetNUnderlyingCoins1 { + const METHOD_ID: [u8; 4] = [10u8, 112u8, 12u8, 8u8]; + 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 { + pool: 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.pool))]); + 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 GetNUnderlyingCoins1 { + const NAME: &'static str = "get_n_underlying_coins1"; + 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 GetNUnderlyingCoins1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNUnderlyingCoins2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetNUnderlyingCoins2 { + const METHOD_ID: [u8; 4] = [222u8, 205u8, 246u8, 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, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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 GetNUnderlyingCoins2 { + const NAME: &'static str = "get_n_underlying_coins2"; + 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 GetNUnderlyingCoins2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolAssetType1 { + pub pool: Vec, + } + impl GetPoolAssetType1 { + const METHOD_ID: [u8; 4] = [102u8, 211u8, 150u8, 108u8]; + 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 { + pool: 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.pool))]); + 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 GetPoolAssetType1 { + const NAME: &'static str = "get_pool_asset_type1"; + 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 GetPoolAssetType1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolAssetType2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetPoolAssetType2 { + const METHOD_ID: [u8; 4] = [144u8, 209u8, 221u8, 45u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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 GetPoolAssetType2 { + const NAME: &'static str = "get_pool_asset_type2"; + 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 GetPoolAssetType2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolFromLpToken1 { + pub token: Vec, + } + impl GetPoolFromLpToken1 { + const METHOD_ID: [u8; 4] = [189u8, 244u8, 117u8, 195u8]; + 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, 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 GetPoolFromLpToken1 { + const NAME: &'static str = "get_pool_from_lp_token1"; + 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 GetPoolFromLpToken1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolFromLpToken2 { + pub token: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetPoolFromLpToken2 { + const METHOD_ID: [u8; 4] = [54u8, 103u8, 139u8, 128u8]; + 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(), + handler_id: { + 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.handler_id.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::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 GetPoolFromLpToken2 { + const NAME: &'static str = "get_pool_from_lp_token2"; + 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 GetPoolFromLpToken2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolName1 { + pub pool: Vec, + } + impl GetPoolName1 { + const METHOD_ID: [u8; 4] = [92u8, 145u8, 23u8, 65u8]; + 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 { + pool: 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.pool))]); + 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 GetPoolName1 { + const NAME: &'static str = "get_pool_name1"; + 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 GetPoolName1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolName2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetPoolName2 { + const METHOD_ID: [u8; 4] = [146u8, 35u8, 79u8, 69u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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::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 GetPoolName2 { + const NAME: &'static str = "get_pool_name2"; + 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 GetPoolName2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolParams1 { + pub pool: Vec, + } + impl GetPoolParams1 { + const METHOD_ID: [u8; 4] = [104u8, 133u8, 50u8, 170u8]; + 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 { + pool: 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.pool))]); + 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; 20usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 20usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 20usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 20usize]> { + 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 GetPoolParams1 { + const NAME: &'static str = "get_pool_params1"; + 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; 20usize]> + for GetPoolParams1 + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 20usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolParams2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetPoolParams2 { + const METHOD_ID: [u8; 4] = [122u8, 101u8, 210u8, 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::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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<[substreams::scalar::BigInt; 20usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 20usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 20usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 20usize]> { + 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 GetPoolParams2 { + const NAME: &'static str = "get_pool_params2"; + 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; 20usize]> + for GetPoolParams2 + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 20usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRegistry { + pub arg0: substreams::scalar::BigInt, + } + impl GetRegistry { + const METHOD_ID: [u8; 4] = [145u8, 61u8, 155u8, 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::Uint(256usize)], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + arg0: { + 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.arg0.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::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 GetRegistry { + const NAME: &'static str = "get_registry"; + 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 GetRegistry { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRegistryHandlersFromPool { + pub pool: Vec, + } + impl GetRegistryHandlersFromPool { + const METHOD_ID: [u8; 4] = [48u8, 141u8, 27u8, 109u8]; + 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 { + pool: 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.pool))]); + 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; 10usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 10usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 10usize]> { + 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 GetRegistryHandlersFromPool { + const NAME: &'static str = "get_registry_handlers_from_pool"; + 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; 10usize]> for GetRegistryHandlersFromPool { + fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingBalances1 { + pub pool: Vec, + } + impl GetUnderlyingBalances1 { + const METHOD_ID: [u8; 4] = [89u8, 244u8, 243u8, 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], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetUnderlyingBalances1 { + const NAME: &'static str = "get_underlying_balances1"; + 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; 8usize]> + for GetUnderlyingBalances1 + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingBalances2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetUnderlyingBalances2 { + const METHOD_ID: [u8; 4] = [135u8, 97u8, 18u8, 230u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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<[substreams::scalar::BigInt; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetUnderlyingBalances2 { + const NAME: &'static str = "get_underlying_balances2"; + 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; 8usize]> + for GetUnderlyingBalances2 + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingCoins1 { + pub pool: Vec, + } + impl GetUnderlyingCoins1 { + const METHOD_ID: [u8; 4] = [167u8, 117u8, 118u8, 239u8]; + 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 { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 8usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 8usize]> { + 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 GetUnderlyingCoins1 { + const NAME: &'static str = "get_underlying_coins1"; + 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; 8usize]> for GetUnderlyingCoins1 { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingCoins2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetUnderlyingCoins2 { + const METHOD_ID: [u8; 4] = [47u8, 201u8, 11u8, 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::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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<[Vec; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 8usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 8usize]> { + 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 GetUnderlyingCoins2 { + const NAME: &'static str = "get_underlying_coins2"; + 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; 8usize]> for GetUnderlyingCoins2 { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingDecimals1 { + pub pool: Vec, + } + impl GetUnderlyingDecimals1 { + const METHOD_ID: [u8; 4] = [76u8, 176u8, 136u8, 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 { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetUnderlyingDecimals1 { + const NAME: &'static str = "get_underlying_decimals1"; + 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; 8usize]> + for GetUnderlyingDecimals1 + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingDecimals2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetUnderlyingDecimals2 { + const METHOD_ID: [u8; 4] = [98u8, 45u8, 100u8, 244u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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<[substreams::scalar::BigInt; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetUnderlyingDecimals2 { + const NAME: &'static str = "get_underlying_decimals2"; + 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; 8usize]> + for GetUnderlyingDecimals2 + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetVirtualPriceFromLpToken1 { + pub token: Vec, + } + impl GetVirtualPriceFromLpToken1 { + const METHOD_ID: [u8; 4] = [197u8, 183u8, 7u8, 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::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 GetVirtualPriceFromLpToken1 { + const NAME: &'static str = "get_virtual_price_from_lp_token1"; + 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 GetVirtualPriceFromLpToken1 + { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetVirtualPriceFromLpToken2 { + pub token: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl GetVirtualPriceFromLpToken2 { + const METHOD_ID: [u8; 4] = [68u8, 96u8, 246u8, 111u8]; + 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(), + handler_id: { + 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.handler_id.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 GetVirtualPriceFromLpToken2 { + const NAME: &'static str = "get_virtual_price_from_lp_token2"; + 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 GetVirtualPriceFromLpToken2 + { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsMeta1 { + pub pool: Vec, + } + impl IsMeta1 { + const METHOD_ID: [u8; 4] = [228u8, 211u8, 50u8, 169u8]; + 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 { + pool: 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.pool))]); + 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 IsMeta1 { + const NAME: &'static str = "is_meta1"; + 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 IsMeta1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsMeta2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl IsMeta2 { + const METHOD_ID: [u8; 4] = [166u8, 68u8, 133u8, 161u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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 IsMeta2 { + const NAME: &'static str = "is_meta2"; + 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 IsMeta2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsRegistered1 { + pub pool: Vec, + } + impl IsRegistered1 { + const METHOD_ID: [u8; 4] = [97u8, 158u8, 168u8, 6u8]; + 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 { + pool: 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.pool))]); + 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 IsRegistered1 { + const NAME: &'static str = "is_registered1"; + 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 IsRegistered1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsRegistered2 { + pub pool: Vec, + pub handler_id: substreams::scalar::BigInt, + } + impl IsRegistered2 { + const METHOD_ID: [u8; 4] = [201u8, 196u8, 243u8, 236u8]; + 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 { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + handler_id: { + 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.pool)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.handler_id.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 IsRegistered2 { + const NAME: &'static str = "is_registered2"; + 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 IsRegistered2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Owner {} + impl Owner { + const METHOD_ID: [u8; 4] = [141u8, 165u8, 203u8, 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, 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 Owner { + const NAME: &'static str = "owner"; + 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 Owner { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolCount {} + impl PoolCount { + const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { + const NAME: &'static str = "pool_count"; + 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 PoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolList { + pub index: substreams::scalar::BigInt, + } + impl PoolList { + const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; + 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 { + index: { + 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.index.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::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 PoolList { + const NAME: &'static str = "pool_list"; + 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 PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RegistryLength {} + impl RegistryLength { + const METHOD_ID: [u8; 4] = [8u8, 50u8, 151u8, 210u8]; + 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 RegistryLength { + const NAME: &'static str = "registry_length"; + 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 RegistryLength { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateRegistryHandler { + pub index: substreams::scalar::BigInt, + pub registry_handler: Vec, + } + impl UpdateRegistryHandler { + const METHOD_ID: [u8; 4] = [13u8, 189u8, 201u8, 255u8]; + 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + index: { + 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) + }, + registry_handler: 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::Uint(ethabi::Uint::from_big_endian( + match self.index.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.registry_handler)), + ]); + 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 UpdateRegistryHandler { + const NAME: &'static str = "update_registry_handler"; + 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() + } + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct CommitNewAdmin { + pub deadline: substreams::scalar::BigInt, + pub admin: Vec, + } + impl CommitNewAdmin { + const TOPIC_ID: [u8; 32] = [ + 24u8, 26u8, 163u8, 170u8, 23u8, 212u8, 203u8, 249u8, 146u8, 101u8, 221u8, 68u8, 67u8, + 235u8, 160u8, 9u8, 67u8, 61u8, 60u8, 222u8, 121u8, 214u8, 1u8, 100u8, 253u8, 225u8, + 209u8, 161u8, 146u8, 190u8, 185u8, 53u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + 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 { + deadline: { + 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 'deadline' 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) + }, + admin: ethabi::decode(&[ethabi::ParamType::Address], log.topics[2usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'admin' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for CommitNewAdmin { + const NAME: &'static str = "CommitNewAdmin"; + 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 NewAdmin { + pub admin: Vec, + } + impl NewAdmin { + const TOPIC_ID: [u8; 32] = [ + 113u8, 97u8, 64u8, 113u8, 184u8, 141u8, 238u8, 94u8, 11u8, 42u8, 229u8, 120u8, 169u8, + 221u8, 123u8, 46u8, 187u8, 233u8, 174u8, 131u8, 43u8, 164u8, 25u8, 220u8, 2u8, 66u8, + 205u8, 6u8, 90u8, 41u8, 11u8, 108u8, + ]; + 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 { + admin: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) + .map_err(|e| { + format!( + "unable to decode param 'admin' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for NewAdmin { + const NAME: &'static str = "NewAdmin"; + 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) + } + } +} diff --git a/substreams/ethereum-curve/src/abi/mod.rs b/substreams/ethereum-curve/src/abi/mod.rs index f0e96ac..1a77e48 100644 --- a/substreams/ethereum-curve/src/abi/mod.rs +++ b/substreams/ethereum-curve/src/abi/mod.rs @@ -1,9 +1,9 @@ #![allow(clippy::all)] pub mod crypto_pool_factory; -pub mod stableswap_factory; pub mod crypto_swap_ng_factory; -pub mod meta_registry; -pub mod tricrypto_factory; -pub mod twocrypto_factory; pub mod erc20; pub mod meta_pool_factory; +pub mod meta_registry; +pub mod stableswap_factory; +pub mod tricrypto_factory; +pub mod twocrypto_factory; diff --git a/substreams/ethereum-curve/src/abi/stableswap_factory.rs b/substreams/ethereum-curve/src/abi/stableswap_factory.rs index ab3d33c..f2eb9aa 100644 --- a/substreams/ethereum-curve/src/abi/stableswap_factory.rs +++ b/substreams/ethereum-curve/src/abi/stableswap_factory.rs @@ -1,6804 +1,5970 @@ - 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 AcceptTransferOwnership {} - impl AcceptTransferOwnership { - const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 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 AcceptTransferOwnership { - const NAME: &'static str = "accept_transfer_ownership"; - 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 AddBasePool { - pub base_pool: Vec, - pub fee_receiver: Vec, - pub asset_type: substreams::scalar::BigInt, - pub implementations: [Vec; 10usize], - } - impl AddBasePool { - const METHOD_ID: [u8; 4] = [47u8, 192u8, 86u8, 83u8]; - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - asset_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) - }, - implementations: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.fee_receiver), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.asset_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 v = self - .implementations - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(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 AddBasePool { - const NAME: &'static str = "add_base_pool"; - 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 AddExistingMetapools { - pub pools: [Vec; 10usize], - } - impl AddExistingMetapools { - const METHOD_ID: [u8; 4] = [219u8, 137u8, 250u8, 188u8]; - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pools: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(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 { - 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 AddExistingMetapools { - const NAME: &'static str = "add_existing_metapools"; - 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 AddExistingMetapools { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AddTokenToWhitelist { - pub coin: Vec, - pub add: bool, - } - impl AddTokenToWhitelist { - const METHOD_ID: [u8; 4] = [42u8, 145u8, 248u8, 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::Address, ethabi::ParamType::Bool], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - add: 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.coin)), - ethabi::Token::Bool(self.add.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 AddTokenToWhitelist { - const NAME: &'static str = "add_token_to_whitelist"; - 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 Admin {} - impl Admin { - const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; - 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 Admin { - const NAME: &'static str = "admin"; - 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 Admin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolAssets { - pub arg0: Vec, - } - impl BasePoolAssets { - const METHOD_ID: [u8; 4] = [16u8, 160u8, 2u8, 223u8]; - 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 { - arg0: 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.arg0))], - ); - 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 BasePoolAssets { - const NAME: &'static str = "base_pool_assets"; - 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 BasePoolAssets { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolCount {} - impl BasePoolCount { - const METHOD_ID: [u8; 4] = [222u8, 94u8, 74u8, 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 BasePoolCount { - const NAME: &'static str = "base_pool_count"; - 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 BasePoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolList { - pub arg0: substreams::scalar::BigInt, - } - impl BasePoolList { - const METHOD_ID: [u8; 4] = [34u8, 254u8, 86u8, 113u8]; - 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 { - arg0: { - 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.arg0.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::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 BasePoolList { - const NAME: &'static str = "base_pool_list"; - 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 BasePoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BatchSetPoolAssetType { - pub pools: [Vec; 32usize], - pub asset_types: [substreams::scalar::BigInt; 32usize], - } - impl BatchSetPoolAssetType { - const METHOD_ID: [u8; 4] = [117u8, 66u8, 240u8, 120u8]; - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 32usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 32usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pools: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - asset_types: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .asset_types - .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::FixedArray(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 BatchSetPoolAssetType { - const NAME: &'static str = "batch_set_pool_asset_type"; - 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 CommitTransferOwnership { - pub addr: Vec, - } - impl CommitTransferOwnership { - const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; - 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 { - addr: 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.addr))], - ); - 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 CommitTransferOwnership { - const NAME: &'static str = "commit_transfer_ownership"; - 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 ConvertMetapoolFees {} - impl ConvertMetapoolFees { - const METHOD_ID: [u8; 4] = [188u8, 201u8, 129u8, 210u8]; - 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 ConvertMetapoolFees { - const NAME: &'static str = "convert_metapool_fees"; - 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 ConvertMetapoolFees { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge { - pub pool: Vec, - } - impl DeployGauge { - const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; - 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 { - pool: 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.pool))], - ); - 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 DeployGauge { - const NAME: &'static str = "deploy_gauge"; - 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 DeployGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployMetapool1 { - pub base_pool: Vec, - pub name: String, - pub symbol: String, - pub coin: Vec, - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - } - impl DeployMetapool1 { - const METHOD_ID: [u8; 4] = [227u8, 57u8, 235u8, 79u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - 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 { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - a: { - 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: { - 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.base_pool), - ), - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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::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 DeployMetapool1 { - const NAME: &'static str = "deploy_metapool1"; - 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 DeployMetapool1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployMetapool2 { - pub base_pool: Vec, - pub name: String, - pub symbol: String, - pub coin: Vec, - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub implementation_idx: substreams::scalar::BigInt, - } - impl DeployMetapool2 { - const METHOD_ID: [u8; 4] = [222u8, 127u8, 227u8, 191u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - 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 { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - a: { - 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: { - 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) - }, - implementation_idx: { - 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.base_pool), - ), - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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.implementation_idx.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::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 DeployMetapool2 { - const NAME: &'static str = "deploy_metapool2"; - 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 DeployMetapool2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPlainPool1 { - pub name: String, - pub symbol: String, - pub coins: [Vec; 4usize], - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - } - impl DeployPlainPool1 { - const METHOD_ID: [u8; 4] = [205u8, 65u8, 155u8, 181u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 4usize, - ), - 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 { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - a: { - 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: { - 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::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .coins - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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::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 DeployPlainPool1 { - const NAME: &'static str = "deploy_plain_pool1"; - 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 DeployPlainPool1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPlainPool2 { - pub name: String, - pub symbol: String, - pub coins: [Vec; 4usize], - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub asset_type: substreams::scalar::BigInt, - } - impl DeployPlainPool2 { - const METHOD_ID: [u8; 4] = [92u8, 22u8, 72u8, 123u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 4usize, - ), - 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 { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - a: { - 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: { - 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) - }, - asset_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::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .coins - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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.asset_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, 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 DeployPlainPool2 { - const NAME: &'static str = "deploy_plain_pool2"; - 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 DeployPlainPool2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPlainPool3 { - pub name: String, - pub symbol: String, - pub coins: [Vec; 4usize], - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub asset_type: substreams::scalar::BigInt, - pub implementation_idx: substreams::scalar::BigInt, - } - impl DeployPlainPool3 { - const METHOD_ID: [u8; 4] = [82u8, 242u8, 219u8, 105u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 4usize, - ), - ethabi::ParamType::Uint(256usize), - 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 { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - a: { - 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: { - 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) - }, - asset_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) - }, - implementation_idx: { - 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::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .coins - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.a.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.fee.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.asset_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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.implementation_idx.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::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 DeployPlainPool3 { - const NAME: &'static str = "deploy_plain_pool3"; - 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 DeployPlainPool3 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub from: Vec, - pub to: Vec, - } - impl FindPoolForCoins1 { - const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 FindPoolForCoins1 { - const NAME: &'static str = "find_pool_for_coins1"; - 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 FindPoolForCoins1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins2 { - pub from: Vec, - pub to: Vec, - pub i: substreams::scalar::BigInt, - } - impl FindPoolForCoins2 { - const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { - 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.i.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::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 FindPoolForCoins2 { - const NAME: &'static str = "find_pool_for_coins2"; - 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 FindPoolForCoins2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdmin {} - impl FutureAdmin { - const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; - 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 FutureAdmin { - const NAME: &'static str = "future_admin"; - 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 FutureAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeImplementation {} - impl GaugeImplementation { - const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; - 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 GaugeImplementation { - const NAME: &'static str = "gauge_implementation"; - 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 GaugeImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetA { - pub pool: Vec, - } - impl GetA { - const METHOD_ID: [u8; 4] = [85u8, 179u8, 11u8, 25u8]; - 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 { - pool: 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.pool))], - ); - 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 GetA { - const NAME: &'static str = "get_A"; - 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 GetA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances { - pub pool: Vec, - } - impl GetAdminBalances { - const METHOD_ID: [u8; 4] = [193u8, 30u8, 69u8, 184u8]; - 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 { - pool: 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.pool))], - ); - 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; 4usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 4usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 4usize]> { - 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 GetAdminBalances { - const NAME: &'static str = "get_admin_balances"; - 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; 4usize]> - for GetAdminBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub pool: Vec, - } - impl GetBalances { - const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; - 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 { - pool: 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.pool))], - ); - 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; 4usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 4usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 4usize]> { - 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 GetBalances { - const NAME: &'static str = "get_balances"; - 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; 4usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBasePool { - pub pool: Vec, - } - impl GetBasePool { - const METHOD_ID: [u8; 4] = [111u8, 32u8, 214u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: 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.pool))], - ); - 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 GetBasePool { - const NAME: &'static str = "get_base_pool"; - 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 GetBasePool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub pool: Vec, - pub from: Vec, - pub to: Vec, - } - impl GetCoinIndices { - const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; - 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::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.pool)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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, bool), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Bool, - ], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_bytes_be(&v) - }, - { - 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) - }, - values.pop().expect(INTERNAL_ERR).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<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> { - 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 GetCoinIndices { - const NAME: &'static str = "get_coin_indices"; - 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, bool), - > for GetCoinIndices { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt, bool), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins { - pub pool: Vec, - } - impl GetCoins { - const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; - 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 { - pool: 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.pool))], - ); - 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; 4usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 4usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 4usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 4usize]> { - 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 GetCoins { - const NAME: &'static str = "get_coins"; - 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; 4usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 4usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub pool: Vec, - } - impl GetDecimals { - const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; - 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 { - pool: 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.pool))], - ); - 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; 4usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 4usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 4usize]> { - 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 GetDecimals { - const NAME: &'static str = "get_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<[substreams::scalar::BigInt; 4usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFeeReceiver { - pub pool: Vec, - } - impl GetFeeReceiver { - const METHOD_ID: [u8; 4] = [21u8, 74u8, 168u8, 245u8]; - 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 { - pool: 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.pool))], - ); - 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 GetFeeReceiver { - const NAME: &'static str = "get_fee_receiver"; - 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 GetFeeReceiver { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFees { - pub pool: Vec, - } - impl GetFees { - const METHOD_ID: [u8; 4] = [124u8, 219u8, 114u8, 176u8]; - 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 { - pool: 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.pool))], - ); - 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 GetFees { - const NAME: &'static str = "get_fees"; - 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 GetFees { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauge { - pub pool: Vec, - } - impl GetGauge { - const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; - 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 { - pool: 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.pool))], - ); - 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 GetGauge { - const NAME: &'static str = "get_gauge"; - 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 GetGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetImplementationAddress { - pub pool: Vec, - } - impl GetImplementationAddress { - const METHOD_ID: [u8; 4] = [81u8, 13u8, 152u8, 164u8]; - 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 { - pool: 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.pool))], - ); - 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 GetImplementationAddress { - const NAME: &'static str = "get_implementation_address"; - 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 GetImplementationAddress { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetMetaNCoins { - pub pool: Vec, - } - impl GetMetaNCoins { - const METHOD_ID: [u8; 4] = [235u8, 115u8, 243u8, 125u8]; - 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 { - pool: 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.pool))], - ); - 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 GetMetaNCoins { - const NAME: &'static str = "get_meta_n_coins"; - 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 GetMetaNCoins { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetMetapoolRates { - pub pool: Vec, - } - impl GetMetapoolRates { - const METHOD_ID: [u8; 4] = [6u8, 216u8, 241u8, 96u8]; - 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 { - pool: 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.pool))], - ); - 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; 2usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [iter.next().expect(INTERNAL_ERR), iter.next().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<[substreams::scalar::BigInt; 2usize]> { - 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 GetMetapoolRates { - const NAME: &'static str = "get_metapool_rates"; - 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; 2usize]> - for GetMetapoolRates { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins { - pub pool: Vec, - } - impl GetNCoins { - const METHOD_ID: [u8; 4] = [148u8, 4u8, 148u8, 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 { - pool: 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.pool))], - ); - 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 GetNCoins { - const NAME: &'static str = "get_n_coins"; - 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 GetNCoins { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolAssetType { - pub pool: Vec, - } - impl GetPoolAssetType { - const METHOD_ID: [u8; 4] = [102u8, 211u8, 150u8, 108u8]; - 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 { - pool: 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.pool))], - ); - 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 GetPoolAssetType { - const NAME: &'static str = "get_pool_asset_type"; - 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 GetPoolAssetType { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances { - pub pool: Vec, - } - impl GetUnderlyingBalances { - const METHOD_ID: [u8; 4] = [89u8, 244u8, 243u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetUnderlyingBalances { - const NAME: &'static str = "get_underlying_balances"; - 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; 8usize]> - for GetUnderlyingBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins { - pub pool: Vec, - } - impl GetUnderlyingCoins { - const METHOD_ID: [u8; 4] = [167u8, 117u8, 118u8, 239u8]; - 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 { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 8usize]> { - 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 GetUnderlyingCoins { - const NAME: &'static str = "get_underlying_coins"; - 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; 8usize]> - for GetUnderlyingCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingDecimals { - pub pool: Vec, - } - impl GetUnderlyingDecimals { - const METHOD_ID: [u8; 4] = [76u8, 176u8, 136u8, 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 { - pool: 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.pool))], - ); - 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; 8usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 8usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 8usize]> { - 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 GetUnderlyingDecimals { - const NAME: &'static str = "get_underlying_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<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsMeta { - pub pool: Vec, - } - impl IsMeta { - const METHOD_ID: [u8; 4] = [228u8, 211u8, 50u8, 169u8]; - 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 { - pool: 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.pool))], - ); - 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 IsMeta { - const NAME: &'static str = "is_meta"; - 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 IsMeta { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Manager {} - impl Manager { - const METHOD_ID: [u8; 4] = [72u8, 28u8, 106u8, 117u8]; - 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 Manager { - const NAME: &'static str = "manager"; - 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 Manager { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct MetapoolImplementations { - pub base_pool: Vec, - } - impl MetapoolImplementations { - const METHOD_ID: [u8; 4] = [151u8, 15u8, 163u8, 243u8]; - 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 { - base_pool: 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.base_pool), - ), - ], - ); - 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; 10usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 10usize]> { - 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 MetapoolImplementations { - const NAME: &'static str = "metapool_implementations"; - 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; 10usize]> - for MetapoolImplementations { - fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PlainImplementations { - pub arg0: substreams::scalar::BigInt, - pub arg1: substreams::scalar::BigInt, - } - impl PlainImplementations { - const METHOD_ID: [u8; 4] = [49u8, 164u8, 248u8, 101u8]; - 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 { - arg0: { - 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) - }, - arg1: { - 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.arg0.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.arg1.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::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 PlainImplementations { - const NAME: &'static str = "plain_implementations"; - 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 PlainImplementations { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PlainWhitelist { - pub arg0: Vec, - } - impl PlainWhitelist { - const METHOD_ID: [u8; 4] = [222u8, 122u8, 248u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - arg0: 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.arg0))], - ); - 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 PlainWhitelist { - const NAME: &'static str = "plain_whitelist"; - 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 PlainWhitelist { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCount {} - impl PoolCount { - const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { - const NAME: &'static str = "pool_count"; - 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 PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub arg0: substreams::scalar::BigInt, - } - impl PoolList { - const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; - 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 { - arg0: { - 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.arg0.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::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 PoolList { - const NAME: &'static str = "pool_list"; - 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 PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetFeeReceiver { - pub base_pool: Vec, - pub fee_receiver: Vec, - } - impl SetFeeReceiver { - const METHOD_ID: [u8; 4] = [54u8, 210u8, 183u8, 122u8]; - 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 { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - fee_receiver: 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.base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.fee_receiver), - ), - ], - ); - 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 SetFeeReceiver { - const NAME: &'static str = "set_fee_receiver"; - 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 SetGaugeImplementation { - pub gauge_implementation: Vec, - } - impl SetGaugeImplementation { - const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; - 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 { - gauge_implementation: 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.gauge_implementation), - ), - ], - ); - 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 SetGaugeImplementation { - const NAME: &'static str = "set_gauge_implementation"; - 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 SetManager { - pub manager: Vec, - } - impl SetManager { - const METHOD_ID: [u8; 4] = [154u8, 236u8, 232u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - manager: 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.manager))], - ); - 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 SetManager { - const NAME: &'static str = "set_manager"; - 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 SetMetapoolImplementations { - pub base_pool: Vec, - pub implementations: [Vec; 10usize], - } - impl SetMetapoolImplementations { - const METHOD_ID: [u8; 4] = [203u8, 149u8, 107u8, 70u8]; - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - implementations: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.base_pool), - ), - { - let v = self - .implementations - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(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 SetMetapoolImplementations { - const NAME: &'static str = "set_metapool_implementations"; - 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 SetPlainImplementations { - pub n_coins: substreams::scalar::BigInt, - pub implementations: [Vec; 10usize], - } - impl SetPlainImplementations { - const METHOD_ID: [u8; 4] = [157u8, 219u8, 244u8, 185u8]; - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - n_coins: { - 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) - }, - implementations: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.n_coins.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 - .implementations - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(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 SetPlainImplementations { - const NAME: &'static str = "set_plain_implementations"; - 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() + +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 AcceptTransferOwnership {} + impl AcceptTransferOwnership { + const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolAdded { - pub base_pool: Vec, + impl substreams_ethereum::Function for AcceptTransferOwnership { + const NAME: &'static str = "accept_transfer_ownership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl BasePoolAdded { - const TOPIC_ID: [u8; 32] = [ - 204u8, - 106u8, - 253u8, - 254u8, - 199u8, - 157u8, - 166u8, - 190u8, - 8u8, - 20u8, - 46u8, - 206u8, - 226u8, - 92u8, - 241u8, - 75u8, - 102u8, - 89u8, - 97u8, - 226u8, - 93u8, - 48u8, - 216u8, - 235u8, - 164u8, - 89u8, - 89u8, - 190u8, - 149u8, - 71u8, - 99u8, - 95u8, - ]; - 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; + 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 AddBasePool { + pub base_pool: Vec, + pub fee_receiver: Vec, + pub asset_type: substreams::scalar::BigInt, + pub implementations: [Vec; 10usize], + } + impl AddBasePool { + const METHOD_ID: [u8; 4] = [47u8, 192u8, 86u8, 83u8]; + 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()); } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - base_pool: values + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 10usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + asset_type: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for BasePoolAdded { - const NAME: &'static str = "BasePoolAdded"; - 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 LiquidityGaugeDeployed { - pub pool: Vec, - pub gauge: Vec, - } - impl LiquidityGaugeDeployed { - const TOPIC_ID: [u8; 32] = [ - 101u8, - 107u8, - 179u8, - 76u8, - 32u8, - 73u8, - 25u8, - 112u8, - 168u8, - 193u8, - 99u8, - 243u8, - 189u8, - 98u8, - 234u8, - 216u8, - 32u8, - 34u8, - 179u8, - 121u8, - 195u8, - 146u8, - 73u8, - 96u8, - 236u8, - 96u8, - 246u8, - 219u8, - 252u8, - 90u8, - 171u8, - 59u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + implementations: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge: values + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.base_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.fee_receiver)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.asset_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 v = self + .implementations + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(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 AddBasePool { + const NAME: &'static str = "add_base_pool"; + 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 AddExistingMetapools { + pub pools: [Vec; 10usize], + } + impl AddExistingMetapools { + const METHOD_ID: [u8; 4] = [219u8, 137u8, 250u8, 188u8]; + 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::FixedArray(Box::new(ethabi::ParamType::Address), 10usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pools: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[{ + let v = self + .pools + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(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 { + 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, } } - impl substreams_ethereum::Event for LiquidityGaugeDeployed { - const NAME: &'static str = "LiquidityGaugeDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct MetaPoolDeployed { - pub coin: Vec, - pub base_pool: Vec, - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub deployer: Vec, - } - impl MetaPoolDeployed { - const TOPIC_ID: [u8; 32] = [ - 1u8, - 243u8, - 28u8, - 210u8, - 171u8, - 222u8, - 180u8, - 229u8, - 225u8, - 11u8, - 165u8, - 0u8, - 242u8, - 219u8, - 15u8, - 147u8, - 125u8, - 158u8, - 140u8, - 115u8, - 90u8, - 176u8, - 70u8, - 129u8, - 146u8, - 84u8, - 65u8, - 180u8, - 234u8, - 55u8, - 237u8, - 165u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 160usize { - 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::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - coin: values + } + } + impl substreams_ethereum::Function for AddExistingMetapools { + const NAME: &'static str = "add_existing_metapools"; + 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 AddExistingMetapools { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddTokenToWhitelist { + pub coin: Vec, + pub add: bool, + } + impl AddTokenToWhitelist { + const METHOD_ID: [u8; 4] = [42u8, 145u8, 248u8, 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::Address, ethabi::ParamType::Bool], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + add: 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.coin)), + ethabi::Token::Bool(self.add.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 AddTokenToWhitelist { + const NAME: &'static str = "add_token_to_whitelist"; + 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 Admin {} + impl Admin { + const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; + 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 Admin { + const NAME: &'static str = "admin"; + 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 Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolAssets { + pub arg0: Vec, + } + impl BasePoolAssets { + const METHOD_ID: [u8; 4] = [16u8, 160u8, 2u8, 223u8]; + 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 { + arg0: 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.arg0))]); + 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 BasePoolAssets { + const NAME: &'static str = "base_pool_assets"; + 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 BasePoolAssets { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolCount {} + impl BasePoolCount { + const METHOD_ID: [u8; 4] = [222u8, 94u8, 74u8, 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 BasePoolCount { + const NAME: &'static str = "base_pool_count"; + 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 BasePoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolList { + pub arg0: substreams::scalar::BigInt, + } + impl BasePoolList { + const METHOD_ID: [u8; 4] = [34u8, 254u8, 86u8, 113u8]; + 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 { + arg0: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - base_pool: values + .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.arg0.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::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 BasePoolList { + const NAME: &'static str = "base_pool_list"; + 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 BasePoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BatchSetPoolAssetType { + pub pools: [Vec; 32usize], + pub asset_types: [substreams::scalar::BigInt; 32usize], + } + impl BatchSetPoolAssetType { + const METHOD_ID: [u8; 4] = [117u8, 66u8, 240u8, 120u8]; + 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::FixedArray(Box::new(ethabi::ParamType::Address), 32usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 32usize, + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pools: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - a: { + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + asset_types: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + { + let v = self + .pools + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + { + let v = self + .asset_types + .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::FixedArray(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 BatchSetPoolAssetType { + const NAME: &'static str = "batch_set_pool_asset_type"; + 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 CommitTransferOwnership { + pub addr: Vec, + } + impl CommitTransferOwnership { + const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; + 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 { + addr: 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.addr))]); + 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 CommitTransferOwnership { + const NAME: &'static str = "commit_transfer_ownership"; + 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 ConvertMetapoolFees {} + impl ConvertMetapoolFees { + const METHOD_ID: [u8; 4] = [188u8, 201u8, 129u8, 210u8]; + 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 ConvertMetapoolFees { + const NAME: &'static str = "convert_metapool_fees"; + 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 ConvertMetapoolFees { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployGauge { + pub pool: Vec, + } + impl DeployGauge { + const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; + 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 { + pool: 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.pool))]); + 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 DeployGauge { + const NAME: &'static str = "deploy_gauge"; + 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 DeployGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool1 { + pub base_pool: Vec, + pub name: String, + pub symbol: String, + pub coin: Vec, + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + } + impl DeployMetapool1 { + const METHOD_ID: [u8; 4] = [227u8, 57u8, 235u8, 79u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + 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 { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + a: { + 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: { + 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.base_pool)), + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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::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 DeployMetapool1 { + const NAME: &'static str = "deploy_metapool1"; + 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 DeployMetapool1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool2 { + pub base_pool: Vec, + pub name: String, + pub symbol: String, + pub coin: Vec, + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub implementation_idx: substreams::scalar::BigInt, + } + impl DeployMetapool2 { + const METHOD_ID: [u8; 4] = [222u8, 127u8, 227u8, 191u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + 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 { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + a: { + 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: { + 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) + }, + implementation_idx: { + 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.base_pool)), + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.coin)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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 + .implementation_idx + .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::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 DeployMetapool2 { + const NAME: &'static str = "deploy_metapool2"; + 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 DeployMetapool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool1 { + pub name: String, + pub symbol: String, + pub coins: [Vec; 4usize], + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + } + impl DeployPlainPool1 { + const METHOD_ID: [u8; 4] = [205u8, 65u8, 155u8, 181u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize), + 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 { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + a: { + 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: { + 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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .coins + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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::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 DeployPlainPool1 { + const NAME: &'static str = "deploy_plain_pool1"; + 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 DeployPlainPool1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool2 { + pub name: String, + pub symbol: String, + pub coins: [Vec; 4usize], + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub asset_type: substreams::scalar::BigInt, + } + impl DeployPlainPool2 { + const METHOD_ID: [u8; 4] = [92u8, 22u8, 72u8, 123u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize), + 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 { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + a: { + 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: { + 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) + }, + asset_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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .coins + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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.asset_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, 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 DeployPlainPool2 { + const NAME: &'static str = "deploy_plain_pool2"; + 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 DeployPlainPool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool3 { + pub name: String, + pub symbol: String, + pub coins: [Vec; 4usize], + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub asset_type: substreams::scalar::BigInt, + pub implementation_idx: substreams::scalar::BigInt, + } + impl DeployPlainPool3 { + const METHOD_ID: [u8; 4] = [82u8, 242u8, 219u8, 105u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize), + ethabi::ParamType::Uint(256usize), + 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 { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + a: { + 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: { + 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) + }, + asset_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) + }, + implementation_idx: { + 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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .coins + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.a.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.fee.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.asset_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(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .implementation_idx + .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::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 DeployPlainPool3 { + const NAME: &'static str = "deploy_plain_pool3"; + 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 DeployPlainPool3 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub from: Vec, + pub to: Vec, + } + impl FindPoolForCoins1 { + const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 FindPoolForCoins1 { + const NAME: &'static str = "find_pool_for_coins1"; + 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 FindPoolForCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins2 { + pub from: Vec, + pub to: Vec, + pub i: substreams::scalar::BigInt, + } + impl FindPoolForCoins2 { + const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + i: { + 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.i.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::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 FindPoolForCoins2 { + const NAME: &'static str = "find_pool_for_coins2"; + 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 FindPoolForCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAdmin {} + impl FutureAdmin { + const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; + 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 FutureAdmin { + const NAME: &'static str = "future_admin"; + 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 FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeImplementation {} + impl GaugeImplementation { + const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; + 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 GaugeImplementation { + const NAME: &'static str = "gauge_implementation"; + 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 GaugeImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetA { + pub pool: Vec, + } + impl GetA { + const METHOD_ID: [u8; 4] = [85u8, 179u8, 11u8, 25u8]; + 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 { + pool: 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.pool))]); + 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 GetA { + const NAME: &'static str = "get_A"; + 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 GetA { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAdminBalances { + pub pool: Vec, + } + impl GetAdminBalances { + const METHOD_ID: [u8; 4] = [193u8, 30u8, 69u8, 184u8]; + 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 { + pool: 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.pool))]); + 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; 4usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 4usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) + inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - fee: { - 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) - }, - deployer: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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, } } - impl substreams_ethereum::Event for MetaPoolDeployed { - const NAME: &'static str = "MetaPoolDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + pub fn call(&self, address: Vec) -> Option<[substreams::scalar::BigInt; 4usize]> { + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PlainPoolDeployed { - pub coins: [Vec; 4usize], - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub deployer: Vec, - pub pool: Vec, - } - impl PlainPoolDeployed { - const TOPIC_ID: [u8; 32] = [ - 184u8, - 246u8, - 151u8, - 45u8, - 110u8, - 86u8, - 210u8, - 28u8, - 71u8, - 98u8, - 30u8, - 253u8, - 127u8, - 2u8, - 254u8, - 104u8, - 240u8, - 122u8, - 23u8, - 201u8, - 153u8, - 196u8, - 34u8, - 69u8, - 179u8, - 171u8, - 211u8, - 0u8, - 243u8, - 77u8, - 97u8, - 235u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 256usize { - return false; + } + } + } + impl substreams_ethereum::Function for GetAdminBalances { + const NAME: &'static str = "get_admin_balances"; + 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; 4usize]> + for GetAdminBalances + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub pool: Vec, + } + impl GetBalances { + const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; + 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 { + pool: 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.pool))]); + 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; 4usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 4usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 4usize]> { + 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 } - 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 4usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - coins: { - let mut iter = values - .pop() + } + } + impl substreams_ethereum::Function for GetBalances { + const NAME: &'static str = "get_balances"; + 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; 4usize]> for GetBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasePool { + pub pool: Vec, + } + impl GetBasePool { + const METHOD_ID: [u8; 4] = [111u8, 32u8, 214u8, 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], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: 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.pool))]); + 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 GetBasePool { + const NAME: &'static str = "get_base_pool"; + 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 GetBasePool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub pool: Vec, + pub from: Vec, + pub to: Vec, + } + impl GetCoinIndices { + const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; + 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::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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, bool), String> + { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Bool, + ], + 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_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + { + 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) + }, + values + .pop() + .expect(INTERNAL_ERR) + .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<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool)> { + 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 GetCoinIndices { + const NAME: &'static str = "get_coin_indices"; + 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, + bool, + )> for GetCoinIndices + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt, bool), String> + { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins { + pub pool: Vec, + } + impl GetCoins { + const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; + 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 { + pool: 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.pool))]); + 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; 4usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 4usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 4usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - a: { + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 4usize]> { + 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 GetCoins { + const NAME: &'static str = "get_coins"; + 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; 4usize]> for GetCoins { + fn output(data: &[u8]) -> Result<[Vec; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub pool: Vec, + } + impl GetDecimals { + const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; + 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 { + pool: 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.pool))]); + 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; 4usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 4usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) + inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - fee: { + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 4usize]> { + 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 GetDecimals { + const NAME: &'static str = "get_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<[substreams::scalar::BigInt; 4usize]> for GetDecimals { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFeeReceiver { + pub pool: Vec, + } + impl GetFeeReceiver { + const METHOD_ID: [u8; 4] = [21u8, 74u8, 168u8, 245u8]; + 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 { + pool: 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.pool))]); + 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 GetFeeReceiver { + const NAME: &'static str = "get_fee_receiver"; + 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 GetFeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees { + pub pool: Vec, + } + impl GetFees { + const METHOD_ID: [u8; 4] = [124u8, 219u8, 114u8, 176u8]; + 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 { + pool: 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.pool))]); + 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 GetFees { + const NAME: &'static str = "get_fees"; + 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 GetFees + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauge { + pub pool: Vec, + } + impl GetGauge { + const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; + 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 { + pool: 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.pool))]); + 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 GetGauge { + const NAME: &'static str = "get_gauge"; + 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 GetGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetImplementationAddress { + pub pool: Vec, + } + impl GetImplementationAddress { + const METHOD_ID: [u8; 4] = [81u8, 13u8, 152u8, 164u8]; + 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 { + pool: 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.pool))]); + 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 GetImplementationAddress { + const NAME: &'static str = "get_implementation_address"; + 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 GetImplementationAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMetaNCoins { + pub pool: Vec, + } + impl GetMetaNCoins { + const METHOD_ID: [u8; 4] = [235u8, 115u8, 243u8, 125u8]; + 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 { + pool: 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.pool))]); + 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 GetMetaNCoins { + const NAME: &'static str = "get_meta_n_coins"; + 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 GetMetaNCoins + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMetapoolRates { + pub pool: Vec, + } + impl GetMetapoolRates { + const METHOD_ID: [u8; 4] = [6u8, 216u8, 241u8, 96u8]; + 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 { + pool: 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.pool))]); + 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; 2usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) + inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - deployer: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + }); + [iter.next().expect(INTERNAL_ERR), iter.next().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, } } - impl substreams_ethereum::Event for PlainPoolDeployed { - const NAME: &'static str = "PlainPoolDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + pub fn call(&self, address: Vec) -> Option<[substreams::scalar::BigInt; 2usize]> { + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 + } } } - } \ No newline at end of file + } + impl substreams_ethereum::Function for GetMetapoolRates { + const NAME: &'static str = "get_metapool_rates"; + 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; 2usize]> + for GetMetapoolRates + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNCoins { + pub pool: Vec, + } + impl GetNCoins { + const METHOD_ID: [u8; 4] = [148u8, 4u8, 148u8, 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 { + pool: 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.pool))]); + 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 GetNCoins { + const NAME: &'static str = "get_n_coins"; + 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 GetNCoins { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolAssetType { + pub pool: Vec, + } + impl GetPoolAssetType { + const METHOD_ID: [u8; 4] = [102u8, 211u8, 150u8, 108u8]; + 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 { + pool: 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.pool))]); + 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 GetPoolAssetType { + const NAME: &'static str = "get_pool_asset_type"; + 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 GetPoolAssetType { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingBalances { + pub pool: Vec, + } + impl GetUnderlyingBalances { + const METHOD_ID: [u8; 4] = [89u8, 244u8, 243u8, 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], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetUnderlyingBalances { + const NAME: &'static str = "get_underlying_balances"; + 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; 8usize]> + for GetUnderlyingBalances + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingCoins { + pub pool: Vec, + } + impl GetUnderlyingCoins { + const METHOD_ID: [u8; 4] = [167u8, 117u8, 118u8, 239u8]; + 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 { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 8usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 8usize]> { + 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 GetUnderlyingCoins { + const NAME: &'static str = "get_underlying_coins"; + 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; 8usize]> for GetUnderlyingCoins { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingDecimals { + pub pool: Vec, + } + impl GetUnderlyingDecimals { + const METHOD_ID: [u8; 4] = [76u8, 176u8, 136u8, 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 { + pool: 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.pool))]); + 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; 8usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 8usize]> { + 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 GetUnderlyingDecimals { + const NAME: &'static str = "get_underlying_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<[substreams::scalar::BigInt; 8usize]> + for GetUnderlyingDecimals + { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsMeta { + pub pool: Vec, + } + impl IsMeta { + const METHOD_ID: [u8; 4] = [228u8, 211u8, 50u8, 169u8]; + 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 { + pool: 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.pool))]); + 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 IsMeta { + const NAME: &'static str = "is_meta"; + 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 IsMeta { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Manager {} + impl Manager { + const METHOD_ID: [u8; 4] = [72u8, 28u8, 106u8, 117u8]; + 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 Manager { + const NAME: &'static str = "manager"; + 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 Manager { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MetapoolImplementations { + pub base_pool: Vec, + } + impl MetapoolImplementations { + const METHOD_ID: [u8; 4] = [151u8, 15u8, 163u8, 243u8]; + 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 { + base_pool: 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.base_pool, + ))]); + 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; 10usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 10usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 10usize]> { + 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 MetapoolImplementations { + const NAME: &'static str = "metapool_implementations"; + 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; 10usize]> for MetapoolImplementations { + fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PlainImplementations { + pub arg0: substreams::scalar::BigInt, + pub arg1: substreams::scalar::BigInt, + } + impl PlainImplementations { + const METHOD_ID: [u8; 4] = [49u8, 164u8, 248u8, 101u8]; + 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 { + arg0: { + 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) + }, + arg1: { + 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.arg0.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.arg1.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::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 PlainImplementations { + const NAME: &'static str = "plain_implementations"; + 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 PlainImplementations { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PlainWhitelist { + pub arg0: Vec, + } + impl PlainWhitelist { + const METHOD_ID: [u8; 4] = [222u8, 122u8, 248u8, 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::Address], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + arg0: 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.arg0))]); + 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 PlainWhitelist { + const NAME: &'static str = "plain_whitelist"; + 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 PlainWhitelist { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolCount {} + impl PoolCount { + const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { + const NAME: &'static str = "pool_count"; + 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 PoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolList { + pub arg0: substreams::scalar::BigInt, + } + impl PoolList { + const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; + 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 { + arg0: { + 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.arg0.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::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 PoolList { + const NAME: &'static str = "pool_list"; + 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 PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub base_pool: Vec, + pub fee_receiver: Vec, + } + impl SetFeeReceiver { + const METHOD_ID: [u8; 4] = [54u8, 210u8, 183u8, 122u8]; + 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 { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + fee_receiver: 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.base_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.fee_receiver)), + ]); + 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 SetFeeReceiver { + const NAME: &'static str = "set_fee_receiver"; + 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 SetGaugeImplementation { + pub gauge_implementation: Vec, + } + impl SetGaugeImplementation { + const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; + 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 { + gauge_implementation: 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.gauge_implementation, + ))]); + 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 SetGaugeImplementation { + const NAME: &'static str = "set_gauge_implementation"; + 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 SetManager { + pub manager: Vec, + } + impl SetManager { + const METHOD_ID: [u8; 4] = [154u8, 236u8, 232u8, 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], maybe_data.unwrap()) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + manager: 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.manager, + ))]); + 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 SetManager { + const NAME: &'static str = "set_manager"; + 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 SetMetapoolImplementations { + pub base_pool: Vec, + pub implementations: [Vec; 10usize], + } + impl SetMetapoolImplementations { + const METHOD_ID: [u8; 4] = [203u8, 149u8, 107u8, 70u8]; + 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::FixedArray(Box::new(ethabi::ParamType::Address), 10usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + implementations: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.base_pool)), + { + let v = self + .implementations + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(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 SetMetapoolImplementations { + const NAME: &'static str = "set_metapool_implementations"; + 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 SetPlainImplementations { + pub n_coins: substreams::scalar::BigInt, + pub implementations: [Vec; 10usize], + } + impl SetPlainImplementations { + const METHOD_ID: [u8; 4] = [157u8, 219u8, 244u8, 185u8]; + 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::FixedArray(Box::new(ethabi::ParamType::Address), 10usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + n_coins: { + 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) + }, + implementations: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.n_coins.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 + .implementations + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(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 SetPlainImplementations { + const NAME: &'static str = "set_plain_implementations"; + 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() + } + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct BasePoolAdded { + pub base_pool: Vec, + } + impl BasePoolAdded { + const TOPIC_ID: [u8; 32] = [ + 204u8, 106u8, 253u8, 254u8, 199u8, 157u8, 166u8, 190u8, 8u8, 20u8, 46u8, 206u8, 226u8, + 92u8, 241u8, 75u8, 102u8, 89u8, 97u8, 226u8, 93u8, 48u8, 216u8, 235u8, 164u8, 89u8, + 89u8, 190u8, 149u8, 71u8, 99u8, 95u8, + ]; + 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::Address], log.data.as_ref()) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for BasePoolAdded { + const NAME: &'static str = "BasePoolAdded"; + 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 LiquidityGaugeDeployed { + pub pool: Vec, + pub gauge: Vec, + } + impl LiquidityGaugeDeployed { + const TOPIC_ID: [u8; 32] = [ + 101u8, 107u8, 179u8, 76u8, 32u8, 73u8, 25u8, 112u8, 168u8, 193u8, 99u8, 243u8, 189u8, + 98u8, 234u8, 216u8, 32u8, 34u8, 179u8, 121u8, 195u8, 146u8, 73u8, 96u8, 236u8, 96u8, + 246u8, 219u8, 252u8, 90u8, 171u8, 59u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for LiquidityGaugeDeployed { + const NAME: &'static str = "LiquidityGaugeDeployed"; + 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 MetaPoolDeployed { + pub coin: Vec, + pub base_pool: Vec, + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub deployer: Vec, + } + impl MetaPoolDeployed { + const TOPIC_ID: [u8; 32] = [ + 1u8, 243u8, 28u8, 210u8, 171u8, 222u8, 180u8, 229u8, 225u8, 11u8, 165u8, 0u8, 242u8, + 219u8, 15u8, 147u8, 125u8, 158u8, 140u8, 115u8, 90u8, 176u8, 70u8, 129u8, 146u8, 84u8, + 65u8, 180u8, 234u8, 55u8, 237u8, 165u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 160usize { + 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::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + a: { + 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: { + 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) + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for MetaPoolDeployed { + const NAME: &'static str = "MetaPoolDeployed"; + 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 PlainPoolDeployed { + pub coins: [Vec; 4usize], + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub deployer: Vec, + pub pool: Vec, + } + impl PlainPoolDeployed { + const TOPIC_ID: [u8; 32] = [ + 184u8, 246u8, 151u8, 45u8, 110u8, 86u8, 210u8, 28u8, 71u8, 98u8, 30u8, 253u8, 127u8, + 2u8, 254u8, 104u8, 240u8, 122u8, 23u8, 201u8, 153u8, 196u8, 34u8, 69u8, 179u8, 171u8, + 211u8, 0u8, 243u8, 77u8, 97u8, 235u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 256usize { + 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::FixedArray(Box::new(ethabi::ParamType::Address), 4usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + coins: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + a: { + 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: { + 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) + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for PlainPoolDeployed { + const NAME: &'static str = "PlainPoolDeployed"; + 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) + } + } +} diff --git a/substreams/ethereum-curve/src/abi/tricrypto_factory.rs b/substreams/ethereum-curve/src/abi/tricrypto_factory.rs index 1ee6521..1bd2e53 100644 --- a/substreams/ethereum-curve/src/abi/tricrypto_factory.rs +++ b/substreams/ethereum-curve/src/abi/tricrypto_factory.rs @@ -1,3785 +1,3227 @@ - 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 AcceptTransferOwnership {} - impl AcceptTransferOwnership { - const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 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 AcceptTransferOwnership { - const NAME: &'static str = "accept_transfer_ownership"; - 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 Admin {} - impl Admin { - const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; - 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 Admin { - const NAME: &'static str = "admin"; - 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 Admin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitTransferOwnership { - pub addr: Vec, - } - impl CommitTransferOwnership { - const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; - 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 { - addr: 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.addr))], - ); - 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 CommitTransferOwnership { - const NAME: &'static str = "commit_transfer_ownership"; - 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 DeployGauge { - pub pool: Vec, - } - impl DeployGauge { - const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; - 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 { - pool: 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.pool))], - ); - 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 DeployGauge { - const NAME: &'static str = "deploy_gauge"; - 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 DeployGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPool { - pub name: String, - pub symbol: String, - pub coins: [Vec; 3usize], - pub weth: Vec, - pub implementation_id: substreams::scalar::BigInt, - pub a: substreams::scalar::BigInt, - pub gamma: substreams::scalar::BigInt, - pub mid_fee: substreams::scalar::BigInt, - pub out_fee: substreams::scalar::BigInt, - pub fee_gamma: substreams::scalar::BigInt, - pub allowed_extra_profit: substreams::scalar::BigInt, - pub adjustment_step: substreams::scalar::BigInt, - pub ma_exp_time: substreams::scalar::BigInt, - pub initial_prices: [substreams::scalar::BigInt; 2usize], - } - impl DeployPool { - const METHOD_ID: [u8; 4] = [170u8, 56u8, 179u8, 133u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 3usize, - ), - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - weth: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - implementation_id: { - 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) - }, - a: { - 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) - }, - gamma: { - 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) - }, - mid_fee: { - 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) - }, - out_fee: { - 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_gamma: { - 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) - }, - allowed_extra_profit: { - 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) - }, - adjustment_step: { - 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) - }, - ma_exp_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) - }, - initial_prices: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .coins - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - ethabi::Token::Address(ethabi::Address::from_slice(&self.weth)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.implementation_id.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.a.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.gamma.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.mid_fee.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.out_fee.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.fee_gamma.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.allowed_extra_profit.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.adjustment_step.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.ma_exp_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 v = self - .initial_prices - .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::FixedArray(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::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 DeployPool { - const NAME: &'static str = "deploy_pool"; - 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 DeployPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FeeReceiver {} - impl FeeReceiver { - const METHOD_ID: [u8; 4] = [202u8, 180u8, 211u8, 219u8]; - 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 FeeReceiver { - const NAME: &'static str = "fee_receiver"; - 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 FeeReceiver { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub from: Vec, - pub to: Vec, - } - impl FindPoolForCoins1 { - const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 FindPoolForCoins1 { - const NAME: &'static str = "find_pool_for_coins1"; - 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 FindPoolForCoins1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins2 { - pub from: Vec, - pub to: Vec, - pub i: substreams::scalar::BigInt, - } - impl FindPoolForCoins2 { - const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { - 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.i.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::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 FindPoolForCoins2 { - const NAME: &'static str = "find_pool_for_coins2"; - 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 FindPoolForCoins2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdmin {} - impl FutureAdmin { - const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; - 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 FutureAdmin { - const NAME: &'static str = "future_admin"; - 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 FutureAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeImplementation {} - impl GaugeImplementation { - const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; - 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 GaugeImplementation { - const NAME: &'static str = "gauge_implementation"; - 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 GaugeImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub pool: Vec, - } - impl GetBalances { - const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; - 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 { - pool: 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.pool))], - ); - 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; 3usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 3usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 3usize]> { - 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 GetBalances { - const NAME: &'static str = "get_balances"; - 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; 3usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 3usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub pool: Vec, - pub from: Vec, - pub to: Vec, - } - impl GetCoinIndices { - const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; - 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::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.pool)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 GetCoinIndices { - const NAME: &'static str = "get_coin_indices"; - 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 GetCoinIndices { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins { - pub pool: Vec, - } - impl GetCoins { - const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; - 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 { - pool: 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.pool))], - ); - 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; 3usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 3usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 3usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[Vec; 3usize]> { - 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 GetCoins { - const NAME: &'static str = "get_coins"; - 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; 3usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 3usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub pool: Vec, - } - impl GetDecimals { - const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; - 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 { - pool: 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.pool))], - ); - 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; 3usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 3usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().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<[substreams::scalar::BigInt; 3usize]> { - 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 GetDecimals { - const NAME: &'static str = "get_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<[substreams::scalar::BigInt; 3usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 3usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauge { - pub pool: Vec, - } - impl GetGauge { - const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; - 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 { - pool: 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.pool))], - ); - 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 GetGauge { - const NAME: &'static str = "get_gauge"; - 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 GetGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetMarketCounts { - pub coin_a: Vec, - pub coin_b: Vec, - } - impl GetMarketCounts { - const METHOD_ID: [u8; 4] = [193u8, 133u8, 107u8, 82u8]; - 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 { - coin_a: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - coin_b: 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.coin_a), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.coin_b)), - ], - ); - 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 GetMarketCounts { - const NAME: &'static str = "get_market_counts"; - 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 GetMarketCounts { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct MathImplementation {} - impl MathImplementation { - const METHOD_ID: [u8; 4] = [161u8, 60u8, 143u8, 129u8]; - 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 MathImplementation { - const NAME: &'static str = "math_implementation"; - 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 MathImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCount {} - impl PoolCount { - const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { - const NAME: &'static str = "pool_count"; - 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 PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolImplementations { - pub arg0: substreams::scalar::BigInt, - } - impl PoolImplementations { - const METHOD_ID: [u8; 4] = [50u8, 115u8, 255u8, 71u8]; - 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 { - arg0: { - 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.arg0.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::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 PoolImplementations { - const NAME: &'static str = "pool_implementations"; - 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 PoolImplementations { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub arg0: substreams::scalar::BigInt, - } - impl PoolList { - const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; - 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 { - arg0: { - 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.arg0.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::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 PoolList { - const NAME: &'static str = "pool_list"; - 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 PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetFeeReceiver { - pub fee_receiver: Vec, - } - impl SetFeeReceiver { - const METHOD_ID: [u8; 4] = [228u8, 26u8, 183u8, 113u8]; - 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 { - fee_receiver: 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.fee_receiver), - ), - ], - ); - 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 SetFeeReceiver { - const NAME: &'static str = "set_fee_receiver"; - 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 SetGaugeImplementation { - pub gauge_implementation: Vec, - } - impl SetGaugeImplementation { - const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; - 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 { - gauge_implementation: 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.gauge_implementation), - ), - ], - ); - 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 SetGaugeImplementation { - const NAME: &'static str = "set_gauge_implementation"; - 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 SetMathImplementation { - pub math_implementation: Vec, - } - impl SetMathImplementation { - const METHOD_ID: [u8; 4] = [176u8, 116u8, 38u8, 244u8]; - 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 { - math_implementation: 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.math_implementation), - ), - ], - ); - 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 SetMathImplementation { - const NAME: &'static str = "set_math_implementation"; - 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 SetPoolImplementation { - pub pool_implementation: Vec, - pub implementation_index: substreams::scalar::BigInt, - } - impl SetPoolImplementation { - const METHOD_ID: [u8; 4] = [111u8, 56u8, 95u8, 246u8]; - 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 { - pool_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - implementation_index: { - 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.pool_implementation), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.implementation_index.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 SetPoolImplementation { - const NAME: &'static str = "set_pool_implementation"; - 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 SetViewsImplementation { - pub views_implementation: Vec, - } - impl SetViewsImplementation { - const METHOD_ID: [u8; 4] = [246u8, 250u8, 147u8, 127u8]; - 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 { - views_implementation: 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.views_implementation), - ), - ], - ); - 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 SetViewsImplementation { - const NAME: &'static str = "set_views_implementation"; - 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 ViewsImplementation {} - impl ViewsImplementation { - const METHOD_ID: [u8; 4] = [227u8, 21u8, 147u8, 216u8]; - 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 ViewsImplementation { - const NAME: &'static str = "views_implementation"; - 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 ViewsImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + +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 AcceptTransferOwnership {} + impl AcceptTransferOwnership { + const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct LiquidityGaugeDeployed { - pub pool: Vec, - pub gauge: Vec, + impl substreams_ethereum::Function for AcceptTransferOwnership { + const NAME: &'static str = "accept_transfer_ownership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl LiquidityGaugeDeployed { - const TOPIC_ID: [u8; 32] = [ - 101u8, - 107u8, - 179u8, - 76u8, - 32u8, - 73u8, - 25u8, - 112u8, - 168u8, - 193u8, - 99u8, - 243u8, - 189u8, - 98u8, - 234u8, - 216u8, - 32u8, - 34u8, - 179u8, - 121u8, - 195u8, - 146u8, - 73u8, - 96u8, - 236u8, - 96u8, - 246u8, - 219u8, - 252u8, - 90u8, - 171u8, - 59u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 Admin {} + impl Admin { + const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; + 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for Admin { + const NAME: &'static str = "admin"; + 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 Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitTransferOwnership { + pub addr: Vec, + } + impl CommitTransferOwnership { + const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; + 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 { + addr: 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.addr))]); + 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 CommitTransferOwnership { + const NAME: &'static str = "commit_transfer_ownership"; + 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 DeployGauge { + pub pool: Vec, + } + impl DeployGauge { + const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; + 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 { + pool: 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.pool))]); + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values + } + } + impl substreams_ethereum::Function for DeployGauge { + const NAME: &'static str = "deploy_gauge"; + 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 DeployGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPool { + pub name: String, + pub symbol: String, + pub coins: [Vec; 3usize], + pub weth: Vec, + pub implementation_id: substreams::scalar::BigInt, + pub a: substreams::scalar::BigInt, + pub gamma: substreams::scalar::BigInt, + pub mid_fee: substreams::scalar::BigInt, + pub out_fee: substreams::scalar::BigInt, + pub fee_gamma: substreams::scalar::BigInt, + pub allowed_extra_profit: substreams::scalar::BigInt, + pub adjustment_step: substreams::scalar::BigInt, + pub ma_exp_time: substreams::scalar::BigInt, + pub initial_prices: [substreams::scalar::BigInt; 2usize], + } + impl DeployPool { + const METHOD_ID: [u8; 4] = [170u8, 56u8, 179u8, 133u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 3usize), + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge: values + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + weth: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + implementation_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + a: { + 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) + }, + gamma: { + 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) + }, + mid_fee: { + 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) + }, + out_fee: { + 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_gamma: { + 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) + }, + allowed_extra_profit: { + 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) + }, + adjustment_step: { + 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) + }, + ma_exp_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) + }, + initial_prices: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_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) + }); + [iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR)] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ + ethabi::Token::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .coins + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + ethabi::Token::Address(ethabi::Address::from_slice(&self.weth)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .implementation_id + .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.a.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.gamma.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.mid_fee.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.out_fee.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.fee_gamma.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 + .allowed_extra_profit + .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 + .adjustment_step + .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.ma_exp_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 v = self + .initial_prices + .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::FixedArray(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::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, } } - impl substreams_ethereum::Event for LiquidityGaugeDeployed { - const NAME: &'static str = "LiquidityGaugeDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferOwnership { - pub old_owner: Vec, - pub new_owner: Vec, - } - impl TransferOwnership { - const TOPIC_ID: [u8; 32] = [ - 92u8, - 72u8, - 101u8, - 40u8, - 236u8, - 62u8, - 63u8, - 14u8, - 169u8, - 17u8, - 129u8, - 207u8, - 248u8, - 17u8, - 111u8, - 2u8, - 191u8, - 163u8, - 80u8, - 224u8, - 59u8, - 139u8, - 111u8, - 18u8, - 224u8, - 7u8, - 101u8, - 173u8, - 187u8, - 90u8, - 248u8, - 92u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for TransferOwnership { - const NAME: &'static str = "TransferOwnership"; - 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) + } + impl substreams_ethereum::Function for DeployPool { + const NAME: &'static str = "deploy_pool"; + 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 DeployPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FeeReceiver {} + impl FeeReceiver { + const METHOD_ID: [u8; 4] = [202u8, 180u8, 211u8, 219u8]; + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct TricryptoPoolDeployed { - pub pool: Vec, - pub name: String, - pub symbol: String, - pub weth: Vec, - pub coins: [Vec; 3usize], - pub math: Vec, - pub salt: [u8; 32usize], - pub packed_precisions: substreams::scalar::BigInt, - pub packed_a_gamma: substreams::scalar::BigInt, - pub packed_fee_params: substreams::scalar::BigInt, - pub packed_rebalancing_params: substreams::scalar::BigInt, - pub packed_prices: substreams::scalar::BigInt, - pub deployer: Vec, - } - impl TricryptoPoolDeployed { - const TOPIC_ID: [u8; 32] = [ - 163u8, - 7u8, - 245u8, - 208u8, - 128u8, - 36u8, - 137u8, - 186u8, - 221u8, - 236u8, - 68u8, - 48u8, - 88u8, - 166u8, - 60u8, - 225u8, - 21u8, - 117u8, - 109u8, - 233u8, - 2u8, - 14u8, - 43u8, - 7u8, - 211u8, - 226u8, - 205u8, - 47u8, - 33u8, - 38u8, - 158u8, - 42u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() < 544usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; + 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; } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 3usize, - ), - ethabi::ParamType::Address, - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values + 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 FeeReceiver { + const NAME: &'static str = "fee_receiver"; + 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 FeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub from: Vec, + pub to: Vec, + } + impl FindPoolForCoins1 { + const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 FindPoolForCoins1 { + const NAME: &'static str = "find_pool_for_coins1"; + 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 FindPoolForCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins2 { + pub from: Vec, + pub to: Vec, + pub i: substreams::scalar::BigInt, + } + impl FindPoolForCoins2 { + const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + i: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - weth: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - math: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - salt: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - packed_precisions: { + .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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.i.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::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 FindPoolForCoins2 { + const NAME: &'static str = "find_pool_for_coins2"; + 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 FindPoolForCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAdmin {} + impl FutureAdmin { + const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; + 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 FutureAdmin { + const NAME: &'static str = "future_admin"; + 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 FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeImplementation {} + impl GaugeImplementation { + const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; + 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 GaugeImplementation { + const NAME: &'static str = "gauge_implementation"; + 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 GaugeImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub pool: Vec, + } + impl GetBalances { + const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; + 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 { + pool: 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.pool))]); + 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; 3usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 3usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) + inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - packed_a_gamma: { - let mut v = [0 as u8; 32]; - values - .pop() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[substreams::scalar::BigInt; 3usize]> { + 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 GetBalances { + const NAME: &'static str = "get_balances"; + 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; 3usize]> for GetBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 3usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub pool: Vec, + pub from: Vec, + pub to: Vec, + } + impl GetCoinIndices { + const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; + 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::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 GetCoinIndices { + const NAME: &'static str = "get_coin_indices"; + 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 GetCoinIndices + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins { + pub pool: Vec, + } + impl GetCoins { + const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; + 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 { + pool: 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.pool))]); + 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; 3usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 3usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 3usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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<[Vec; 3usize]> { + 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 GetCoins { + const NAME: &'static str = "get_coins"; + 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; 3usize]> for GetCoins { + fn output(data: &[u8]) -> Result<[Vec; 3usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub pool: Vec, + } + impl GetDecimals { + const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; + 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 { + pool: 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.pool))]); + 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; 3usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 3usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) - }, - packed_fee_params: { - 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) - }, - packed_rebalancing_params: { - 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) - }, - packed_prices: { - 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) - }, - deployer: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().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, } } - impl substreams_ethereum::Event for TricryptoPoolDeployed { - const NAME: &'static str = "TricryptoPoolDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + pub fn call(&self, address: Vec) -> Option<[substreams::scalar::BigInt; 3usize]> { + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateFeeReceiver { - pub old_fee_receiver: Vec, - pub new_fee_receiver: Vec, - } - impl UpdateFeeReceiver { - const TOPIC_ID: [u8; 32] = [ - 40u8, - 97u8, - 68u8, - 134u8, - 120u8, - 240u8, - 190u8, - 103u8, - 241u8, - 27u8, - 251u8, - 84u8, - 129u8, - 179u8, - 227u8, - 180u8, - 207u8, - 235u8, - 58u8, - 204u8, - 97u8, - 38u8, - 173u8, - 96u8, - 160u8, - 95u8, - 149u8, - 191u8, - 198u8, - 83u8, - 6u8, - 102u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for GetDecimals { + const NAME: &'static str = "get_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<[substreams::scalar::BigInt; 3usize]> for GetDecimals { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 3usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauge { + pub pool: Vec, + } + impl GetGauge { + const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; + 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 { + pool: 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.pool))]); + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for UpdateFeeReceiver { - const NAME: &'static str = "UpdateFeeReceiver"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + } + impl substreams_ethereum::Function for GetGauge { + const NAME: &'static str = "get_gauge"; + 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 GetGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMarketCounts { + pub coin_a: Vec, + pub coin_b: Vec, + } + impl GetMarketCounts { + const METHOD_ID: [u8; 4] = [193u8, 133u8, 107u8, 82u8]; + 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()); } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 { + coin_a: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + coin_b: 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.coin_a)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.coin_b)), + ]); + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateGaugeImplementation { - pub old_gauge_implementation: Vec, - pub new_gauge_implementation: Vec, - } - impl UpdateGaugeImplementation { - const TOPIC_ID: [u8; 32] = [ - 31u8, - 215u8, - 5u8, - 249u8, - 199u8, - 112u8, - 83u8, - 150u8, - 42u8, - 80u8, - 63u8, - 47u8, - 47u8, - 87u8, - 240u8, - 134u8, - 43u8, - 76u8, - 58u8, - 246u8, - 135u8, - 194u8, - 86u8, - 21u8, - 193u8, - 56u8, - 23u8, - 168u8, - 105u8, - 70u8, - 195u8, - 89u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for GetMarketCounts { + const NAME: &'static str = "get_market_counts"; + 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 GetMarketCounts { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MathImplementation {} + impl MathImplementation { + const METHOD_ID: [u8; 4] = [161u8, 60u8, 143u8, 129u8]; + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_gauge_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_gauge_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for UpdateGaugeImplementation { - const NAME: &'static str = "UpdateGaugeImplementation"; - 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) + } + impl substreams_ethereum::Function for MathImplementation { + const NAME: &'static str = "math_implementation"; + 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 MathImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolCount {} + impl PoolCount { + const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateMathImplementation { - pub old_math_implementation: Vec, - pub new_math_implementation: Vec, - } - impl UpdateMathImplementation { - const TOPIC_ID: [u8; 32] = [ - 104u8, - 254u8, - 143u8, - 195u8, - 172u8, - 118u8, - 236u8, - 23u8, - 226u8, - 17u8, - 23u8, - 223u8, - 94u8, - 133u8, - 76u8, - 140u8, - 37u8, - 183u8, - 181u8, - 247u8, - 118u8, - 170u8, - 210u8, - 173u8, - 201u8, - 39u8, - 253u8, - 209u8, - 86u8, - 188u8, - 214u8, - 222u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for PoolCount { + const NAME: &'static str = "pool_count"; + 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 PoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolImplementations { + pub arg0: substreams::scalar::BigInt, + } + impl PoolImplementations { + const METHOD_ID: [u8; 4] = [50u8, 115u8, 255u8, 71u8]; + 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 { + arg0: { + 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.arg0.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") + } } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_math_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_math_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .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::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, } } - impl substreams_ethereum::Event for UpdateMathImplementation { - const NAME: &'static str = "UpdateMathImplementation"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdatePoolImplementation { - pub implemention_id: substreams::scalar::BigInt, - pub old_pool_implementation: Vec, - pub new_pool_implementation: Vec, - } - impl UpdatePoolImplementation { - const TOPIC_ID: [u8; 32] = [ - 106u8, - 66u8, - 239u8, - 150u8, - 5u8, - 225u8, - 53u8, - 175u8, - 175u8, - 106u8, - 228u8, - 243u8, - 104u8, - 59u8, - 22u8, - 26u8, - 59u8, - 115u8, - 105u8, - 208u8, - 124u8, - 157u8, - 82u8, - 199u8, - 1u8, - 171u8, - 105u8, - 85u8, - 62u8, - 4u8, - 195u8, - 182u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 96usize { - return false; + } + } + } + impl substreams_ethereum::Function for PoolImplementations { + const NAME: &'static str = "pool_implementations"; + 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 PoolImplementations { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolList { + pub arg0: substreams::scalar::BigInt, + } + impl PoolList { + const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; + 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 { + arg0: { + 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.arg0.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") + } } - 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::Address, - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - implemention_id: { - 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) - }, - old_pool_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_pool_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .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::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, } } - impl substreams_ethereum::Event for UpdatePoolImplementation { - const NAME: &'static str = "UpdatePoolImplementation"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateViewsImplementation { - pub old_views_implementation: Vec, - pub new_views_implementation: Vec, - } - impl UpdateViewsImplementation { - const TOPIC_ID: [u8; 32] = [ - 216u8, - 78u8, - 177u8, - 234u8, - 112u8, - 205u8, - 164u8, - 10u8, - 107u8, - 250u8, - 161u8, - 31u8, - 79u8, - 105u8, - 239u8, - 161u8, - 12u8, - 188u8, - 94u8, - 184u8, - 39u8, - 96u8, - 179u8, - 5u8, - 143u8, - 68u8, - 5u8, - 18u8, - 236u8, - 29u8, - 109u8, - 31u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for PoolList { + const NAME: &'static str = "pool_list"; + 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 PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub fee_receiver: Vec, + } + impl SetFeeReceiver { + const METHOD_ID: [u8; 4] = [228u8, 26u8, 183u8, 113u8]; + 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 { + fee_receiver: 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.fee_receiver, + ))]); + 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 SetFeeReceiver { + const NAME: &'static str = "set_fee_receiver"; + 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 SetGaugeImplementation { + pub gauge_implementation: Vec, + } + impl SetGaugeImplementation { + const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; + 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 { + gauge_implementation: 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.gauge_implementation, + ))]); + 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 SetGaugeImplementation { + const NAME: &'static str = "set_gauge_implementation"; + 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 SetMathImplementation { + pub math_implementation: Vec, + } + impl SetMathImplementation { + const METHOD_ID: [u8; 4] = [176u8, 116u8, 38u8, 244u8]; + 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 { + math_implementation: 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.math_implementation, + ))]); + 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 SetMathImplementation { + const NAME: &'static str = "set_math_implementation"; + 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 SetPoolImplementation { + pub pool_implementation: Vec, + pub implementation_index: substreams::scalar::BigInt, + } + impl SetPoolImplementation { + const METHOD_ID: [u8; 4] = [111u8, 56u8, 95u8, 246u8]; + 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 { + pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + implementation_index: { + 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.pool_implementation)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .implementation_index + .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 SetPoolImplementation { + const NAME: &'static str = "set_pool_implementation"; + 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 SetViewsImplementation { + pub views_implementation: Vec, + } + impl SetViewsImplementation { + const METHOD_ID: [u8; 4] = [246u8, 250u8, 147u8, 127u8]; + 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 { + views_implementation: 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.views_implementation, + ))]); + 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 SetViewsImplementation { + const NAME: &'static str = "set_views_implementation"; + 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 ViewsImplementation {} + impl ViewsImplementation { + const METHOD_ID: [u8; 4] = [227u8, 21u8, 147u8, 216u8]; + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_views_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_views_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for UpdateViewsImplementation { - const NAME: &'static str = "UpdateViewsImplementation"; - 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) - } + } + impl substreams_ethereum::Function for ViewsImplementation { + const NAME: &'static str = "views_implementation"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - } \ No newline at end of file + 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 ViewsImplementation { + fn output(data: &[u8]) -> Result, String> { + 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 LiquidityGaugeDeployed { + pub pool: Vec, + pub gauge: Vec, + } + impl LiquidityGaugeDeployed { + const TOPIC_ID: [u8; 32] = [ + 101u8, 107u8, 179u8, 76u8, 32u8, 73u8, 25u8, 112u8, 168u8, 193u8, 99u8, 243u8, 189u8, + 98u8, 234u8, 216u8, 32u8, 34u8, 179u8, 121u8, 195u8, 146u8, 73u8, 96u8, 236u8, 96u8, + 246u8, 219u8, 252u8, 90u8, 171u8, 59u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for LiquidityGaugeDeployed { + const NAME: &'static str = "LiquidityGaugeDeployed"; + 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 TransferOwnership { + pub old_owner: Vec, + pub new_owner: Vec, + } + impl TransferOwnership { + const TOPIC_ID: [u8; 32] = [ + 92u8, 72u8, 101u8, 40u8, 236u8, 62u8, 63u8, 14u8, 169u8, 17u8, 129u8, 207u8, 248u8, + 17u8, 111u8, 2u8, 191u8, 163u8, 80u8, 224u8, 59u8, 139u8, 111u8, 18u8, 224u8, 7u8, + 101u8, 173u8, 187u8, 90u8, 248u8, 92u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for TransferOwnership { + const NAME: &'static str = "TransferOwnership"; + 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 TricryptoPoolDeployed { + pub pool: Vec, + pub name: String, + pub symbol: String, + pub weth: Vec, + pub coins: [Vec; 3usize], + pub math: Vec, + pub salt: [u8; 32usize], + pub packed_precisions: substreams::scalar::BigInt, + pub packed_a_gamma: substreams::scalar::BigInt, + pub packed_fee_params: substreams::scalar::BigInt, + pub packed_rebalancing_params: substreams::scalar::BigInt, + pub packed_prices: substreams::scalar::BigInt, + pub deployer: Vec, + } + impl TricryptoPoolDeployed { + const TOPIC_ID: [u8; 32] = [ + 163u8, 7u8, 245u8, 208u8, 128u8, 36u8, 137u8, 186u8, 221u8, 236u8, 68u8, 48u8, 88u8, + 166u8, 60u8, 225u8, 21u8, 117u8, 109u8, 233u8, 2u8, 14u8, 43u8, 7u8, 211u8, 226u8, + 205u8, 47u8, 33u8, 38u8, 158u8, 42u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() < 544usize { + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 3usize), + ethabi::ParamType::Address, + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + weth: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + coins: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + math: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + salt: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + packed_precisions: { + 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) + }, + packed_a_gamma: { + 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) + }, + packed_fee_params: { + 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) + }, + packed_rebalancing_params: { + 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) + }, + packed_prices: { + 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) + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for TricryptoPoolDeployed { + const NAME: &'static str = "TricryptoPoolDeployed"; + 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 UpdateFeeReceiver { + pub old_fee_receiver: Vec, + pub new_fee_receiver: Vec, + } + impl UpdateFeeReceiver { + const TOPIC_ID: [u8; 32] = [ + 40u8, 97u8, 68u8, 134u8, 120u8, 240u8, 190u8, 103u8, 241u8, 27u8, 251u8, 84u8, 129u8, + 179u8, 227u8, 180u8, 207u8, 235u8, 58u8, 204u8, 97u8, 38u8, 173u8, 96u8, 160u8, 95u8, + 149u8, 191u8, 198u8, 83u8, 6u8, 102u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateFeeReceiver { + const NAME: &'static str = "UpdateFeeReceiver"; + 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 UpdateGaugeImplementation { + pub old_gauge_implementation: Vec, + pub new_gauge_implementation: Vec, + } + impl UpdateGaugeImplementation { + const TOPIC_ID: [u8; 32] = [ + 31u8, 215u8, 5u8, 249u8, 199u8, 112u8, 83u8, 150u8, 42u8, 80u8, 63u8, 47u8, 47u8, 87u8, + 240u8, 134u8, 43u8, 76u8, 58u8, 246u8, 135u8, 194u8, 86u8, 21u8, 193u8, 56u8, 23u8, + 168u8, 105u8, 70u8, 195u8, 89u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_gauge_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_gauge_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateGaugeImplementation { + const NAME: &'static str = "UpdateGaugeImplementation"; + 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 UpdateMathImplementation { + pub old_math_implementation: Vec, + pub new_math_implementation: Vec, + } + impl UpdateMathImplementation { + const TOPIC_ID: [u8; 32] = [ + 104u8, 254u8, 143u8, 195u8, 172u8, 118u8, 236u8, 23u8, 226u8, 17u8, 23u8, 223u8, 94u8, + 133u8, 76u8, 140u8, 37u8, 183u8, 181u8, 247u8, 118u8, 170u8, 210u8, 173u8, 201u8, 39u8, + 253u8, 209u8, 86u8, 188u8, 214u8, 222u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_math_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_math_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateMathImplementation { + const NAME: &'static str = "UpdateMathImplementation"; + 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 UpdatePoolImplementation { + pub implemention_id: substreams::scalar::BigInt, + pub old_pool_implementation: Vec, + pub new_pool_implementation: Vec, + } + impl UpdatePoolImplementation { + const TOPIC_ID: [u8; 32] = [ + 106u8, 66u8, 239u8, 150u8, 5u8, 225u8, 53u8, 175u8, 175u8, 106u8, 228u8, 243u8, 104u8, + 59u8, 22u8, 26u8, 59u8, 115u8, 105u8, 208u8, 124u8, 157u8, 82u8, 199u8, 1u8, 171u8, + 105u8, 85u8, 62u8, 4u8, 195u8, 182u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 96usize { + 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::Address, + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + implemention_id: { + 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) + }, + old_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdatePoolImplementation { + const NAME: &'static str = "UpdatePoolImplementation"; + 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 UpdateViewsImplementation { + pub old_views_implementation: Vec, + pub new_views_implementation: Vec, + } + impl UpdateViewsImplementation { + const TOPIC_ID: [u8; 32] = [ + 216u8, 78u8, 177u8, 234u8, 112u8, 205u8, 164u8, 10u8, 107u8, 250u8, 161u8, 31u8, 79u8, + 105u8, 239u8, 161u8, 12u8, 188u8, 94u8, 184u8, 39u8, 96u8, 179u8, 5u8, 143u8, 68u8, + 5u8, 18u8, 236u8, 29u8, 109u8, 31u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_views_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_views_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateViewsImplementation { + const NAME: &'static str = "UpdateViewsImplementation"; + 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) + } + } +} diff --git a/substreams/ethereum-curve/src/abi/twocrypto_factory.rs b/substreams/ethereum-curve/src/abi/twocrypto_factory.rs index 7bb6a83..1c74303 100644 --- a/substreams/ethereum-curve/src/abi/twocrypto_factory.rs +++ b/substreams/ethereum-curve/src/abi/twocrypto_factory.rs @@ -1,3817 +1,3243 @@ - 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 AcceptTransferOwnership {} - impl AcceptTransferOwnership { - const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 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 AcceptTransferOwnership { - const NAME: &'static str = "accept_transfer_ownership"; - 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 Admin {} - impl Admin { - const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; - 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 Admin { - const NAME: &'static str = "admin"; - 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 Admin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitTransferOwnership { - pub addr: Vec, - } - impl CommitTransferOwnership { - const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; - 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 { - addr: 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.addr))], - ); - 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 CommitTransferOwnership { - const NAME: &'static str = "commit_transfer_ownership"; - 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 DeployGauge { - pub pool: Vec, - } - impl DeployGauge { - const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; - 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 { - pool: 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.pool))], - ); - 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 DeployGauge { - const NAME: &'static str = "deploy_gauge"; - 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 DeployGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPool { - pub name: String, - pub symbol: String, - pub coins: [Vec; 2usize], - pub implementation_id: substreams::scalar::BigInt, - pub a: substreams::scalar::BigInt, - pub gamma: substreams::scalar::BigInt, - pub mid_fee: substreams::scalar::BigInt, - pub out_fee: substreams::scalar::BigInt, - pub fee_gamma: substreams::scalar::BigInt, - pub allowed_extra_profit: substreams::scalar::BigInt, - pub adjustment_step: substreams::scalar::BigInt, - pub ma_exp_time: substreams::scalar::BigInt, - pub initial_price: substreams::scalar::BigInt, - } - impl DeployPool { - const METHOD_ID: [u8; 4] = [201u8, 85u8, 250u8, 4u8]; - 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::String, - ethabi::ParamType::String, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - 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 { - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - implementation_id: { - 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) - }, - a: { - 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) - }, - gamma: { - 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) - }, - mid_fee: { - 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) - }, - out_fee: { - 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_gamma: { - 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) - }, - allowed_extra_profit: { - 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) - }, - adjustment_step: { - 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) - }, - ma_exp_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) - }, - initial_price: { - 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::String(self.name.clone()), - ethabi::Token::String(self.symbol.clone()), - { - let v = self - .coins - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.implementation_id.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.a.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.gamma.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.mid_fee.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.out_fee.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.fee_gamma.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.allowed_extra_profit.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.adjustment_step.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.ma_exp_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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.initial_price.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::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 DeployPool { - const NAME: &'static str = "deploy_pool"; - 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 DeployPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FeeReceiver {} - impl FeeReceiver { - const METHOD_ID: [u8; 4] = [202u8, 180u8, 211u8, 219u8]; - 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 FeeReceiver { - const NAME: &'static str = "fee_receiver"; - 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 FeeReceiver { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub from: Vec, - pub to: Vec, - } - impl FindPoolForCoins1 { - const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 FindPoolForCoins1 { - const NAME: &'static str = "find_pool_for_coins1"; - 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 FindPoolForCoins1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins2 { - pub from: Vec, - pub to: Vec, - pub i: substreams::scalar::BigInt, - } - impl FindPoolForCoins2 { - const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; - 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 { - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { - 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.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.i.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::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 FindPoolForCoins2 { - const NAME: &'static str = "find_pool_for_coins2"; - 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 FindPoolForCoins2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdmin {} - impl FutureAdmin { - const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; - 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 FutureAdmin { - const NAME: &'static str = "future_admin"; - 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 FutureAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeImplementation {} - impl GaugeImplementation { - const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; - 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 GaugeImplementation { - const NAME: &'static str = "gauge_implementation"; - 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 GaugeImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub pool: Vec, - } - impl GetBalances { - const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; - 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 { - pool: 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.pool))], - ); - 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; 2usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [iter.next().expect(INTERNAL_ERR), iter.next().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<[substreams::scalar::BigInt; 2usize]> { - 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 GetBalances { - const NAME: &'static str = "get_balances"; - 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; 2usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub pool: Vec, - pub from: Vec, - pub to: Vec, - } - impl GetCoinIndices { - const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; - 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::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: 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.pool)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), - ], - ); - 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 GetCoinIndices { - const NAME: &'static str = "get_coin_indices"; - 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 GetCoinIndices { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins { - pub pool: Vec, - } - impl GetCoins { - const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; - 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 { - pool: 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.pool))], - ); - 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; 2usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 2usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() - }); - [iter.next().expect(INTERNAL_ERR), iter.next().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<[Vec; 2usize]> { - 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 GetCoins { - const NAME: &'static str = "get_coins"; - 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; 2usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub pool: Vec, - } - impl GetDecimals { - const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; - 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 { - pool: 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.pool))], - ); - 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; 2usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut iter = values - .pop() - .expect("one output data should have existed") - .into_fixed_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) - }); - [iter.next().expect(INTERNAL_ERR), iter.next().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<[substreams::scalar::BigInt; 2usize]> { - 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 GetDecimals { - const NAME: &'static str = "get_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<[substreams::scalar::BigInt; 2usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauge { - pub pool: Vec, - } - impl GetGauge { - const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; - 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 { - pool: 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.pool))], - ); - 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 GetGauge { - const NAME: &'static str = "get_gauge"; - 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 GetGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetMarketCounts { - pub coin_a: Vec, - pub coin_b: Vec, - } - impl GetMarketCounts { - const METHOD_ID: [u8; 4] = [193u8, 133u8, 107u8, 82u8]; - 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 { - coin_a: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - coin_b: 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.coin_a), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.coin_b)), - ], - ); - 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 GetMarketCounts { - const NAME: &'static str = "get_market_counts"; - 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 GetMarketCounts { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct InitialiseOwnership { - pub fee_receiver: Vec, - pub admin: Vec, - } - impl InitialiseOwnership { - const METHOD_ID: [u8; 4] = [69u8, 230u8, 47u8, 133u8]; - 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 { - fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - admin: 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.fee_receiver), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.admin)), - ], - ); - 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 InitialiseOwnership { - const NAME: &'static str = "initialise_ownership"; - 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 MathImplementation {} - impl MathImplementation { - const METHOD_ID: [u8; 4] = [161u8, 60u8, 143u8, 129u8]; - 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 MathImplementation { - const NAME: &'static str = "math_implementation"; - 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 MathImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolCount {} - impl PoolCount { - const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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 PoolCount { - const NAME: &'static str = "pool_count"; - 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 PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolImplementations { - pub arg0: substreams::scalar::BigInt, - } - impl PoolImplementations { - const METHOD_ID: [u8; 4] = [50u8, 115u8, 255u8, 71u8]; - 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 { - arg0: { - 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.arg0.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::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 PoolImplementations { - const NAME: &'static str = "pool_implementations"; - 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 PoolImplementations { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub arg0: substreams::scalar::BigInt, - } - impl PoolList { - const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; - 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 { - arg0: { - 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.arg0.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::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 PoolList { - const NAME: &'static str = "pool_list"; - 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 PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetFeeReceiver { - pub fee_receiver: Vec, - } - impl SetFeeReceiver { - const METHOD_ID: [u8; 4] = [228u8, 26u8, 183u8, 113u8]; - 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 { - fee_receiver: 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.fee_receiver), - ), - ], - ); - 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 SetFeeReceiver { - const NAME: &'static str = "set_fee_receiver"; - 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 SetGaugeImplementation { - pub gauge_implementation: Vec, - } - impl SetGaugeImplementation { - const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; - 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 { - gauge_implementation: 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.gauge_implementation), - ), - ], - ); - 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 SetGaugeImplementation { - const NAME: &'static str = "set_gauge_implementation"; - 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 SetMathImplementation { - pub math_implementation: Vec, - } - impl SetMathImplementation { - const METHOD_ID: [u8; 4] = [176u8, 116u8, 38u8, 244u8]; - 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 { - math_implementation: 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.math_implementation), - ), - ], - ); - 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 SetMathImplementation { - const NAME: &'static str = "set_math_implementation"; - 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 SetPoolImplementation { - pub pool_implementation: Vec, - pub implementation_index: substreams::scalar::BigInt, - } - impl SetPoolImplementation { - const METHOD_ID: [u8; 4] = [111u8, 56u8, 95u8, 246u8]; - 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 { - pool_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - implementation_index: { - 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.pool_implementation), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.implementation_index.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 SetPoolImplementation { - const NAME: &'static str = "set_pool_implementation"; - 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 SetViewsImplementation { - pub views_implementation: Vec, - } - impl SetViewsImplementation { - const METHOD_ID: [u8; 4] = [246u8, 250u8, 147u8, 127u8]; - 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 { - views_implementation: 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.views_implementation), - ), - ], - ); - 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 SetViewsImplementation { - const NAME: &'static str = "set_views_implementation"; - 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 ViewsImplementation {} - impl ViewsImplementation { - const METHOD_ID: [u8; 4] = [227u8, 21u8, 147u8, 216u8]; - 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 ViewsImplementation { - const NAME: &'static str = "views_implementation"; - 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 ViewsImplementation { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + +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 AcceptTransferOwnership {} + impl AcceptTransferOwnership { + const METHOD_ID: [u8; 4] = [229u8, 234u8, 71u8, 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct LiquidityGaugeDeployed { - pub pool: Vec, - pub gauge: Vec, + impl substreams_ethereum::Function for AcceptTransferOwnership { + const NAME: &'static str = "accept_transfer_ownership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl LiquidityGaugeDeployed { - const TOPIC_ID: [u8; 32] = [ - 101u8, - 107u8, - 179u8, - 76u8, - 32u8, - 73u8, - 25u8, - 112u8, - 168u8, - 193u8, - 99u8, - 243u8, - 189u8, - 98u8, - 234u8, - 216u8, - 32u8, - 34u8, - 179u8, - 121u8, - 195u8, - 146u8, - 73u8, - 96u8, - 236u8, - 96u8, - 246u8, - 219u8, - 252u8, - 90u8, - 171u8, - 59u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 Admin {} + impl Admin { + const METHOD_ID: [u8; 4] = [248u8, 81u8, 164u8, 64u8]; + 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for Admin { + const NAME: &'static str = "admin"; + 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 Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitTransferOwnership { + pub addr: Vec, + } + impl CommitTransferOwnership { + const METHOD_ID: [u8; 4] = [107u8, 68u8, 26u8, 64u8]; + 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 { + addr: 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.addr))]); + 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 CommitTransferOwnership { + const NAME: &'static str = "commit_transfer_ownership"; + 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 DeployGauge { + pub pool: Vec, + } + impl DeployGauge { + const METHOD_ID: [u8; 4] = [150u8, 190u8, 187u8, 52u8]; + 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 { + pool: 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.pool))]); + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values + } + } + impl substreams_ethereum::Function for DeployGauge { + const NAME: &'static str = "deploy_gauge"; + 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 DeployGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPool { + pub name: String, + pub symbol: String, + pub coins: [Vec; 2usize], + pub implementation_id: substreams::scalar::BigInt, + pub a: substreams::scalar::BigInt, + pub gamma: substreams::scalar::BigInt, + pub mid_fee: substreams::scalar::BigInt, + pub out_fee: substreams::scalar::BigInt, + pub fee_gamma: substreams::scalar::BigInt, + pub allowed_extra_profit: substreams::scalar::BigInt, + pub adjustment_step: substreams::scalar::BigInt, + pub ma_exp_time: substreams::scalar::BigInt, + pub initial_price: substreams::scalar::BigInt, + } + impl DeployPool { + const METHOD_ID: [u8; 4] = [201u8, 85u8, 250u8, 4u8]; + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 2usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + 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 { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge: values + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR)] + }, + implementation_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + a: { + 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) + }, + gamma: { + 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) + }, + mid_fee: { + 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) + }, + out_fee: { + 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_gamma: { + 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) + }, + allowed_extra_profit: { + 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) + }, + adjustment_step: { + 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) + }, + ma_exp_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) + }, + initial_price: { + 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::String(self.name.clone()), + ethabi::Token::String(self.symbol.clone()), + { + let v = self + .coins + .iter() + .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) + .collect(); + ethabi::Token::FixedArray(v) + }, + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .implementation_id + .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.a.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.gamma.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.mid_fee.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.out_fee.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.fee_gamma.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 + .allowed_extra_profit + .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 + .adjustment_step + .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.ma_exp_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(), + )), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.initial_price.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::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, } } - impl substreams_ethereum::Event for LiquidityGaugeDeployed { - const NAME: &'static str = "LiquidityGaugeDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferOwnership { - pub old_owner: Vec, - pub new_owner: Vec, - } - impl TransferOwnership { - const TOPIC_ID: [u8; 32] = [ - 92u8, - 72u8, - 101u8, - 40u8, - 236u8, - 62u8, - 63u8, - 14u8, - 169u8, - 17u8, - 129u8, - 207u8, - 248u8, - 17u8, - 111u8, - 2u8, - 191u8, - 163u8, - 80u8, - 224u8, - 59u8, - 139u8, - 111u8, - 18u8, - 224u8, - 7u8, - 101u8, - 173u8, - 187u8, - 90u8, - 248u8, - 92u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for TransferOwnership { - const NAME: &'static str = "TransferOwnership"; - 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) + } + impl substreams_ethereum::Function for DeployPool { + const NAME: &'static str = "deploy_pool"; + 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 DeployPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FeeReceiver {} + impl FeeReceiver { + const METHOD_ID: [u8; 4] = [202u8, 180u8, 211u8, 219u8]; + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct TwocryptoPoolDeployed { - pub pool: Vec, - pub name: String, - pub symbol: String, - pub coins: [Vec; 2usize], - pub math: Vec, - pub salt: [u8; 32usize], - pub precisions: [substreams::scalar::BigInt; 2usize], - pub packed_a_gamma: substreams::scalar::BigInt, - pub packed_fee_params: substreams::scalar::BigInt, - pub packed_rebalancing_params: substreams::scalar::BigInt, - pub packed_prices: substreams::scalar::BigInt, - pub deployer: Vec, - } - impl TwocryptoPoolDeployed { - const TOPIC_ID: [u8; 32] = [ - 129u8, - 82u8, - 163u8, - 3u8, - 126u8, - 61u8, - 197u8, - 65u8, - 84u8, - 173u8, - 13u8, - 44u8, - 173u8, - 177u8, - 207u8, - 126u8, - 29u8, - 27u8, - 158u8, - 43u8, - 98u8, - 95u8, - 170u8, - 61u8, - 251u8, - 79u8, - 224u8, - 61u8, - 96u8, - 145u8, - 2u8, - 202u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() < 512usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; + 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; } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::String, - ethabi::ParamType::String, - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 2usize, - ), - ethabi::ParamType::Address, - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - pool: values + 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 FeeReceiver { + const NAME: &'static str = "fee_receiver"; + 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 FeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub from: Vec, + pub to: Vec, + } + impl FindPoolForCoins1 { + const METHOD_ID: [u8; 4] = [168u8, 125u8, 240u8, 108u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 FindPoolForCoins1 { + const NAME: &'static str = "find_pool_for_coins1"; + 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 FindPoolForCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins2 { + pub from: Vec, + pub to: Vec, + pub i: substreams::scalar::BigInt, + } + impl FindPoolForCoins2 { + const METHOD_ID: [u8; 4] = [105u8, 130u8, 235u8, 11u8]; + 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 { + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + i: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - coins: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - inner - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec() - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - math: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - salt: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - precisions: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - ] - }, - packed_a_gamma: { + .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.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self.i.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::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 FindPoolForCoins2 { + const NAME: &'static str = "find_pool_for_coins2"; + 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 FindPoolForCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAdmin {} + impl FutureAdmin { + const METHOD_ID: [u8; 4] = [23u8, 247u8, 24u8, 42u8]; + 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 FutureAdmin { + const NAME: &'static str = "future_admin"; + 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 FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeImplementation {} + impl GaugeImplementation { + const METHOD_ID: [u8; 4] = [141u8, 242u8, 66u8, 7u8]; + 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 GaugeImplementation { + const NAME: &'static str = "gauge_implementation"; + 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 GaugeImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub pool: Vec, + } + impl GetBalances { + const METHOD_ID: [u8; 4] = [146u8, 227u8, 204u8, 45u8]; + 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 { + pool: 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.pool))]); + 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; 2usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) + inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - packed_fee_params: { - let mut v = [0 as u8; 32]; - values - .pop() + }); + [iter.next().expect(INTERNAL_ERR), iter.next().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<[substreams::scalar::BigInt; 2usize]> { + 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 GetBalances { + const NAME: &'static str = "get_balances"; + 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; 2usize]> for GetBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub pool: Vec, + pub from: Vec, + pub to: Vec, + } + impl GetCoinIndices { + const METHOD_ID: [u8; 4] = [235u8, 133u8, 34u8, 109u8]; + 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::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: 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.pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), + ]); + 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 GetCoinIndices { + const NAME: &'static str = "get_coin_indices"; + 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 GetCoinIndices + { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins { + pub pool: Vec, + } + impl GetCoins { + const METHOD_ID: [u8; 4] = [154u8, 201u8, 13u8, 61u8]; + 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 { + pool: 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.pool))]); + 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; 2usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 2usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [iter.next().expect(INTERNAL_ERR), iter.next().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<[Vec; 2usize]> { + 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 GetCoins { + const NAME: &'static str = "get_coins"; + 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; 2usize]> for GetCoins { + fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub pool: Vec, + } + impl GetDecimals { + const METHOD_ID: [u8; 4] = [82u8, 181u8, 21u8, 85u8]; + 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 { + pool: 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.pool))]); + 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; 2usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + )], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut iter = values + .pop() + .expect("one output data should have existed") + .into_fixed_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) - }, - packed_rebalancing_params: { - 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) - }, - packed_prices: { - 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) - }, - deployer: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + }); + [iter.next().expect(INTERNAL_ERR), iter.next().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, } } - impl substreams_ethereum::Event for TwocryptoPoolDeployed { - const NAME: &'static str = "TwocryptoPoolDeployed"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + pub fn call(&self, address: Vec) -> Option<[substreams::scalar::BigInt; 2usize]> { + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateFeeReceiver { - pub old_fee_receiver: Vec, - pub new_fee_receiver: Vec, - } - impl UpdateFeeReceiver { - const TOPIC_ID: [u8; 32] = [ - 40u8, - 97u8, - 68u8, - 134u8, - 120u8, - 240u8, - 190u8, - 103u8, - 241u8, - 27u8, - 251u8, - 84u8, - 129u8, - 179u8, - 227u8, - 180u8, - 207u8, - 235u8, - 58u8, - 204u8, - 97u8, - 38u8, - 173u8, - 96u8, - 160u8, - 95u8, - 149u8, - 191u8, - 198u8, - 83u8, - 6u8, - 102u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for GetDecimals { + const NAME: &'static str = "get_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<[substreams::scalar::BigInt; 2usize]> for GetDecimals { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauge { + pub pool: Vec, + } + impl GetGauge { + const METHOD_ID: [u8; 4] = [218u8, 242u8, 151u8, 185u8]; + 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 { + pool: 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.pool))]); + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for UpdateFeeReceiver { - const NAME: &'static str = "UpdateFeeReceiver"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + } + impl substreams_ethereum::Function for GetGauge { + const NAME: &'static str = "get_gauge"; + 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 GetGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMarketCounts { + pub coin_a: Vec, + pub coin_b: Vec, + } + impl GetMarketCounts { + const METHOD_ID: [u8; 4] = [193u8, 133u8, 107u8, 82u8]; + 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()); } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + 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 { + coin_a: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + coin_b: 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.coin_a)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.coin_b)), + ]); + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateGaugeImplementation { - pub old_gauge_implementation: Vec, - pub new_gauge_implementation: Vec, - } - impl UpdateGaugeImplementation { - const TOPIC_ID: [u8; 32] = [ - 31u8, - 215u8, - 5u8, - 249u8, - 199u8, - 112u8, - 83u8, - 150u8, - 42u8, - 80u8, - 63u8, - 47u8, - 47u8, - 87u8, - 240u8, - 134u8, - 43u8, - 76u8, - 58u8, - 246u8, - 135u8, - 194u8, - 86u8, - 21u8, - 193u8, - 56u8, - 23u8, - 168u8, - 105u8, - 70u8, - 195u8, - 89u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for GetMarketCounts { + const NAME: &'static str = "get_market_counts"; + 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 GetMarketCounts { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InitialiseOwnership { + pub fee_receiver: Vec, + pub admin: Vec, + } + impl InitialiseOwnership { + const METHOD_ID: [u8; 4] = [69u8, 230u8, 47u8, 133u8]; + 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 { + fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + admin: 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.fee_receiver)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.admin)), + ]); + 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 InitialiseOwnership { + const NAME: &'static str = "initialise_ownership"; + 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 MathImplementation {} + impl MathImplementation { + const METHOD_ID: [u8; 4] = [161u8, 60u8, 143u8, 129u8]; + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_gauge_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_gauge_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for UpdateGaugeImplementation { - const NAME: &'static str = "UpdateGaugeImplementation"; - 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) + } + impl substreams_ethereum::Function for MathImplementation { + const NAME: &'static str = "math_implementation"; + 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 MathImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolCount {} + impl PoolCount { + const METHOD_ID: [u8; 4] = [149u8, 106u8, 174u8, 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 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateMathImplementation { - pub old_math_implementation: Vec, - pub new_math_implementation: Vec, - } - impl UpdateMathImplementation { - const TOPIC_ID: [u8; 32] = [ - 104u8, - 254u8, - 143u8, - 195u8, - 172u8, - 118u8, - 236u8, - 23u8, - 226u8, - 17u8, - 23u8, - 223u8, - 94u8, - 133u8, - 76u8, - 140u8, - 37u8, - 183u8, - 181u8, - 247u8, - 118u8, - 170u8, - 210u8, - 173u8, - 201u8, - 39u8, - 253u8, - 209u8, - 86u8, - 188u8, - 214u8, - 222u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for PoolCount { + const NAME: &'static str = "pool_count"; + 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 PoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolImplementations { + pub arg0: substreams::scalar::BigInt, + } + impl PoolImplementations { + const METHOD_ID: [u8; 4] = [50u8, 115u8, 255u8, 71u8]; + 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 { + arg0: { + 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.arg0.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") + } } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_math_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_math_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .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::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, } } - impl substreams_ethereum::Event for UpdateMathImplementation { - const NAME: &'static str = "UpdateMathImplementation"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdatePoolImplementation { - pub implemention_id: substreams::scalar::BigInt, - pub old_pool_implementation: Vec, - pub new_pool_implementation: Vec, - } - impl UpdatePoolImplementation { - const TOPIC_ID: [u8; 32] = [ - 106u8, - 66u8, - 239u8, - 150u8, - 5u8, - 225u8, - 53u8, - 175u8, - 175u8, - 106u8, - 228u8, - 243u8, - 104u8, - 59u8, - 22u8, - 26u8, - 59u8, - 115u8, - 105u8, - 208u8, - 124u8, - 157u8, - 82u8, - 199u8, - 1u8, - 171u8, - 105u8, - 85u8, - 62u8, - 4u8, - 195u8, - 182u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 96usize { - return false; + } + } + } + impl substreams_ethereum::Function for PoolImplementations { + const NAME: &'static str = "pool_implementations"; + 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 PoolImplementations { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolList { + pub arg0: substreams::scalar::BigInt, + } + impl PoolList { + const METHOD_ID: [u8; 4] = [58u8, 29u8, 93u8, 142u8]; + 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 { + arg0: { + 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.arg0.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") + } } - 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::Address, - ethabi::ParamType::Address, - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - implemention_id: { - 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) - }, - old_pool_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_pool_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + .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::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, } } - impl substreams_ethereum::Event for UpdatePoolImplementation { - const NAME: &'static str = "UpdatePoolImplementation"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + 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; } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateViewsImplementation { - pub old_views_implementation: Vec, - pub new_views_implementation: Vec, - } - impl UpdateViewsImplementation { - const TOPIC_ID: [u8; 32] = [ - 216u8, - 78u8, - 177u8, - 234u8, - 112u8, - 205u8, - 164u8, - 10u8, - 107u8, - 250u8, - 161u8, - 31u8, - 79u8, - 105u8, - 239u8, - 161u8, - 12u8, - 188u8, - 94u8, - 184u8, - 39u8, - 96u8, - 179u8, - 5u8, - 143u8, - 68u8, - 5u8, - 18u8, - 236u8, - 29u8, - 109u8, - 31u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; + 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 } - if log.data.len() != 64usize { - return false; + } + } + } + impl substreams_ethereum::Function for PoolList { + const NAME: &'static str = "pool_list"; + 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 PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub fee_receiver: Vec, + } + impl SetFeeReceiver { + const METHOD_ID: [u8; 4] = [228u8, 26u8, 183u8, 113u8]; + 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 { + fee_receiver: 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.fee_receiver, + ))]); + 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 SetFeeReceiver { + const NAME: &'static str = "set_fee_receiver"; + 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 SetGaugeImplementation { + pub gauge_implementation: Vec, + } + impl SetGaugeImplementation { + const METHOD_ID: [u8; 4] = [143u8, 3u8, 24u8, 44u8]; + 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 { + gauge_implementation: 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.gauge_implementation, + ))]); + 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 SetGaugeImplementation { + const NAME: &'static str = "set_gauge_implementation"; + 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 SetMathImplementation { + pub math_implementation: Vec, + } + impl SetMathImplementation { + const METHOD_ID: [u8; 4] = [176u8, 116u8, 38u8, 244u8]; + 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 { + math_implementation: 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.math_implementation, + ))]); + 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 SetMathImplementation { + const NAME: &'static str = "set_math_implementation"; + 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 SetPoolImplementation { + pub pool_implementation: Vec, + pub implementation_index: substreams::scalar::BigInt, + } + impl SetPoolImplementation { + const METHOD_ID: [u8; 4] = [111u8, 56u8, 95u8, 246u8]; + 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 { + pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + implementation_index: { + 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.pool_implementation)), + ethabi::Token::Uint(ethabi::Uint::from_big_endian( + match self + .implementation_index + .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 SetPoolImplementation { + const NAME: &'static str = "set_pool_implementation"; + 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 SetViewsImplementation { + pub views_implementation: Vec, + } + impl SetViewsImplementation { + const METHOD_ID: [u8; 4] = [246u8, 250u8, 147u8, 127u8]; + 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 { + views_implementation: 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.views_implementation, + ))]); + 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 SetViewsImplementation { + const NAME: &'static str = "set_views_implementation"; + 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 ViewsImplementation {} + impl ViewsImplementation { + const METHOD_ID: [u8; 4] = [227u8, 21u8, 147u8, 216u8]; + 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 } - 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::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_views_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_views_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for UpdateViewsImplementation { - const NAME: &'static str = "UpdateViewsImplementation"; - 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) - } + } + impl substreams_ethereum::Function for ViewsImplementation { + const NAME: &'static str = "views_implementation"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - } \ No newline at end of file + 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 ViewsImplementation { + fn output(data: &[u8]) -> Result, String> { + 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 LiquidityGaugeDeployed { + pub pool: Vec, + pub gauge: Vec, + } + impl LiquidityGaugeDeployed { + const TOPIC_ID: [u8; 32] = [ + 101u8, 107u8, 179u8, 76u8, 32u8, 73u8, 25u8, 112u8, 168u8, 193u8, 99u8, 243u8, 189u8, + 98u8, 234u8, 216u8, 32u8, 34u8, 179u8, 121u8, 195u8, 146u8, 73u8, 96u8, 236u8, 96u8, + 246u8, 219u8, 252u8, 90u8, 171u8, 59u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for LiquidityGaugeDeployed { + const NAME: &'static str = "LiquidityGaugeDeployed"; + 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 TransferOwnership { + pub old_owner: Vec, + pub new_owner: Vec, + } + impl TransferOwnership { + const TOPIC_ID: [u8; 32] = [ + 92u8, 72u8, 101u8, 40u8, 236u8, 62u8, 63u8, 14u8, 169u8, 17u8, 129u8, 207u8, 248u8, + 17u8, 111u8, 2u8, 191u8, 163u8, 80u8, 224u8, 59u8, 139u8, 111u8, 18u8, 224u8, 7u8, + 101u8, 173u8, 187u8, 90u8, 248u8, 92u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for TransferOwnership { + const NAME: &'static str = "TransferOwnership"; + 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 TwocryptoPoolDeployed { + pub pool: Vec, + pub name: String, + pub symbol: String, + pub coins: [Vec; 2usize], + pub math: Vec, + pub salt: [u8; 32usize], + pub precisions: [substreams::scalar::BigInt; 2usize], + pub packed_a_gamma: substreams::scalar::BigInt, + pub packed_fee_params: substreams::scalar::BigInt, + pub packed_rebalancing_params: substreams::scalar::BigInt, + pub packed_prices: substreams::scalar::BigInt, + pub deployer: Vec, + } + impl TwocryptoPoolDeployed { + const TOPIC_ID: [u8; 32] = [ + 129u8, 82u8, 163u8, 3u8, 126u8, 61u8, 197u8, 65u8, 84u8, 173u8, 13u8, 44u8, 173u8, + 177u8, 207u8, 126u8, 29u8, 27u8, 158u8, 43u8, 98u8, 95u8, 170u8, 61u8, 251u8, 79u8, + 224u8, 61u8, 96u8, 145u8, 2u8, 202u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() < 512usize { + 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::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray(Box::new(ethabi::ParamType::Address), 2usize), + ethabi::ParamType::Address, + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + coins: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_array() + .expect(INTERNAL_ERR) + .into_iter() + .map(|inner| { + inner + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec() + }); + [iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR)] + }, + math: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + salt: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + precisions: { + let mut iter = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_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) + }); + [iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR)] + }, + packed_a_gamma: { + 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) + }, + packed_fee_params: { + 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) + }, + packed_rebalancing_params: { + 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) + }, + packed_prices: { + 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) + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for TwocryptoPoolDeployed { + const NAME: &'static str = "TwocryptoPoolDeployed"; + 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 UpdateFeeReceiver { + pub old_fee_receiver: Vec, + pub new_fee_receiver: Vec, + } + impl UpdateFeeReceiver { + const TOPIC_ID: [u8; 32] = [ + 40u8, 97u8, 68u8, 134u8, 120u8, 240u8, 190u8, 103u8, 241u8, 27u8, 251u8, 84u8, 129u8, + 179u8, 227u8, 180u8, 207u8, 235u8, 58u8, 204u8, 97u8, 38u8, 173u8, 96u8, 160u8, 95u8, + 149u8, 191u8, 198u8, 83u8, 6u8, 102u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateFeeReceiver { + const NAME: &'static str = "UpdateFeeReceiver"; + 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 UpdateGaugeImplementation { + pub old_gauge_implementation: Vec, + pub new_gauge_implementation: Vec, + } + impl UpdateGaugeImplementation { + const TOPIC_ID: [u8; 32] = [ + 31u8, 215u8, 5u8, 249u8, 199u8, 112u8, 83u8, 150u8, 42u8, 80u8, 63u8, 47u8, 47u8, 87u8, + 240u8, 134u8, 43u8, 76u8, 58u8, 246u8, 135u8, 194u8, 86u8, 21u8, 193u8, 56u8, 23u8, + 168u8, 105u8, 70u8, 195u8, 89u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_gauge_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_gauge_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateGaugeImplementation { + const NAME: &'static str = "UpdateGaugeImplementation"; + 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 UpdateMathImplementation { + pub old_math_implementation: Vec, + pub new_math_implementation: Vec, + } + impl UpdateMathImplementation { + const TOPIC_ID: [u8; 32] = [ + 104u8, 254u8, 143u8, 195u8, 172u8, 118u8, 236u8, 23u8, 226u8, 17u8, 23u8, 223u8, 94u8, + 133u8, 76u8, 140u8, 37u8, 183u8, 181u8, 247u8, 118u8, 170u8, 210u8, 173u8, 201u8, 39u8, + 253u8, 209u8, 86u8, 188u8, 214u8, 222u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_math_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_math_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateMathImplementation { + const NAME: &'static str = "UpdateMathImplementation"; + 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 UpdatePoolImplementation { + pub implemention_id: substreams::scalar::BigInt, + pub old_pool_implementation: Vec, + pub new_pool_implementation: Vec, + } + impl UpdatePoolImplementation { + const TOPIC_ID: [u8; 32] = [ + 106u8, 66u8, 239u8, 150u8, 5u8, 225u8, 53u8, 175u8, 175u8, 106u8, 228u8, 243u8, 104u8, + 59u8, 22u8, 26u8, 59u8, 115u8, 105u8, 208u8, 124u8, 157u8, 82u8, 199u8, 1u8, 171u8, + 105u8, 85u8, 62u8, 4u8, 195u8, 182u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 96usize { + 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::Address, + ethabi::ParamType::Address, + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + implemention_id: { + 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) + }, + old_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdatePoolImplementation { + const NAME: &'static str = "UpdatePoolImplementation"; + 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 UpdateViewsImplementation { + pub old_views_implementation: Vec, + pub new_views_implementation: Vec, + } + impl UpdateViewsImplementation { + const TOPIC_ID: [u8; 32] = [ + 216u8, 78u8, 177u8, 234u8, 112u8, 205u8, 164u8, 10u8, 107u8, 250u8, 161u8, 31u8, 79u8, + 105u8, 239u8, 161u8, 12u8, 188u8, 94u8, 184u8, 39u8, 96u8, 179u8, 5u8, 143u8, 68u8, + 5u8, 18u8, 236u8, 29u8, 109u8, 31u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Address], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_views_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_views_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateViewsImplementation { + const NAME: &'static str = "UpdateViewsImplementation"; + 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) + } + } +}