From 6989bfbeeebadc3df08af8cf81e0fc093f4f691e Mon Sep 17 00:00:00 2001 From: jmulq Date: Mon, 22 Apr 2024 16:37:10 +0100 Subject: [PATCH 1/5] fix: ETH withdraw one + bump substream ethereum to 0.9.11 --- Cargo.lock | 16 +- src/abi/common/erc20.rs | 17474 ++++++------ src/abi/curve/address_provider.rs | 3346 ++- .../child_registries/base_pool_registry.rs | 3819 ++- .../child_registries/crv_usd_pool_factory.rs | 12500 ++++----- .../crypto_pool_factory_v2.rs | 6536 +++-- .../crypto_swap_registry_old.rs | 6919 +++-- .../crypto_swap_registry_v2.rs | 8936 +++--- .../child_registries/metapool_factory_old.rs | 6212 ++--- .../child_registries/pool_registry_v1.rs | 12241 ++++---- .../child_registries/pool_registry_v1_old.rs | 10648 ++++--- .../child_registries/pool_registry_v2_old.rs | 8110 +++--- .../stable_swap_factory_ng.rs | 11324 ++++---- .../child_registries/tricrypto_factory_ng.rs | 6985 +++-- .../child_registries/twocrypto_factory.rs | 7053 +++-- src/abi/curve/crv_token.rs | 5272 ++-- src/abi/curve/gauge_controller.rs | 9076 +++--- src/abi/curve/gauges/liquidity_gauge_v1.rs | 5224 ++-- src/abi/curve/gauges/liquidity_gauge_v2.rs | 10576 ++++--- src/abi/curve/gauges/liquidity_gauge_v3.rs | 11366 ++++---- src/abi/curve/gauges/liquidity_gauge_v4.rs | 10633 ++++--- src/abi/curve/gauges/liquidity_gauge_v5.rs | 11568 ++++---- src/abi/curve/gauges/liquidity_gauge_v6.rs | 12008 ++++---- .../curve/ownership_proxies/factory_owner.rs | 4113 ++- .../curve/ownership_proxies/gauge_manager.rs | 2062 +- .../ownership_proxies/gauge_manager_old.rs | 2062 +- .../ownership_proxies/stableswap_owner.rs | 7237 +++-- src/abi/curve/pool.rs | 23176 ++++++++-------- src/abi/curve/pools/lending_pool.rs | 13468 +++++---- src/abi/curve/pools/metapool_old.rs | 11362 ++++---- src/abi/curve/registry.rs | 13878 +++++---- src/abi/oracle/curve_calculations.rs | 2666 +- src/abi/oracle/inch.rs | 3043 +- src/abi/oracle/sushiswap.rs | 2501 +- src/abi/oracle/yearn_lens.rs | 2381 +- src/modules/5_map_extract_pool_events.rs | 42 +- 36 files changed, 139639 insertions(+), 146194 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab4c17a..99c27e4 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -812,9 +812,9 @@ dependencies = [ [[package]] name = "substreams-ethereum" -version = "0.9.9" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48f45dc04be50b7ca08d6d5c4560ee3eeba16ccaa1c124d0361bb30b5b84e28b" +checksum = "5ed942baf2eead40294676be39b00cd78ba71c3608686d91549801b44cf7b817" dependencies = [ "getrandom", "num-bigint", @@ -826,9 +826,9 @@ dependencies = [ [[package]] name = "substreams-ethereum-abigen" -version = "0.9.9" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c04307913a355aaf2a1bb7186d4bc7e36875f3d4aff77b47e83f1b63b24da55" +checksum = "fb962e39d1bbdee95c74dfb71ef0f75f8283d892a46f430733535116f5af96e1" dependencies = [ "anyhow", "ethabi", @@ -843,9 +843,9 @@ dependencies = [ [[package]] name = "substreams-ethereum-core" -version = "0.9.9" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db9048cc9a66873ab7069ef958c2684994e6ee323da49c186b19156fdb4ca131" +checksum = "faaa48bbf9a76cc1847d3b4df49dc3a9cc421038504f9449f8f50245c4d2cdc1" dependencies = [ "bigdecimal", "ethabi", @@ -859,9 +859,9 @@ dependencies = [ [[package]] name = "substreams-ethereum-derive" -version = "0.9.9" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e862928bee8653f5c9291ac619c8dc0da14ca61d8cd8d89b3acdbbde4d0bf304" +checksum = "3904b9d78bc958f813c66123b3996e9da5fe8bfa4e075d67cf25af709617b03a" dependencies = [ "ethabi", "heck", diff --git a/src/abi/common/erc20.rs b/src/abi/common/erc20.rs index 7751b20..647fec0 100644 --- a/src/abi/common/erc20.rs +++ b/src/abi/common/erc20.rs @@ -1,9481 +1,9101 @@ - 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 DomainSeparator {} - impl DomainSeparator { - const METHOD_ID: [u8; 4] = [54u8, 68u8, 229u8, 21u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result<[u8; 32usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::FixedBytes(32usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut result = [0u8; 32]; - let v = values - .pop() - .expect("one output data should have existed") - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } +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 DomainSeparator {} + impl DomainSeparator { + const METHOD_ID: [u8; 4] = [54u8, 68u8, 229u8, 21u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for DomainSeparator { - const NAME: &'static str = "DOMAIN_SEPARATOR"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for DomainSeparator { + const NAME: &'static str = "DOMAIN_SEPARATOR"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for DomainSeparator { - fn output(data: &[u8]) -> Result<[u8; 32usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AcceptGovernance {} - impl AcceptGovernance { - const METHOD_ID: [u8; 4] = [35u8, 142u8, 252u8, 188u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for DomainSeparator { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AcceptGovernance {} + impl AcceptGovernance { + const METHOD_ID: [u8; 4] = [35u8, 142u8, 252u8, 188u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 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 AcceptGovernance { + const NAME: &'static str = "acceptGovernance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Activation {} + impl Activation { + const METHOD_ID: [u8; 4] = [54u8, 41u8, 200u8, 222u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 AcceptGovernance { - const NAME: &'static str = "acceptGovernance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Activation {} - impl Activation { - const METHOD_ID: [u8; 4] = [54u8, 41u8, 200u8, 222u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + } + impl substreams_ethereum::Function for Activation { + const NAME: &'static str = "activation"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Activation { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddStrategy { + pub strategy: Vec, + pub debt_ratio: substreams::scalar::BigInt, + pub rate_limit: substreams::scalar::BigInt, + pub performance_fee: substreams::scalar::BigInt, + } + impl AddStrategy { + const METHOD_ID: [u8; 4] = [13u8, 210u8, 27u8, 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::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 { + strategy: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + debt_ratio: { 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 Activation { - const NAME: &'static str = "activation"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Activation { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AddStrategy { - pub strategy: Vec, - pub debt_ratio: substreams::scalar::BigInt, - pub rate_limit: substreams::scalar::BigInt, - pub performance_fee: substreams::scalar::BigInt, - } - impl AddStrategy { - const METHOD_ID: [u8; 4] = [13u8, 210u8, 27u8, 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::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 { - strategy: values + }, + rate_limit: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - debt_ratio: { - let mut v = [0 as u8; 32]; - values - .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_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) - }, - performance_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.strategy), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.debt_ratio.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + performance_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.strategy)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.debt_ratio.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.rate_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.rate_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.performance_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.performance_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(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for AddStrategy { - const NAME: &'static str = "addStrategy"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 AddStrategyToQueue { - pub strategy: Vec, + } + impl substreams_ethereum::Function for AddStrategy { + const NAME: &'static str = "addStrategy"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl AddStrategyToQueue { - const METHOD_ID: [u8; 4] = [247u8, 110u8, 76u8, 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 { - strategy: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + 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 AddStrategyToQueue { + pub strategy: Vec, + } + impl AddStrategyToQueue { + const METHOD_ID: [u8; 4] = [247u8, 110u8, 76u8, 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 { + strategy: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.strategy))], + ); + 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 encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.strategy), - ), - ], - ); - 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 AddStrategyToQueue { + const NAME: &'static str = "addStrategyToQueue"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Allowance { + pub arg0: Vec, + pub arg1: Vec, + } + impl Allowance { + const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 AddStrategyToQueue { - const NAME: &'static str = "addStrategyToQueue"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Allowance { + const NAME: &'static str = "allowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct Allowance { - pub arg0: Vec, - pub arg1: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable + for Allowance { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl Allowance { - const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct ApiVersion {} + impl ApiVersion { + const METHOD_ID: [u8; 4] = [37u8, 130u8, 148u8, 16u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - 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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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({ + } + } + impl substreams_ethereum::Function for ApiVersion { + const NAME: &'static str = "apiVersion"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for ApiVersion { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approve { + pub spender: Vec, + pub amount: substreams::scalar::BigInt, + } + impl Approve { + const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount: { let mut v = [0 as u8; 32]; values .pop() - .expect("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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Approve { + const NAME: &'static str = "approve"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Approve { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AvailableDepositLimit {} + impl AvailableDepositLimit { + const METHOD_ID: [u8; 4] = [21u8, 60u8, 39u8, 196u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Allowance { - const NAME: &'static str = "allowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for AvailableDepositLimit { + const NAME: &'static str = "availableDepositLimit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Allowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ApiVersion {} - impl ApiVersion { - const METHOD_ID: [u8; 4] = [37u8, 130u8, 148u8, 16u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AvailableDepositLimit { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BalanceOf { + pub arg0: Vec, + } + impl BalanceOf { + const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for BalanceOf { + const NAME: &'static str = "balanceOf"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for BalanceOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CreditAvailable1 {} + impl CreditAvailable1 { + const METHOD_ID: [u8; 4] = [17u8, 44u8, 31u8, 155u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 ApiVersion { - const NAME: &'static str = "apiVersion"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 CreditAvailable1 { + const NAME: &'static str = "creditAvailable1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for ApiVersion { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct Approve { - pub spender: Vec, - pub amount: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable + for CreditAvailable1 { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl Approve { - const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct CreditAvailable2 { + pub strategy: Vec, + } + impl CreditAvailable2 { + const METHOD_ID: [u8; 4] = [215u8, 100u8, 128u8, 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 { + strategy: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.strategy))], + ); + let mut encoded = Vec::with_capacity(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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + } + impl substreams_ethereum::Function for CreditAvailable2 { + const NAME: &'static str = "creditAvailable2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for CreditAvailable2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DebtOutstanding1 {} + impl DebtOutstanding1 { + const METHOD_ID: [u8; 4] = [191u8, 55u8, 89u8, 181u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for DebtOutstanding1 { + const NAME: &'static str = "debtOutstanding1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for DebtOutstanding1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DebtOutstanding2 { + pub strategy: Vec, + } + impl DebtOutstanding2 { + const METHOD_ID: [u8; 4] = [189u8, 207u8, 54u8, 187u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + strategy: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.strategy))], + ); + let mut encoded = Vec::with_capacity(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 Approve { - const NAME: &'static str = "approve"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for DebtOutstanding2 { + const NAME: &'static str = "debtOutstanding2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Approve { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AvailableDepositLimit {} - impl AvailableDepositLimit { - const METHOD_ID: [u8; 4] = [21u8, 60u8, 39u8, 196u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for DebtOutstanding2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DebtRatio {} + impl DebtRatio { + const METHOD_ID: [u8; 4] = [206u8, 165u8, 95u8, 87u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) + } + } + impl substreams_ethereum::Function for DebtRatio { + const NAME: &'static str = "debtRatio"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for DebtRatio { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Decimals {} + impl Decimals { + const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(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 + } } - 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({ + } + } + impl substreams_ethereum::Function for Decimals { + const NAME: &'static str = "decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Decimals { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DecreaseAllowance { + pub spender: Vec, + pub amount: substreams::scalar::BigInt, + } + impl DecreaseAllowance { + const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount: { let mut v = [0 as u8; 32]; values .pop() - .expect("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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for AvailableDepositLimit { - const NAME: &'static str = "availableDepositLimit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 DecreaseAllowance { + const NAME: &'static str = "decreaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AvailableDepositLimit { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct BalanceOf { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl BalanceOf { - const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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::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::rpc::RPCDecodable for DecreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit1 {} + impl Deposit1 { + const METHOD_ID: [u8; 4] = [208u8, 227u8, 13u8, 176u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for BalanceOf { - const NAME: &'static str = "balanceOf"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Deposit1 { + const NAME: &'static str = "deposit1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for BalanceOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CreditAvailable1 {} - impl CreditAvailable1 { - const METHOD_ID: [u8; 4] = [17u8, 44u8, 31u8, 155u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Deposit1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit2 { + pub u_amount: substreams::scalar::BigInt, + } + impl Deposit2 { + const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_amount: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::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 CreditAvailable1 { - const NAME: &'static str = "creditAvailable1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Deposit2 { + const NAME: &'static str = "deposit2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for CreditAvailable1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CreditAvailable2 { - pub strategy: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl CreditAvailable2 { - const METHOD_ID: [u8; 4] = [215u8, 100u8, 128u8, 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 { - strategy: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.strategy), - ), - ], - ); - let mut encoded = Vec::with_capacity(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({ + } + impl substreams_ethereum::rpc::RPCDecodable + for Deposit2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit3 { + pub u_amount: substreams::scalar::BigInt, + pub recipient: Vec, + } + impl Deposit3 { + const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amount: { 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 - } + }, + recipient: values + .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.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.recipient)), + ], + ); + let mut encoded = Vec::with_capacity(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 CreditAvailable2 { - const NAME: &'static str = "creditAvailable2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Deposit3 { + const NAME: &'static str = "deposit3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for CreditAvailable2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct DebtOutstanding1 {} - impl DebtOutstanding1 { - const METHOD_ID: [u8; 4] = [191u8, 55u8, 89u8, 181u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Deposit3 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DepositLimit {} + impl DepositLimit { + const METHOD_ID: [u8; 4] = [236u8, 247u8, 8u8, 88u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for DepositLimit { + const NAME: &'static str = "depositLimit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for DepositLimit { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct EmergencyShutdown {} + impl EmergencyShutdown { + const METHOD_ID: [u8; 4] = [52u8, 3u8, 194u8, 252u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn 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 DebtOutstanding1 { - const NAME: &'static str = "debtOutstanding1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 EmergencyShutdown { + const NAME: &'static str = "emergencyShutdown"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for DebtOutstanding1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct DebtOutstanding2 { - pub strategy: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl DebtOutstanding2 { - const METHOD_ID: [u8; 4] = [189u8, 207u8, 54u8, 187u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + impl substreams_ethereum::rpc::RPCDecodable for EmergencyShutdown { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ExpectedReturn1 {} + impl ExpectedReturn1 { + const METHOD_ID: [u8; 4] = [211u8, 64u8, 106u8, 189u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - strategy: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.strategy), - ), - ], - ); - let mut encoded = Vec::with_capacity(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, + } + } + impl substreams_ethereum::Function for ExpectedReturn1 { + const NAME: &'static str = "expectedReturn1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ExpectedReturn1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ExpectedReturn2 { + pub strategy: Vec, + } + impl ExpectedReturn2 { + const METHOD_ID: [u8; 4] = [51u8, 88u8, 107u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + strategy: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.strategy))], + ); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for ExpectedReturn2 { + const NAME: &'static str = "expectedReturn2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ExpectedReturn2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Governance {} + impl Governance { + const METHOD_ID: [u8; 4] = [90u8, 166u8, 230u8, 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 DebtOutstanding2 { - const NAME: &'static str = "debtOutstanding2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Governance { + const NAME: &'static str = "governance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for DebtOutstanding2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct DebtRatio {} - impl DebtRatio { - const METHOD_ID: [u8; 4] = [206u8, 165u8, 95u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Governance { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Guardian {} + impl Guardian { + const METHOD_ID: [u8; 4] = [69u8, 42u8, 147u8, 32u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 Guardian { + const NAME: &'static str = "guardian"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Guardian { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GuestList {} + impl GuestList { + const METHOD_ID: [u8; 4] = [70u8, 213u8, 88u8, 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 DebtRatio { - const NAME: &'static str = "debtRatio"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GuestList { + const NAME: &'static str = "guestList"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for DebtRatio { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Decimals {} - impl Decimals { - const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GuestList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IncreaseAllowance { + pub spender: Vec, + pub amount: substreams::scalar::BigInt, + } + impl IncreaseAllowance { + const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + impl substreams_ethereum::Function for IncreaseAllowance { + const NAME: &'static str = "increaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Initialize1 { + pub token: Vec, + pub governance: Vec, + pub rewards: Vec, + pub name_override: String, + pub symbol_override: String, + } + impl Initialize1 { + const METHOD_ID: [u8; 4] = [131u8, 180u8, 53u8, 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::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::String, + ethabi::ParamType::String, ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + 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(), + governance: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + name_override: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol_override: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.token)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.governance), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.rewards)), + ethabi::Token::String(self.name_override.clone()), + ethabi::Token::String(self.symbol_override.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 Decimals { - const NAME: &'static str = "decimals"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Initialize1 { + const NAME: &'static str = "initialize1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Decimals { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct DecreaseAllowance { - pub spender: Vec, - pub amount: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl DecreaseAllowance { - const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct Initialize2 { + pub token: Vec, + pub governance: Vec, + pub rewards: Vec, + pub name_override: String, + pub symbol_override: String, + pub guardian: Vec, + } + impl Initialize2 { + const METHOD_ID: [u8; 4] = [165u8, 184u8, 31u8, 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::Token::Address( - ethabi::Address::from_slice(&self.spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::String, + ethabi::ParamType::String, + ethabi::ParamType::Address, ], - ); - let mut encoded = Vec::with_capacity(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), + 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(), + governance: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + name_override: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + symbol_override: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + guardian: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.governance), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.rewards)), + ethabi::Token::String(self.name_override.clone()), + ethabi::Token::String(self.symbol_override.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.guardian)), + ], + ); + 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 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 Initialize2 { + const NAME: &'static str = "initialize2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LastReport {} + impl LastReport { + const METHOD_ID: [u8; 4] = [195u8, 83u8, 91u8, 82u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for LastReport { + const NAME: &'static str = "lastReport"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for LastReport { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Management {} + impl Management { + const METHOD_ID: [u8; 4] = [136u8, 168u8, 214u8, 2u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for DecreaseAllowance { - const NAME: &'static str = "decreaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Management { + const NAME: &'static str = "management"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit1 {} - impl Deposit1 { - const METHOD_ID: [u8; 4] = [208u8, 227u8, 13u8, 176u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Management { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ManagementFee {} + impl ManagementFee { + const METHOD_ID: [u8; 4] = [166u8, 247u8, 245u8, 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 { + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for ManagementFee { + const NAME: &'static str = "managementFee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ManagementFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MaxAvailableShares {} + impl MaxAvailableShares { + const METHOD_ID: [u8; 4] = [117u8, 222u8, 41u8, 2u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 Deposit1 { - const NAME: &'static str = "deposit1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + } + impl substreams_ethereum::Function for MaxAvailableShares { + const NAME: &'static str = "maxAvailableShares"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for MaxAvailableShares { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MigrateStrategy { + pub old_version: Vec, + pub new_version: Vec, + } + impl MigrateStrategy { + const METHOD_ID: [u8; 4] = [108u8, 181u8, 109u8, 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, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + old_version: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_version: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.old_version), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.new_version), + ), + ], + ); + 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 MigrateStrategy { + const NAME: &'static str = "migrateStrategy"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Minter {} + impl Minter { + const METHOD_ID: [u8; 4] = [7u8, 84u8, 97u8, 114u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } } - fn encode(&self) -> Vec { - self.encode() + } + } + impl substreams_ethereum::Function for Minter { + const NAME: &'static str = "minter"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Minter { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Name {} + impl Name { + const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } } } - impl substreams_ethereum::rpc::RPCDecodable - for Deposit1 { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for Name { + const NAME: &'static str = "name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Name { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Nonces { + pub arg0: Vec, + } + impl Nonces { + const METHOD_ID: [u8; 4] = [126u8, 206u8, 190u8, 0u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + 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::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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit2 { - pub u_amount: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for Nonces { + const NAME: &'static str = "nonces"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Nonces { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl Deposit2 { - const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 PerformanceFee {} + impl PerformanceFee { + const METHOD_ID: [u8; 4] = [135u8, 120u8, 135u8, 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 { + 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 } - 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 { - u_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for PerformanceFee { + const NAME: &'static str = "performanceFee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for PerformanceFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Permit { + pub owner: Vec, + pub spender: Vec, + pub amount: substreams::scalar::BigInt, + pub expiry: substreams::scalar::BigInt, + pub signature: Vec, + } + impl Permit { + const METHOD_ID: [u8; 4] = [159u8, 213u8, 166u8, 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::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bytes, ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + amount: { 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, + }, + expiry: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + signature: 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.owner)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.expiry.clone().to_bytes_be() { + (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.signature.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 { + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Permit { + const NAME: &'static str = "permit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Permit { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PricePerShare {} + impl PricePerShare { + const METHOD_ID: [u8; 4] = [153u8, 83u8, 11u8, 6u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 Deposit2 { - const NAME: &'static str = "deposit2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 PricePerShare { + const NAME: &'static str = "pricePerShare"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::rpc::RPCDecodable - for Deposit2 { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::rpc::RPCDecodable + for PricePerShare { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveStrategyFromQueue { + pub strategy: Vec, + } + impl RemoveStrategyFromQueue { + const METHOD_ID: [u8; 4] = [178u8, 36u8, 57u8, 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 { + strategy: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.strategy))], + ); + 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 Deposit3 { - pub u_amount: substreams::scalar::BigInt, - pub recipient: Vec, + } + impl substreams_ethereum::Function for RemoveStrategyFromQueue { + const NAME: &'static str = "removeStrategyFromQueue"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl Deposit3 { - const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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) - }, - recipient: values + 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 Report { + pub gain: substreams::scalar::BigInt, + pub loss: substreams::scalar::BigInt, + pub u_debt_payment: substreams::scalar::BigInt, + } + impl Report { + const METHOD_ID: [u8; 4] = [161u8, 217u8, 186u8, 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::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 { + gain: { + 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::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.recipient), - ), - ], - ); - let mut encoded = Vec::with_capacity(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({ + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + loss: { 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 Deposit3 { - const NAME: &'static str = "deposit3"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Deposit3 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DepositLimit {} - impl DepositLimit { - const METHOD_ID: [u8; 4] = [236u8, 247u8, 8u8, 88u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + u_debt_payment: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.gain.clone().to_bytes_be() { + (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.loss.clone().to_bytes_be() { + (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.u_debt_payment.clone().to_bytes_be() { + (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 DepositLimit { - const NAME: &'static str = "depositLimit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Report { + const NAME: &'static str = "report"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for DepositLimit { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct EmergencyShutdown {} - impl EmergencyShutdown { - const METHOD_ID: [u8; 4] = [52u8, 3u8, 194u8, 252u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Report { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RevokeStrategy1 {} + impl RevokeStrategy1 { + const METHOD_ID: [u8; 4] = [160u8, 228u8, 175u8, 154u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 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), + } + } + impl substreams_ethereum::Function for RevokeStrategy1 { + const NAME: &'static str = "revokeStrategy1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 RevokeStrategy2 { + pub strategy: Vec, + } + impl RevokeStrategy2 { + const METHOD_ID: [u8; 4] = [187u8, 153u8, 77u8, 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::Address], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + strategy: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.strategy))], + ); + 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for RevokeStrategy2 { + const NAME: &'static str = "revokeStrategy2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Rewards {} + impl Rewards { + const METHOD_ID: [u8; 4] = [158u8, 197u8, 168u8, 148u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for EmergencyShutdown { - const NAME: &'static str = "emergencyShutdown"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Rewards { + const NAME: &'static str = "rewards"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for EmergencyShutdown { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ExpectedReturn1 {} - impl ExpectedReturn1 { - const METHOD_ID: [u8; 4] = [211u8, 64u8, 106u8, 189u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Rewards { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetDepositLimit { + pub limit: substreams::scalar::BigInt, + } + impl SetDepositLimit { + const METHOD_ID: [u8; 4] = [189u8, 200u8, 20u8, 75u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + limit: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + 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(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for ExpectedReturn1 { - const NAME: &'static str = "expectedReturn1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 ExpectedReturn1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for SetDepositLimit { + const NAME: &'static str = "setDepositLimit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ExpectedReturn2 { - pub strategy: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl ExpectedReturn2 { - const METHOD_ID: [u8; 4] = [51u8, 88u8, 107u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - strategy: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetEmergencyShutdown { + pub active: bool, + } + impl SetEmergencyShutdown { + const METHOD_ID: [u8; 4] = [20u8, 198u8, 68u8, 2u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + active: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ethabi::Token::Bool(self.active.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, } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.strategy), - ), - ], - ); - let mut encoded = Vec::with_capacity(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({ + } + } + impl substreams_ethereum::Function for SetEmergencyShutdown { + const NAME: &'static str = "setEmergencyShutdown"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetGovernance { + pub governance: Vec, + } + impl SetGovernance { + const METHOD_ID: [u8; 4] = [171u8, 3u8, 62u8, 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 { + governance: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.governance))], + ); + 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 SetGovernance { + const NAME: &'static str = "setGovernance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetGuardian { + pub guardian: Vec, + } + impl SetGuardian { + const METHOD_ID: [u8; 4] = [138u8, 13u8, 172u8, 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 { + guardian: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.guardian))], + ); + 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 SetGuardian { + const NAME: &'static str = "setGuardian"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetGuestList { + pub guest_list: Vec, + } + impl SetGuestList { + const METHOD_ID: [u8; 4] = [11u8, 91u8, 120u8, 235u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + guest_list: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.guest_list))], + ); + 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 SetGuestList { + const NAME: &'static str = "setGuestList"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetManagement { + pub management: Vec, + } + impl SetManagement { + const METHOD_ID: [u8; 4] = [212u8, 162u8, 43u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + management: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.management))], + ); + 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 SetManagement { + const NAME: &'static str = "setManagement"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetManagementFee { + pub fee: substreams::scalar::BigInt, + } + impl SetManagementFee { + const METHOD_ID: [u8; 4] = [254u8, 86u8, 226u8, 50u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + fee: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + 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 } - impl substreams_ethereum::Function for ExpectedReturn2 { - const NAME: &'static str = "expectedReturn2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 ExpectedReturn2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for SetManagementFee { + const NAME: &'static str = "setManagementFee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Governance {} - impl Governance { - const METHOD_ID: [u8; 4] = [90u8, 166u8, 230u8, 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(), + 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 SetName { + pub name: String, + } + impl SetName { + const METHOD_ID: [u8; 4] = [196u8, 127u8, 0u8, 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::String], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .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), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[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 Governance { - const NAME: &'static str = "governance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 SetName { + const NAME: &'static str = "setName"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Governance { - 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 Guardian {} - impl Guardian { - const METHOD_ID: [u8; 4] = [69u8, 42u8, 147u8, 32u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetPerformanceFee { + pub fee: substreams::scalar::BigInt, + } + impl SetPerformanceFee { + const METHOD_ID: [u8; 4] = [112u8, 137u8, 123u8, 35u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + fee: { + 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.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 } - impl substreams_ethereum::Function for Guardian { - const NAME: &'static str = "guardian"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 Guardian { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + } + impl substreams_ethereum::Function for SetPerformanceFee { + const NAME: &'static str = "setPerformanceFee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GuestList {} - impl GuestList { - const METHOD_ID: [u8; 4] = [70u8, 213u8, 88u8, 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(), + 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 SetRewards { + pub rewards: Vec, + } + impl SetRewards { + const METHOD_ID: [u8; 4] = [236u8, 56u8, 168u8, 98u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.rewards))], + ); + 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 GuestList { - const NAME: &'static str = "guestList"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 SetRewards { + const NAME: &'static str = "setRewards"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GuestList { - 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 IncreaseAllowance { - pub spender: Vec, - pub amount: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl IncreaseAllowance { - const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - 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) - }, - }) + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetSymbol { + pub symbol: String, + } + impl SetSymbol { + const METHOD_ID: [u8; 4] = [184u8, 76u8, 130u8, 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::String], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ethabi::Token::String(self.symbol.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, } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for SetSymbol { + const NAME: &'static str = "setSymbol"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetWithdrawalQueue { + pub queue: [Vec; 20usize], + } + impl SetWithdrawalQueue { + const METHOD_ID: [u8; 4] = [148u8, 20u8, 132u8, 21u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 20usize, ), ], - ); - let mut encoded = Vec::with_capacity(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), + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + queue: { + 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), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .queue + .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 } - impl substreams_ethereum::Function for IncreaseAllowance { - const NAME: &'static str = "increaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + pub fn 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 IncreaseAllowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for SetWithdrawalQueue { + const NAME: &'static str = "setWithdrawalQueue"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Initialize1 { - pub token: Vec, - pub governance: Vec, - pub rewards: Vec, - pub name_override: String, - pub symbol_override: String, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl Initialize1 { - const METHOD_ID: [u8; 4] = [131u8, 180u8, 53u8, 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::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::String, - ethabi::ParamType::String, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - token: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Strategies { + pub arg0: Vec, + } + impl Strategies { + const METHOD_ID: [u8; 4] = [57u8, 235u8, 248u8, 35u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - governance: 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - rewards: 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - name_override: 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_string() - .expect(INTERNAL_ERR), - symbol_override: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.token)), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.governance), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.rewards), - ), - ethabi::Token::String(self.name_override.clone()), - ethabi::Token::String(self.symbol_override.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 Initialize1 { - const NAME: &'static str = "initialize1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Initialize2 { - pub token: Vec, - pub governance: Vec, - pub rewards: Vec, - pub name_override: String, - pub symbol_override: String, - pub guardian: Vec, - } - impl Initialize2 { - const METHOD_ID: [u8; 4] = [165u8, 184u8, 31u8, 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, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::String, - ethabi::ParamType::String, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - token: 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - governance: 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - rewards: 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - name_override: 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_string() - .expect(INTERNAL_ERR), - symbol_override: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - guardian: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.governance), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.rewards), - ), - ethabi::Token::String(self.name_override.clone()), - ethabi::Token::String(self.symbol_override.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.guardian), - ), - ], - ); - 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 Initialize2 { - const NAME: &'static str = "initialize2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LastReport {} - impl LastReport { - const METHOD_ID: [u8; 4] = [195u8, 83u8, 91u8, 82u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for LastReport { - const NAME: &'static str = "lastReport"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Strategies { + const NAME: &'static str = "strategies"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for LastReport { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Management {} - impl Management { - const METHOD_ID: [u8; 4] = [136u8, 168u8, 214u8, 2u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > for Strategies { + fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Sweep1 { + pub token: Vec, + } + impl Sweep1 { + const METHOD_ID: [u8; 4] = [1u8, 104u8, 26u8, 98u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.token))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } } - impl substreams_ethereum::Function for Management { - const NAME: &'static str = "management"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Sweep1 { + const NAME: &'static str = "sweep1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Management { - 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 ManagementFee {} - impl ManagementFee { - const METHOD_ID: [u8; 4] = [166u8, 247u8, 245u8, 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 { - 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({ + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Sweep2 { + pub token: Vec, + pub amount: substreams::scalar::BigInt, + } + impl Sweep2 { + const METHOD_ID: [u8; 4] = [110u8, 160u8, 86u8, 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, 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(), + amount: { 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 - } - } - } + }, + }) + } + 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.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for ManagementFee { - const NAME: &'static str = "managementFee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 ManagementFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Sweep2 { + const NAME: &'static str = "sweep2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct MaxAvailableShares {} - impl MaxAvailableShares { - const METHOD_ID: [u8; 4] = [117u8, 222u8, 41u8, 2u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Symbol {} + impl Symbol { + const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for MaxAvailableShares { - const NAME: &'static str = "maxAvailableShares"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Symbol { + const NAME: &'static str = "symbol"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for MaxAvailableShares { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct MigrateStrategy { - pub old_version: Vec, - pub new_version: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl MigrateStrategy { - const METHOD_ID: [u8; 4] = [108u8, 181u8, 109u8, 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, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - old_version: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_version: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.old_version), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.new_version), - ), - ], - ); - 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 Symbol { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Token {} + impl Token { + const METHOD_ID: [u8; 4] = [252u8, 12u8, 84u8, 106u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for MigrateStrategy { - const NAME: &'static str = "migrateStrategy"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Token { + const NAME: &'static str = "token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Minter {} - impl Minter { - const METHOD_ID: [u8; 4] = [7u8, 84u8, 97u8, 114u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Token { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TotalAssets {} + impl TotalAssets { + const METHOD_ID: [u8; 4] = [1u8, 225u8, 209u8, 20u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 Minter { - const NAME: &'static str = "minter"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 TotalAssets { + const NAME: &'static str = "totalAssets"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Minter { - 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 Name {} - impl Name { - const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalAssets { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TotalDebt {} + impl TotalDebt { + const METHOD_ID: [u8; 4] = [252u8, 123u8, 156u8, 24u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for TotalDebt { + const NAME: &'static str = "totalDebt"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalDebt { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TotalSupply {} + impl TotalSupply { + const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Name { - const NAME: &'static str = "name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for TotalSupply { + const NAME: &'static str = "totalSupply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Name { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Nonces { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl Nonces { - const METHOD_ID: [u8; 4] = [126u8, 206u8, 190u8, 0u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub receiver: Vec, + pub amount: substreams::scalar::BigInt, + } + impl Transfer { + const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + receiver: 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("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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.receiver)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Nonces { - const NAME: &'static str = "nonces"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Transfer { + const NAME: &'static str = "transfer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Nonces { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PerformanceFee {} - impl PerformanceFee { - const METHOD_ID: [u8; 4] = [135u8, 120u8, 135u8, 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 { - 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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Transfer { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferFrom { + pub sender: Vec, + pub receiver: Vec, + pub amount: substreams::scalar::BigInt, + } + impl TransferFrom { + const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + sender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + receiver: 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("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 - } + }, + }) + } + 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.receiver)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for PerformanceFee { - const NAME: &'static str = "performanceFee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 TransferFrom { + const NAME: &'static str = "transferFrom"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for PerformanceFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Permit { - pub owner: Vec, - pub spender: Vec, - pub amount: substreams::scalar::BigInt, - pub expiry: substreams::scalar::BigInt, - pub signature: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl Permit { - const METHOD_ID: [u8; 4] = [159u8, 213u8, 166u8, 207u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bytes, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - spender: values + } + impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateStrategyDebtRatio { + pub strategy: Vec, + pub debt_ratio: substreams::scalar::BigInt, + } + impl UpdateStrategyDebtRatio { + const METHOD_ID: [u8; 4] = [124u8, 106u8, 79u8, 36u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + strategy: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + debt_ratio: { + let mut v = [0 as u8; 32]; + 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) - }, - expiry: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - signature: values - .pop() + .into_uint() .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.owner)), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.expiry.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .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.strategy)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.debt_ratio.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Bytes(self.signature.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 { - 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 - } - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for Permit { - const NAME: &'static str = "permit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + pub fn 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 Permit { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for UpdateStrategyDebtRatio { + const NAME: &'static str = "updateStrategyDebtRatio"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PricePerShare {} - impl PricePerShare { - const METHOD_ID: [u8; 4] = [153u8, 83u8, 11u8, 6u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + 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 UpdateStrategyPerformanceFee { + pub strategy: Vec, + pub performance_fee: substreams::scalar::BigInt, + } + impl UpdateStrategyPerformanceFee { + const METHOD_ID: [u8; 4] = [208u8, 25u8, 78u8, 214u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + strategy: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + performance_fee: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.strategy)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.performance_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 } - impl substreams_ethereum::Function for PricePerShare { - const NAME: &'static str = "pricePerShare"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 PricePerShare { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for UpdateStrategyPerformanceFee { + const NAME: &'static str = "updateStrategyPerformanceFee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveStrategyFromQueue { - pub strategy: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl RemoveStrategyFromQueue { - const METHOD_ID: [u8; 4] = [178u8, 36u8, 57u8, 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 { - strategy: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateStrategyRateLimit { + pub strategy: Vec, + pub rate_limit: substreams::scalar::BigInt, + } + impl UpdateStrategyRateLimit { + const METHOD_ID: [u8; 4] = [98u8, 253u8, 188u8, 159u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + strategy: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + rate_limit: { + 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.strategy), + .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.strategy)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.rate_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(), ), - ], - ); - 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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for RemoveStrategyFromQueue { - const NAME: &'static str = "removeStrategyFromQueue"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 Report { - pub gain: substreams::scalar::BigInt, - pub loss: substreams::scalar::BigInt, - pub u_debt_payment: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for UpdateStrategyRateLimit { + const NAME: &'static str = "updateStrategyRateLimit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl Report { - const METHOD_ID: [u8; 4] = [161u8, 217u8, 186u8, 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()); + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw1 {} + impl Withdraw1 { + const METHOD_ID: [u8; 4] = [60u8, 207u8, 214u8, 11u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - let mut values = ethabi::decode( - &[ - 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 { - gain: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - loss: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_debt_payment: { - let mut v = [0 as u8; 32]; - values - .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.gain.clone().to_bytes_be() { - (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.loss.clone().to_bytes_be() { - (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.u_debt_payment.clone().to_bytes_be() { - (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({ + } + } + impl substreams_ethereum::Function for Withdraw1 { + const NAME: &'static str = "withdraw1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Withdraw1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw2 { + pub max_shares: substreams::scalar::BigInt, + } + impl Withdraw2 { + const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { + max_shares: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.max_shares.clone().to_bytes_be() { + (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 Report { - const NAME: &'static str = "report"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Report { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Withdraw2 { + const NAME: &'static str = "withdraw2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RevokeStrategy1 {} - impl RevokeStrategy1 { - const METHOD_ID: [u8; 4] = [160u8, 228u8, 175u8, 154u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 RevokeStrategy1 { - const NAME: &'static str = "revokeStrategy1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 RevokeStrategy2 { - pub strategy: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable + for Withdraw2 { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl RevokeStrategy2 { - const METHOD_ID: [u8; 4] = [187u8, 153u8, 77u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - strategy: values + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw3 { + pub max_shares: substreams::scalar::BigInt, + pub recipient: Vec, + } + impl Withdraw3 { + const METHOD_ID: [u8; 4] = [0u8, 247u8, 20u8, 206u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + max_shares: { + 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.strategy), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + recipient: values + .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.max_shares.clone().to_bytes_be() { + (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, + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.recipient)), + ], + ); + let mut encoded = Vec::with_capacity(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 RevokeStrategy2 { - const NAME: &'static str = "revokeStrategy2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Withdraw3 { + const NAME: &'static str = "withdraw3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Rewards {} - impl Rewards { - const METHOD_ID: [u8; 4] = [158u8, 197u8, 168u8, 148u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Withdraw3 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw4 { + pub max_shares: substreams::scalar::BigInt, + pub recipient: Vec, + pub max_loss: substreams::scalar::BigInt, + } + impl Withdraw4 { + const METHOD_ID: [u8; 4] = [230u8, 54u8, 151u8, 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::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 { + max_shares: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + recipient: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + max_loss: { + 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(), + .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.max_shares.clone().to_bytes_be() { + (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.recipient)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.max_loss.clone().to_bytes_be() { + (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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 Rewards { - const NAME: &'static str = "rewards"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Withdraw4 { + const NAME: &'static str = "withdraw4"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Rewards { - 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 SetDepositLimit { - pub limit: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl SetDepositLimit { - const METHOD_ID: [u8; 4] = [189u8, 200u8, 20u8, 75u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - 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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - 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") - } + } + impl substreams_ethereum::rpc::RPCDecodable + for Withdraw4 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct WithdrawalQueue { + pub arg0: substreams::scalar::BigInt, + } + impl WithdrawalQueue { + const METHOD_ID: [u8; 4] = [200u8, 34u8, 173u8, 218u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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(), - ), + } + .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, + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for SetDepositLimit { - const NAME: &'static str = "setDepositLimit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetEmergencyShutdown { - pub active: bool, + } + impl substreams_ethereum::Function for WithdrawalQueue { + const NAME: &'static str = "withdrawalQueue"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetEmergencyShutdown { - const METHOD_ID: [u8; 4] = [20u8, 198u8, 68u8, 2u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - active: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[ethabi::Token::Bool(self.active.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 decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for SetEmergencyShutdown { - const NAME: &'static str = "setEmergencyShutdown"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetGovernance { - pub governance: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for WithdrawalQueue { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl SetGovernance { - const METHOD_ID: [u8; 4] = [171u8, 3u8, 62u8, 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( + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct Approval { + pub owner: Vec, + pub spender: Vec, + pub value: substreams::scalar::BigInt, + } + impl Approval { + const TOPIC_ID: [u8; 32] = [ + 140u8, + 91u8, + 225u8, + 229u8, + 235u8, + 236u8, + 125u8, + 91u8, + 209u8, + 79u8, + 113u8, + 66u8, + 125u8, + 30u8, + 132u8, + 243u8, + 221u8, + 3u8, + 20u8, + 192u8, + 247u8, + 178u8, + 41u8, + 30u8, + 91u8, + 32u8, + 10u8, + 200u8, + 199u8, + 195u8, + 185u8, + 37u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + owner: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - governance: values + .map_err(|e| { + format!( + "unable to decode param 'owner' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + spender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'spender' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_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.governance), - ), - ], - ); - 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, - } - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Function for SetGovernance { - const NAME: &'static str = "setGovernance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Event for Approval { + const NAME: &'static str = "Approval"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetGuardian { - pub guardian: Vec, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl SetGuardian { - const METHOD_ID: [u8; 4] = [138u8, 13u8, 172u8, 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( + } + #[derive(Debug, Clone, PartialEq)] + pub struct EmergencyShutdown { + pub active: bool, + } + impl EmergencyShutdown { + const TOPIC_ID: [u8; 32] = [ + 186u8, + 64u8, + 55u8, + 42u8, + 58u8, + 114u8, + 77u8, + 202u8, + 60u8, + 87u8, + 21u8, + 97u8, + 40u8, + 239u8, + 30u8, + 137u8, + 103u8, + 36u8, + 182u8, + 91u8, + 55u8, + 161u8, + 127u8, + 25u8, + 11u8, + 26u8, + 213u8, + 222u8, + 104u8, + 243u8, + 164u8, + 243u8, + ]; + 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 { + active: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + } + impl substreams_ethereum::Event for EmergencyShutdown { + const NAME: &'static str = "EmergencyShutdown"; + 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 StrategyAdded { + pub strategy: Vec, + pub debt_ratio: substreams::scalar::BigInt, + pub rate_limit: substreams::scalar::BigInt, + pub performance_fee: substreams::scalar::BigInt, + } + impl StrategyAdded { + const TOPIC_ID: [u8; 32] = [ + 94u8, + 194u8, + 122u8, + 79u8, + 165u8, + 55u8, + 252u8, + 134u8, + 208u8, + 209u8, + 125u8, + 132u8, + 224u8, + 238u8, + 49u8, + 114u8, + 201u8, + 210u8, + 83u8, + 199u8, + 140u8, + 196u8, + 171u8, + 92u8, + 105u8, + 238u8, + 153u8, + 197u8, + 247u8, + 8u8, + 79u8, + 81u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + strategy: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - guardian: values + .map_err(|e| { + format!( + "unable to decode param 'strategy' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + debt_ratio: { + 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.guardian), - ), - ], - ); - 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 SetGuardian { - const NAME: &'static str = "setGuardian"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetGuestList { - pub guest_list: Vec, - } - impl SetGuestList { - const METHOD_ID: [u8; 4] = [11u8, 91u8, 120u8, 235u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - guest_list: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + rate_limit: { + 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.guest_list), - ), - ], - ); - 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 SetGuestList { - const NAME: &'static str = "setGuestList"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetManagement { - pub management: Vec, - } - impl SetManagement { - const METHOD_ID: [u8; 4] = [212u8, 162u8, 43u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - management: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + performance_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.management), - ), - ], - ); - 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 SetManagement { - const NAME: &'static str = "setManagement"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetManagementFee { - pub fee: substreams::scalar::BigInt, - } - impl SetManagementFee { - const METHOD_ID: [u8; 4] = [254u8, 86u8, 226u8, 50u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - fee: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.fee.clone().to_bytes_be() { - (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 SetManagementFee { - const NAME: &'static str = "setManagementFee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetName { - pub name: String, - } - impl SetName { - const METHOD_ID: [u8; 4] = [196u8, 127u8, 0u8, 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::String], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[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 SetName { - const NAME: &'static str = "setName"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetPerformanceFee { - pub fee: substreams::scalar::BigInt, - } - impl SetPerformanceFee { - const METHOD_ID: [u8; 4] = [112u8, 137u8, 123u8, 35u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - fee: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.fee.clone().to_bytes_be() { - (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, - } - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Function for SetPerformanceFee { - const NAME: &'static str = "setPerformanceFee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Event for StrategyAdded { + const NAME: &'static str = "StrategyAdded"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetRewards { - pub rewards: Vec, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl SetRewards { - const METHOD_ID: [u8; 4] = [236u8, 56u8, 168u8, 98u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct StrategyAddedToQueue { + pub strategy: Vec, + } + impl StrategyAddedToQueue { + const TOPIC_ID: [u8; 32] = [ + 168u8, + 114u8, + 125u8, + 65u8, + 44u8, + 111u8, + 161u8, + 226u8, + 73u8, + 125u8, + 109u8, + 111u8, + 39u8, + 94u8, + 45u8, + 159u8, + 228u8, + 217u8, + 49u8, + 141u8, + 91u8, + 121u8, + 54u8, + 50u8, + 230u8, + 10u8, + 217u8, + 211u8, + 142u8, + 232u8, + 241u8, + 250u8, + ]; + 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 { + strategy: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - rewards: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.rewards))], - ); - 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 SetRewards { - const NAME: &'static str = "setRewards"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetSymbol { - pub symbol: String, - } - impl SetSymbol { - const METHOD_ID: [u8; 4] = [184u8, 76u8, 130u8, 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::String], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[ethabi::Token::String(self.symbol.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 SetSymbol { - const NAME: &'static str = "setSymbol"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetWithdrawalQueue { - pub queue: [Vec; 20usize], - } - impl SetWithdrawalQueue { - const METHOD_ID: [u8; 4] = [148u8, 20u8, 132u8, 21u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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), - 20usize, - ), - ], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - queue: { - 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), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .queue - .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, - } - } + .map_err(|e| { + format!( + "unable to decode param 'strategy' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for SetWithdrawalQueue { - const NAME: &'static str = "setWithdrawalQueue"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Event for StrategyAddedToQueue { + const NAME: &'static str = "StrategyAddedToQueue"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct Strategies { - pub arg0: Vec, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl Strategies { - const METHOD_ID: [u8; 4] = [57u8, 235u8, 248u8, 35u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct StrategyMigrated { + pub old_version: Vec, + pub new_version: Vec, + } + impl StrategyMigrated { + const TOPIC_ID: [u8; 32] = [ + 16u8, + 11u8, + 105u8, + 187u8, + 107u8, + 80u8, + 78u8, + 18u8, + 82u8, + 227u8, + 107u8, + 55u8, + 82u8, + 51u8, + 21u8, + 142u8, + 222u8, + 230u8, + 77u8, + 7u8, + 27u8, + 57u8, + 158u8, + 47u8, + 129u8, + 71u8, + 58u8, + 105u8, + 95u8, + 209u8, + 176u8, + 33u8, + ]; + 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 { + old_version: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .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< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - data.as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'old_version' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_version: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call( - &self, - address: Vec, - ) -> Option< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - > { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| { + format!( + "unable to decode param 'new_version' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for Strategies { - const NAME: &'static str = "strategies"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Event for StrategyMigrated { + const NAME: &'static str = "StrategyMigrated"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - > for Strategies { - fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Sweep1 { - pub token: Vec, - } - impl Sweep1 { - const METHOD_ID: [u8; 4] = [1u8, 104u8, 26u8, 98u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct StrategyRemovedFromQueue { + pub strategy: Vec, + } + impl StrategyRemovedFromQueue { + const TOPIC_ID: [u8; 32] = [ + 142u8, + 30u8, + 195u8, + 193u8, + 109u8, + 106u8, + 103u8, + 234u8, + 142u8, + 255u8, + 226u8, + 172u8, + 122u8, + 222u8, + 249u8, + 194u8, + 222u8, + 11u8, + 192u8, + 220u8, + 71u8, + 196u8, + 156u8, + 223u8, + 24u8, + 246u8, + 168u8, + 176u8, + 4u8, + 128u8, + 133u8, + 190u8, + ]; + 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 { + strategy: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.token))], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } + .map_err(|e| { + format!( + "unable to decode param 'strategy' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for Sweep1 { - const NAME: &'static str = "sweep1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Event for StrategyRemovedFromQueue { + const NAME: &'static str = "StrategyRemovedFromQueue"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct Sweep2 { - pub token: Vec, - pub amount: substreams::scalar::BigInt, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl Sweep2 { - const METHOD_ID: [u8; 4] = [110u8, 160u8, 86u8, 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, 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(), - amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct StrategyReported { + pub strategy: Vec, + pub gain: substreams::scalar::BigInt, + pub loss: substreams::scalar::BigInt, + pub total_gain: substreams::scalar::BigInt, + pub total_loss: substreams::scalar::BigInt, + pub total_debt: substreams::scalar::BigInt, + pub debt_added: substreams::scalar::BigInt, + pub debt_ratio: substreams::scalar::BigInt, + } + impl StrategyReported { + const TOPIC_ID: [u8; 32] = [ + 47u8, + 182u8, + 17u8, + 250u8, + 244u8, + 139u8, + 29u8, + 27u8, + 145u8, + 237u8, + 187u8, + 163u8, + 76u8, + 238u8, + 16u8, + 198u8, + 53u8, + 122u8, + 222u8, + 228u8, + 16u8, + 84u8, + 14u8, + 74u8, + 143u8, + 122u8, + 130u8, + 182u8, + 179u8, + 134u8, + 115u8, + 228u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Token::Address(ethabi::Address::from_slice(&self.token)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), + 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), ], - ); - 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 Sweep2 { - const NAME: &'static str = "sweep2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Symbol {} - impl Symbol { - const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + log.data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Symbol { - const NAME: &'static str = "symbol"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for Symbol { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Token {} - impl Token { - const METHOD_ID: [u8; 4] = [252u8, 12u8, 84u8, 106u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + strategy: ethabi::decode( &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Token { - const NAME: &'static str = "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 Token { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TotalAssets {} - impl TotalAssets { - const METHOD_ID: [u8; 4] = [1u8, 225u8, 209u8, 20u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'strategy' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gain: { 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 TotalAssets { - const NAME: &'static str = "totalAssets"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for TotalAssets { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TotalDebt {} - impl TotalDebt { - const METHOD_ID: [u8; 4] = [252u8, 123u8, 156u8, 24u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + loss: { 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 TotalDebt { - const NAME: &'static str = "totalDebt"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for TotalDebt { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TotalSupply {} - impl TotalSupply { - const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut v = [0 as u8; 32]; - values - .pop() - .expect("one output data should have existed") - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for TotalSupply { - const NAME: &'static str = "totalSupply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for TotalSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub receiver: Vec, - pub amount: substreams::scalar::BigInt, - } - impl Transfer { - const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.receiver), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Transfer { - const NAME: &'static str = "transfer"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for Transfer { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferFrom { - pub sender: Vec, - pub receiver: Vec, - pub amount: substreams::scalar::BigInt, - } - impl TransferFrom { - const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - sender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.sender), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.receiver), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for TransferFrom { - const NAME: &'static str = "transferFrom"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateStrategyDebtRatio { - pub strategy: Vec, - pub debt_ratio: substreams::scalar::BigInt, - } - impl UpdateStrategyDebtRatio { - const METHOD_ID: [u8; 4] = [124u8, 106u8, 79u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - strategy: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - debt_ratio: { - let mut v = [0 as u8; 32]; - values - .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.strategy), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.debt_ratio.clone().to_bytes_be() { - (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 UpdateStrategyDebtRatio { - const NAME: &'static str = "updateStrategyDebtRatio"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 UpdateStrategyPerformanceFee { - pub strategy: Vec, - pub performance_fee: substreams::scalar::BigInt, - } - impl UpdateStrategyPerformanceFee { - const METHOD_ID: [u8; 4] = [208u8, 25u8, 78u8, 214u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - strategy: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - performance_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.strategy), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.performance_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 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 UpdateStrategyPerformanceFee { - const NAME: &'static str = "updateStrategyPerformanceFee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 UpdateStrategyRateLimit { - pub strategy: Vec, - pub rate_limit: substreams::scalar::BigInt, - } - impl UpdateStrategyRateLimit { - const METHOD_ID: [u8; 4] = [98u8, 253u8, 188u8, 159u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - strategy: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - rate_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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.strategy), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.rate_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(), - ), - ), - ], - ); - 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 UpdateStrategyRateLimit { - const NAME: &'static str = "updateStrategyRateLimit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Withdraw1 {} - impl Withdraw1 { - const METHOD_ID: [u8; 4] = [60u8, 207u8, 214u8, 11u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 Withdraw1 { - const NAME: &'static str = "withdraw1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Withdraw1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw2 { - pub max_shares: substreams::scalar::BigInt, - } - impl Withdraw2 { - const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { - max_shares: { - let mut v = [0 as u8; 32]; - values - .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.max_shares.clone().to_bytes_be() { - (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 Withdraw2 { - const NAME: &'static str = "withdraw2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Withdraw2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw3 { - pub max_shares: substreams::scalar::BigInt, - pub recipient: Vec, - } - impl Withdraw3 { - const METHOD_ID: [u8; 4] = [0u8, 247u8, 20u8, 206u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - max_shares: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - recipient: values - .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.max_shares.clone().to_bytes_be() { - (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.recipient), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 Withdraw3 { - const NAME: &'static str = "withdraw3"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Withdraw3 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw4 { - pub max_shares: substreams::scalar::BigInt, - pub recipient: Vec, - pub max_loss: substreams::scalar::BigInt, - } - impl Withdraw4 { - const METHOD_ID: [u8; 4] = [230u8, 54u8, 151u8, 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::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 { - max_shares: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - recipient: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - max_loss: { - let mut v = [0 as u8; 32]; - values - .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.max_shares.clone().to_bytes_be() { - (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.recipient), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.max_loss.clone().to_bytes_be() { - (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 Withdraw4 { - const NAME: &'static str = "withdraw4"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Withdraw4 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct WithdrawalQueue { - pub arg0: substreams::scalar::BigInt, - } - impl WithdrawalQueue { - const METHOD_ID: [u8; 4] = [200u8, 34u8, 173u8, 218u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 WithdrawalQueue { - const NAME: &'static str = "withdrawalQueue"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable> for WithdrawalQueue { - 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 Approval { - pub owner: Vec, - pub spender: Vec, - pub value: substreams::scalar::BigInt, - } - impl Approval { - const TOPIC_ID: [u8; 32] = [ - 140u8, - 91u8, - 225u8, - 229u8, - 235u8, - 236u8, - 125u8, - 91u8, - 209u8, - 79u8, - 113u8, - 66u8, - 125u8, - 30u8, - 132u8, - 243u8, - 221u8, - 3u8, - 20u8, - 192u8, - 247u8, - 178u8, - 41u8, - 30u8, - 91u8, - 32u8, - 10u8, - 200u8, - 199u8, - 195u8, - 185u8, - 37u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - owner: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'owner' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - spender: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'spender' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Approval { - const NAME: &'static str = "Approval"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct EmergencyShutdown { - pub active: bool, - } - impl EmergencyShutdown { - const TOPIC_ID: [u8; 32] = [ - 186u8, - 64u8, - 55u8, - 42u8, - 58u8, - 114u8, - 77u8, - 202u8, - 60u8, - 87u8, - 21u8, - 97u8, - 40u8, - 239u8, - 30u8, - 137u8, - 103u8, - 36u8, - 182u8, - 91u8, - 55u8, - 161u8, - 127u8, - 25u8, - 11u8, - 26u8, - 213u8, - 222u8, - 104u8, - 243u8, - 164u8, - 243u8, - ]; - 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 { - active: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - } - impl substreams_ethereum::Event for EmergencyShutdown { - const NAME: &'static str = "EmergencyShutdown"; - 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 StrategyAdded { - pub strategy: Vec, - pub debt_ratio: substreams::scalar::BigInt, - pub rate_limit: substreams::scalar::BigInt, - pub performance_fee: substreams::scalar::BigInt, - } - impl StrategyAdded { - const TOPIC_ID: [u8; 32] = [ - 94u8, - 194u8, - 122u8, - 79u8, - 165u8, - 55u8, - 252u8, - 134u8, - 208u8, - 209u8, - 125u8, - 132u8, - 224u8, - 238u8, - 49u8, - 114u8, - 201u8, - 210u8, - 83u8, - 199u8, - 140u8, - 196u8, - 171u8, - 92u8, - 105u8, - 238u8, - 153u8, - 197u8, - 247u8, - 8u8, - 79u8, - 81u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - strategy: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'strategy' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - debt_ratio: { - let mut v = [0 as u8; 32]; - values - .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_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) - }, - performance_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) - }, - }) - } - } - impl substreams_ethereum::Event for StrategyAdded { - const NAME: &'static str = "StrategyAdded"; - 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 StrategyAddedToQueue { - pub strategy: Vec, - } - impl StrategyAddedToQueue { - const TOPIC_ID: [u8; 32] = [ - 168u8, - 114u8, - 125u8, - 65u8, - 44u8, - 111u8, - 161u8, - 226u8, - 73u8, - 125u8, - 109u8, - 111u8, - 39u8, - 94u8, - 45u8, - 159u8, - 228u8, - 217u8, - 49u8, - 141u8, - 91u8, - 121u8, - 54u8, - 50u8, - 230u8, - 10u8, - 217u8, - 211u8, - 142u8, - 232u8, - 241u8, - 250u8, - ]; - 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 { - strategy: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'strategy' from topic of type 'address': {:?}", - e - ) - })? + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for StrategyAddedToQueue { - const NAME: &'static str = "StrategyAddedToQueue"; - 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 StrategyMigrated { - pub old_version: Vec, - pub new_version: Vec, - } - impl StrategyMigrated { - const TOPIC_ID: [u8; 32] = [ - 16u8, - 11u8, - 105u8, - 187u8, - 107u8, - 80u8, - 78u8, - 18u8, - 82u8, - 227u8, - 107u8, - 55u8, - 82u8, - 51u8, - 21u8, - 142u8, - 222u8, - 230u8, - 77u8, - 7u8, - 27u8, - 57u8, - 158u8, - 47u8, - 129u8, - 71u8, - 58u8, - 105u8, - 95u8, - 209u8, - 176u8, - 33u8, - ]; - 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 { - old_version: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'old_version' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + total_gain: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_version: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'new_version' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + total_loss: { + 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 StrategyMigrated { - const NAME: &'static str = "StrategyMigrated"; - 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 StrategyRemovedFromQueue { - pub strategy: Vec, - } - impl StrategyRemovedFromQueue { - const TOPIC_ID: [u8; 32] = [ - 142u8, - 30u8, - 195u8, - 193u8, - 109u8, - 106u8, - 103u8, - 234u8, - 142u8, - 255u8, - 226u8, - 172u8, - 122u8, - 222u8, - 249u8, - 194u8, - 222u8, - 11u8, - 192u8, - 220u8, - 71u8, - 196u8, - 156u8, - 223u8, - 24u8, - 246u8, - 168u8, - 176u8, - 4u8, - 128u8, - 133u8, - 190u8, - ]; - 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 { - strategy: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'strategy' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + total_debt: { + 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 StrategyRemovedFromQueue { - const NAME: &'static str = "StrategyRemovedFromQueue"; - 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 StrategyReported { - pub strategy: Vec, - pub gain: substreams::scalar::BigInt, - pub loss: substreams::scalar::BigInt, - pub total_gain: substreams::scalar::BigInt, - pub total_loss: substreams::scalar::BigInt, - pub total_debt: substreams::scalar::BigInt, - pub debt_added: substreams::scalar::BigInt, - pub debt_ratio: substreams::scalar::BigInt, - } - impl StrategyReported { - const TOPIC_ID: [u8; 32] = [ - 47u8, - 182u8, - 17u8, - 250u8, - 244u8, - 139u8, - 29u8, - 27u8, - 145u8, - 237u8, - 187u8, - 163u8, - 76u8, - 238u8, - 16u8, - 198u8, - 53u8, - 122u8, - 222u8, - 228u8, - 16u8, - 84u8, - 14u8, - 74u8, - 143u8, - 122u8, - 130u8, - 182u8, - 179u8, - 134u8, - 115u8, - 228u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::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), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - strategy: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'strategy' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + debt_added: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gain: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - loss: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - total_gain: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - total_loss: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - total_debt: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - debt_added: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - debt_ratio: { - let mut v = [0 as u8; 32]; - values - .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 StrategyReported { - const NAME: &'static str = "StrategyReported"; - 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 StrategyRevoked { - pub strategy: Vec, - } - impl StrategyRevoked { - const TOPIC_ID: [u8; 32] = [ - 66u8, - 1u8, - 198u8, - 136u8, - 216u8, - 76u8, - 1u8, - 21u8, - 77u8, - 50u8, - 26u8, - 250u8, - 12u8, - 114u8, - 241u8, - 191u8, - 254u8, - 158u8, - 239u8, - 83u8, - 0u8, - 92u8, - 157u8, - 233u8, - 208u8, - 53u8, - 7u8, - 78u8, - 113u8, - 233u8, - 179u8, - 42u8, - ]; - 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 { - strategy: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'strategy' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + debt_ratio: { + 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 StrategyRevoked { - const NAME: &'static str = "StrategyRevoked"; - 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 StrategyUpdateDebtRatio { - pub strategy: Vec, - pub debt_ratio: substreams::scalar::BigInt, - } - impl StrategyUpdateDebtRatio { - const TOPIC_ID: [u8; 32] = [ - 189u8, - 169u8, - 57u8, - 131u8, - 21u8, - 200u8, - 60u8, - 206u8, - 240u8, - 18u8, - 188u8, - 170u8, - 49u8, - 138u8, - 47u8, - 247u8, - 182u8, - 128u8, - 243u8, - 100u8, - 41u8, - 211u8, - 101u8, - 151u8, - 189u8, - 75u8, - 194u8, - 90u8, - 193u8, - 30u8, - 173u8, - 89u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for StrategyReported { + const NAME: &'static str = "StrategyReported"; + 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 StrategyRevoked { + pub strategy: Vec, + } + impl StrategyRevoked { + const TOPIC_ID: [u8; 32] = [ + 66u8, + 1u8, + 198u8, + 136u8, + 216u8, + 76u8, + 1u8, + 21u8, + 77u8, + 50u8, + 26u8, + 250u8, + 12u8, + 114u8, + 241u8, + 191u8, + 254u8, + 158u8, + 239u8, + 83u8, + 0u8, + 92u8, + 157u8, + 233u8, + 208u8, + 53u8, + 7u8, + 78u8, + 113u8, + 233u8, + 179u8, + 42u8, + ]; + 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 { + strategy: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - strategy: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'strategy' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'strategy' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - debt_ratio: { - let mut v = [0 as u8; 32]; - values - .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 StrategyUpdateDebtRatio { - const NAME: &'static str = "StrategyUpdateDebtRatio"; - 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 StrategyUpdatePerformanceFee { - pub strategy: Vec, - pub performance_fee: substreams::scalar::BigInt, - } - impl StrategyUpdatePerformanceFee { - const TOPIC_ID: [u8; 32] = [ - 229u8, - 116u8, - 136u8, - 166u8, - 95u8, - 165u8, - 48u8, - 102u8, - 212u8, - 194u8, - 91u8, - 172u8, - 144u8, - 219u8, - 71u8, - 221u8, - 164u8, - 229u8, - 222u8, - 48u8, - 37u8, - 172u8, - 18u8, - 191u8, - 118u8, - 255u8, - 7u8, - 33u8, - 28u8, - 247u8, - 243u8, - 158u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for StrategyRevoked { + const NAME: &'static str = "StrategyRevoked"; + 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 StrategyUpdateDebtRatio { + pub strategy: Vec, + pub debt_ratio: substreams::scalar::BigInt, + } + impl StrategyUpdateDebtRatio { + const TOPIC_ID: [u8; 32] = [ + 189u8, + 169u8, + 57u8, + 131u8, + 21u8, + 200u8, + 60u8, + 206u8, + 240u8, + 18u8, + 188u8, + 170u8, + 49u8, + 138u8, + 47u8, + 247u8, + 182u8, + 128u8, + 243u8, + 100u8, + 41u8, + 211u8, + 101u8, + 151u8, + 189u8, + 75u8, + 194u8, + 90u8, + 193u8, + 30u8, + 173u8, + 89u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + strategy: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - strategy: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'strategy' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'strategy' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + debt_ratio: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - performance_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) - }, - }) - } - } - impl substreams_ethereum::Event for StrategyUpdatePerformanceFee { - const NAME: &'static str = "StrategyUpdatePerformanceFee"; - 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 StrategyUpdateRateLimit { - pub strategy: Vec, - pub rate_limit: substreams::scalar::BigInt, - } - impl StrategyUpdateRateLimit { - const TOPIC_ID: [u8; 32] = [ - 252u8, - 14u8, - 20u8, - 90u8, - 233u8, - 236u8, - 11u8, - 17u8, - 127u8, - 207u8, - 82u8, - 162u8, - 172u8, - 15u8, - 163u8, - 9u8, - 210u8, - 137u8, - 110u8, - 159u8, - 241u8, - 158u8, - 106u8, - 120u8, - 157u8, - 28u8, - 32u8, - 244u8, - 37u8, - 178u8, - 67u8, - 234u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for StrategyUpdateDebtRatio { + const NAME: &'static str = "StrategyUpdateDebtRatio"; + 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 StrategyUpdatePerformanceFee { + pub strategy: Vec, + pub performance_fee: substreams::scalar::BigInt, + } + impl StrategyUpdatePerformanceFee { + const TOPIC_ID: [u8; 32] = [ + 229u8, + 116u8, + 136u8, + 166u8, + 95u8, + 165u8, + 48u8, + 102u8, + 212u8, + 194u8, + 91u8, + 172u8, + 144u8, + 219u8, + 71u8, + 221u8, + 164u8, + 229u8, + 222u8, + 48u8, + 37u8, + 172u8, + 18u8, + 191u8, + 118u8, + 255u8, + 7u8, + 33u8, + 28u8, + 247u8, + 243u8, + 158u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + strategy: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - strategy: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'strategy' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'strategy' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + performance_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - rate_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) - }, - }) - } - } - impl substreams_ethereum::Event for StrategyUpdateRateLimit { - const NAME: &'static str = "StrategyUpdateRateLimit"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub sender: Vec, - pub receiver: Vec, - pub value: substreams::scalar::BigInt, - } - impl Transfer { - const TOPIC_ID: [u8; 32] = [ - 221u8, - 242u8, - 82u8, - 173u8, - 27u8, - 226u8, - 200u8, - 155u8, - 105u8, - 194u8, - 176u8, - 104u8, - 252u8, - 55u8, - 141u8, - 170u8, - 149u8, - 43u8, - 167u8, - 241u8, - 99u8, - 196u8, - 161u8, - 22u8, - 40u8, - 245u8, - 90u8, - 77u8, - 245u8, - 35u8, - 179u8, - 239u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for StrategyUpdatePerformanceFee { + const NAME: &'static str = "StrategyUpdatePerformanceFee"; + 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 StrategyUpdateRateLimit { + pub strategy: Vec, + pub rate_limit: substreams::scalar::BigInt, + } + impl StrategyUpdateRateLimit { + const TOPIC_ID: [u8; 32] = [ + 252u8, + 14u8, + 20u8, + 90u8, + 233u8, + 236u8, + 11u8, + 17u8, + 127u8, + 207u8, + 82u8, + 162u8, + 172u8, + 15u8, + 163u8, + 9u8, + 210u8, + 137u8, + 110u8, + 159u8, + 241u8, + 158u8, + 106u8, + 120u8, + 157u8, + 28u8, + 32u8, + 244u8, + 37u8, + 178u8, + 67u8, + 234u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + strategy: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - sender: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].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(), - receiver: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'strategy' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'receiver' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + rate_limit: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Transfer { - const NAME: &'static str = "Transfer"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateDepositLimit { - pub deposit_limit: substreams::scalar::BigInt, - } - impl UpdateDepositLimit { - const TOPIC_ID: [u8; 32] = [ - 174u8, - 86u8, - 90u8, - 171u8, - 136u8, - 139u8, - 202u8, - 94u8, - 25u8, - 226u8, - 90u8, - 19u8, - 219u8, - 123u8, - 12u8, - 145u8, - 68u8, - 48u8, - 91u8, - 245u8, - 92u8, - 176u8, - 243u8, - 244u8, - 215u8, - 36u8, - 247u8, - 48u8, - 229u8, - 172u8, - 221u8, - 98u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for StrategyUpdateRateLimit { + const NAME: &'static str = "StrategyUpdateRateLimit"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub sender: Vec, + pub receiver: Vec, + pub value: substreams::scalar::BigInt, + } + impl Transfer { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 242u8, + 82u8, + 173u8, + 27u8, + 226u8, + 200u8, + 155u8, + 105u8, + 194u8, + 176u8, + 104u8, + 252u8, + 55u8, + 141u8, + 170u8, + 149u8, + 43u8, + 167u8, + 241u8, + 99u8, + 196u8, + 161u8, + 22u8, + 40u8, + 245u8, + 90u8, + 77u8, + 245u8, + 35u8, + 179u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + sender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - deposit_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) - }, - }) - } - } - impl substreams_ethereum::Event for UpdateDepositLimit { - const NAME: &'static str = "UpdateDepositLimit"; - 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 UpdateGovernance { - pub governance: Vec, - } - impl UpdateGovernance { - const TOPIC_ID: [u8; 32] = [ - 141u8, - 85u8, - 209u8, - 96u8, - 192u8, - 0u8, - 158u8, - 179u8, - 215u8, - 57u8, - 68u8, - 45u8, - 240u8, - 163u8, - 202u8, - 8u8, - 158u8, - 214u8, - 67u8, - 120u8, - 191u8, - 172u8, - 1u8, - 126u8, - 125u8, - 218u8, - 212u8, - 99u8, - 249u8, - 129u8, - 91u8, - 135u8, - ]; - 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( + .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(), + receiver: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - governance: values + .map_err(|e| { + format!( + "unable to decode param 'receiver' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for UpdateGovernance { - const NAME: &'static str = "UpdateGovernance"; - 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 UpdateGuardian { - pub guardian: Vec, - } - impl UpdateGuardian { - const TOPIC_ID: [u8; 32] = [ - 131u8, - 123u8, - 154u8, - 209u8, - 56u8, - 160u8, - 161u8, - 131u8, - 154u8, - 150u8, - 55u8, - 175u8, - 206u8, - 83u8, - 6u8, - 165u8, - 193u8, - 62u8, - 35u8, - 235u8, - 99u8, - 54u8, - 86u8, - 134u8, - 132u8, - 58u8, - 83u8, - 25u8, - 162u8, - 67u8, - 96u8, - 156u8, - ]; - 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 { - guardian: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Transfer { + const NAME: &'static str = "Transfer"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateDepositLimit { + pub deposit_limit: substreams::scalar::BigInt, + } + impl UpdateDepositLimit { + const TOPIC_ID: [u8; 32] = [ + 174u8, + 86u8, + 90u8, + 171u8, + 136u8, + 139u8, + 202u8, + 94u8, + 25u8, + 226u8, + 90u8, + 19u8, + 219u8, + 123u8, + 12u8, + 145u8, + 68u8, + 48u8, + 91u8, + 245u8, + 92u8, + 176u8, + 243u8, + 244u8, + 215u8, + 36u8, + 247u8, + 48u8, + 229u8, + 172u8, + 221u8, + 98u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + deposit_limit: { + 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 UpdateGuardian { - const NAME: &'static str = "UpdateGuardian"; - 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 UpdateGuestList { - pub guest_list: Vec, - } - impl UpdateGuestList { - const TOPIC_ID: [u8; 32] = [ - 109u8, - 103u8, - 76u8, - 49u8, - 19u8, - 41u8, - 251u8, - 56u8, - 187u8, - 201u8, - 109u8, - 195u8, - 61u8, - 42u8, - 173u8, - 3u8, - 185u8, - 191u8, - 159u8, - 207u8, - 221u8, - 143u8, - 94u8, - 80u8, - 84u8, - 253u8, - 162u8, - 145u8, - 165u8, - 179u8, - 193u8, - 248u8, - ]; - 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 { - guest_list: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for UpdateDepositLimit { + const NAME: &'static str = "UpdateDepositLimit"; + 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 UpdateGovernance { + pub governance: Vec, + } + impl UpdateGovernance { + const TOPIC_ID: [u8; 32] = [ + 141u8, + 85u8, + 209u8, + 96u8, + 192u8, + 0u8, + 158u8, + 179u8, + 215u8, + 57u8, + 68u8, + 45u8, + 240u8, + 163u8, + 202u8, + 8u8, + 158u8, + 214u8, + 67u8, + 120u8, + 191u8, + 172u8, + 1u8, + 126u8, + 125u8, + 218u8, + 212u8, + 99u8, + 249u8, + 129u8, + 91u8, + 135u8, + ]; + 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 { + governance: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateGovernance { + const NAME: &'static str = "UpdateGovernance"; + 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 UpdateGuardian { + pub guardian: Vec, + } + impl UpdateGuardian { + const TOPIC_ID: [u8; 32] = [ + 131u8, + 123u8, + 154u8, + 209u8, + 56u8, + 160u8, + 161u8, + 131u8, + 154u8, + 150u8, + 55u8, + 175u8, + 206u8, + 83u8, + 6u8, + 165u8, + 193u8, + 62u8, + 35u8, + 235u8, + 99u8, + 54u8, + 86u8, + 134u8, + 132u8, + 58u8, + 83u8, + 25u8, + 162u8, + 67u8, + 96u8, + 156u8, + ]; + 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 { + guardian: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateGuardian { + const NAME: &'static str = "UpdateGuardian"; + 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 UpdateGuestList { + pub guest_list: Vec, + } + impl UpdateGuestList { + const TOPIC_ID: [u8; 32] = [ + 109u8, + 103u8, + 76u8, + 49u8, + 19u8, + 41u8, + 251u8, + 56u8, + 187u8, + 201u8, + 109u8, + 195u8, + 61u8, + 42u8, + 173u8, + 3u8, + 185u8, + 191u8, + 159u8, + 207u8, + 221u8, + 143u8, + 94u8, + 80u8, + 84u8, + 253u8, + 162u8, + 145u8, + 165u8, + 179u8, + 193u8, + 248u8, + ]; + 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 { + guest_list: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateGuestList { + const NAME: &'static str = "UpdateGuestList"; + 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 UpdateManagement { + pub management: Vec, + } + impl UpdateManagement { + const TOPIC_ID: [u8; 32] = [ + 255u8, + 84u8, + 151u8, + 129u8, + 39u8, + 237u8, + 211u8, + 74u8, + 236u8, + 15u8, + 144u8, + 97u8, + 251u8, + 59u8, + 21u8, + 95u8, + 190u8, + 14u8, + 222u8, + 221u8, + 250u8, + 136u8, + 30u8, + 227u8, + 224u8, + 213u8, + 65u8, + 211u8, + 161u8, + 238u8, + 244u8, + 56u8, + ]; + 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 { + management: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateManagement { + const NAME: &'static str = "UpdateManagement"; + 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 UpdateManagementFee { + pub management_fee: substreams::scalar::BigInt, + } + impl UpdateManagementFee { + const TOPIC_ID: [u8; 32] = [ + 122u8, + 120u8, + 131u8, + 176u8, + 7u8, + 79u8, + 150u8, + 226u8, + 199u8, + 250u8, + 182u8, + 94u8, + 178u8, + 90u8, + 191u8, + 98u8, + 76u8, + 72u8, + 135u8, + 97u8, + 165u8, + 219u8, + 136u8, + 158u8, + 59u8, + 184u8, + 72u8, + 85u8, + 220u8, + 198u8, + 218u8, + 175u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + management_fee: { + 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 UpdateGuestList { - const NAME: &'static str = "UpdateGuestList"; - 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 UpdateManagement { - pub management: Vec, - } - impl UpdateManagement { - const TOPIC_ID: [u8; 32] = [ - 255u8, - 84u8, - 151u8, - 129u8, - 39u8, - 237u8, - 211u8, - 74u8, - 236u8, - 15u8, - 144u8, - 97u8, - 251u8, - 59u8, - 21u8, - 95u8, - 190u8, - 14u8, - 222u8, - 221u8, - 250u8, - 136u8, - 30u8, - 227u8, - 224u8, - 213u8, - 65u8, - 211u8, - 161u8, - 238u8, - 244u8, - 56u8, - ]; - 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 { - management: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for UpdateManagementFee { + const NAME: &'static str = "UpdateManagementFee"; + 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 UpdatePerformanceFee { + pub performance_fee: substreams::scalar::BigInt, + } + impl UpdatePerformanceFee { + const TOPIC_ID: [u8; 32] = [ + 8u8, + 16u8, + 161u8, + 194u8, + 97u8, + 202u8, + 44u8, + 12u8, + 216u8, + 106u8, + 1u8, + 82u8, + 197u8, + 28u8, + 67u8, + 186u8, + 157u8, + 195u8, + 41u8, + 99u8, + 157u8, + 35u8, + 73u8, + 249u8, + 129u8, + 64u8, + 137u8, + 27u8, + 46u8, + 167u8, + 152u8, + 235u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + performance_fee: { + 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 UpdateManagement { - const NAME: &'static str = "UpdateManagement"; - 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 UpdateManagementFee { - pub management_fee: substreams::scalar::BigInt, - } - impl UpdateManagementFee { - const TOPIC_ID: [u8; 32] = [ - 122u8, - 120u8, - 131u8, - 176u8, - 7u8, - 79u8, - 150u8, - 226u8, - 199u8, - 250u8, - 182u8, - 94u8, - 178u8, - 90u8, - 191u8, - 98u8, - 76u8, - 72u8, - 135u8, - 97u8, - 165u8, - 219u8, - 136u8, - 158u8, - 59u8, - 184u8, - 72u8, - 85u8, - 220u8, - 198u8, - 218u8, - 175u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - management_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) - }, - }) - } - } - impl substreams_ethereum::Event for UpdateManagementFee { - const NAME: &'static str = "UpdateManagementFee"; - 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 UpdatePerformanceFee { - pub performance_fee: substreams::scalar::BigInt, - } - impl UpdatePerformanceFee { - const TOPIC_ID: [u8; 32] = [ - 8u8, - 16u8, - 161u8, - 194u8, - 97u8, - 202u8, - 44u8, - 12u8, - 216u8, - 106u8, - 1u8, - 82u8, - 197u8, - 28u8, - 67u8, - 186u8, - 157u8, - 195u8, - 41u8, - 99u8, - 157u8, - 35u8, - 73u8, - 249u8, - 129u8, - 64u8, - 137u8, - 27u8, - 46u8, - 167u8, - 152u8, - 235u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - performance_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) - }, - }) - } - } - impl substreams_ethereum::Event for UpdatePerformanceFee { - const NAME: &'static str = "UpdatePerformanceFee"; - 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 UpdateRewards { - pub rewards: Vec, - } - impl UpdateRewards { - const TOPIC_ID: [u8; 32] = [ - 223u8, - 60u8, - 65u8, - 169u8, - 22u8, - 174u8, - 203u8, - 244u8, - 35u8, - 97u8, - 161u8, - 71u8, - 248u8, - 52u8, - 140u8, - 36u8, - 38u8, - 98u8, - 195u8, - 206u8, - 32u8, - 236u8, - 239u8, - 48u8, - 232u8, - 38u8, - 184u8, - 6u8, - 66u8, - 71u8, - 122u8, - 61u8, - ]; - 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 { - rewards: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for UpdatePerformanceFee { + const NAME: &'static str = "UpdatePerformanceFee"; + 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 UpdateRewards { + pub rewards: Vec, + } + impl UpdateRewards { + const TOPIC_ID: [u8; 32] = [ + 223u8, + 60u8, + 65u8, + 169u8, + 22u8, + 174u8, + 203u8, + 244u8, + 35u8, + 97u8, + 161u8, + 71u8, + 248u8, + 52u8, + 140u8, + 36u8, + 38u8, + 98u8, + 195u8, + 206u8, + 32u8, + 236u8, + 239u8, + 48u8, + 232u8, + 38u8, + 184u8, + 6u8, + 66u8, + 71u8, + 122u8, + 61u8, + ]; + 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 { + rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for UpdateRewards { + const NAME: &'static str = "UpdateRewards"; + 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 UpdateWithdrawalQueue { + pub queue: [Vec; 20usize], + } + impl UpdateWithdrawalQueue { + const TOPIC_ID: [u8; 32] = [ + 105u8, + 90u8, + 195u8, + 172u8, + 115u8, + 240u8, + 143u8, + 32u8, + 2u8, + 40u8, + 79u8, + 254u8, + 86u8, + 60u8, + 239u8, + 231u8, + 152u8, + 238u8, + 40u8, + 120u8, + 165u8, + 224u8, + 66u8, + 25u8, + 82u8, + 46u8, + 46u8, + 153u8, + 235u8, + 137u8, + 209u8, + 104u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 640usize { + 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), + 20usize, + ), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + queue: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for UpdateRewards { - const NAME: &'static str = "UpdateRewards"; - 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 UpdateWithdrawalQueue { - pub queue: [Vec; 20usize], - } - impl UpdateWithdrawalQueue { - const TOPIC_ID: [u8; 32] = [ - 105u8, - 90u8, - 195u8, - 172u8, - 115u8, - 240u8, - 143u8, - 32u8, - 2u8, - 40u8, - 79u8, - 254u8, - 86u8, - 60u8, - 239u8, - 231u8, - 152u8, - 238u8, - 40u8, - 120u8, - 165u8, - 224u8, - 66u8, - 25u8, - 82u8, - 46u8, - 46u8, - 153u8, - 235u8, - 137u8, - 209u8, - 104u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 640usize { - 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), - 20usize, - ), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - queue: { - 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), - ] - }, - }) - } + .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), + ] + }, + }) } - impl substreams_ethereum::Event for UpdateWithdrawalQueue { - const NAME: &'static str = "UpdateWithdrawalQueue"; - 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 UpdateWithdrawalQueue { + const NAME: &'static str = "UpdateWithdrawalQueue"; + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/address_provider.rs b/src/abi/curve/address_provider.rs index a52b558..a457dce 100644 --- a/src/abi/curve/address_provider.rs +++ b/src/abi/curve/address_provider.rs @@ -1,820 +1,776 @@ - 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 AddNewId { - pub u_address: Vec, - pub u_description: String, - } - impl AddNewId { - const METHOD_ID: [u8; 4] = [22u8, 143u8, 149u8, 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::String], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_description: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_address), - ), - ethabi::Token::String(self.u_description.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 { - 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 - } - } - } +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 AddNewId { + pub u_address: Vec, + pub u_description: String, + } + impl AddNewId { + const METHOD_ID: [u8; 4] = [22u8, 143u8, 149u8, 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::String], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_description: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) } - impl substreams_ethereum::Function for AddNewId { - const NAME: &'static str = "add_new_id"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address(ethabi::Address::from_slice(&self.u_address)), + ethabi::Token::String(self.u_description.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable - for AddNewId { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - #[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 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 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::Function for AddNewId { + const NAME: &'static str = "add_new_id"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Admin { - 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 ApplyTransferOwnership {} - impl ApplyTransferOwnership { - const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 { - 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 - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for ApplyTransferOwnership { - const NAME: &'static str = "apply_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::rpc::RPCDecodable + for AddNewId { + 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(), + ) } - impl substreams_ethereum::rpc::RPCDecodable for ApplyTransferOwnership { - fn output(data: &[u8]) -> Result { - Self::output(data) + pub fn 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 CommitTransferOwnership { - pub u_new_admin: 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()); + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 { - u_new_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.u_new_admin), - ), - ], - ); - let mut encoded = Vec::with_capacity(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::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 ApplyTransferOwnership {} + impl ApplyTransferOwnership { + const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 { + 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 - } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for ApplyTransferOwnership { + const NAME: &'static str = "apply_transfer_ownership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for CommitTransferOwnership { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[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(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for ApplyTransferOwnership { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitTransferOwnership { + pub u_new_admin: 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 { + u_new_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.u_new_admin))], + ); + let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for CommitTransferOwnership { + fn output(data: &[u8]) -> Result { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAddress { - pub u_id: substreams::scalar::BigInt, - } - impl GetAddress { - const METHOD_ID: [u8; 4] = [73u8, 63u8, 79u8, 116u8]; - pub fn decode( - call: &substreams_ethereum::pb::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::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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::Uint( - ethabi::Uint::from_big_endian( - match self.u_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( + } + } + 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 GetAddress { + pub u_id: substreams::scalar::BigInt, + } + impl GetAddress { + const METHOD_ID: [u8; 4] = [73u8, 63u8, 79u8, 116u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_id: { + 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) + }, + }) } - impl substreams_ethereum::Function for GetAddress { - const NAME: &'static str = "get_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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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()) } - impl substreams_ethereum::rpc::RPCDecodable> for GetAddress { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 GetIdInfo { - pub arg0: substreams::scalar::BigInt, - } - impl GetIdInfo { - const METHOD_ID: [u8; 4] = [146u8, 102u8, 142u8, 203u8]; - pub fn decode( - call: &substreams_ethereum::pb::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::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") - } + } + } + impl substreams_ethereum::Function for GetAddress { + const NAME: &'static str = "get_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 GetAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetIdInfo { + pub arg0: substreams::scalar::BigInt, + } + impl GetIdInfo { + const METHOD_ID: [u8; 4] = [146u8, 102u8, 142u8, 203u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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(), - ), + } + .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, - bool, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - String, - ), + ), + ], + ); + let mut encoded = Vec::with_capacity(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, + bool, + substreams::scalar::BigInt, + substreams::scalar::BigInt, String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ( - Vec, - bool, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - String, - ), + ), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + Vec, + bool, + substreams::scalar::BigInt, + substreams::scalar::BigInt, String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Bool, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::String, - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( + ), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Bool, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::String, + ], + 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_bool().expect(INTERNAL_ERR), + { + let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - 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) - }, - values.pop().expect(INTERNAL_ERR).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, - } + .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_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< - ( - Vec, - bool, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - String, - ), - > { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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< + ( + Vec, + bool, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + String, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetIdInfo { - const NAME: &'static str = "get_id_info"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetIdInfo { + const NAME: &'static str = "get_id_info"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable< + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + (Vec, bool, substreams::scalar::BigInt, substreams::scalar::BigInt, String), + > for GetIdInfo { + fn output( + data: &[u8], + ) -> Result< ( Vec, bool, @@ -822,1047 +778,989 @@ substreams::scalar::BigInt, String, ), - > for GetIdInfo { - fn output( - data: &[u8], - ) -> Result< - ( - Vec, - bool, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - String, - ), - String, - > { - Self::output(data) - } + String, + > { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetRegistry {} - impl GetRegistry { - const METHOD_ID: [u8; 4] = [162u8, 98u8, 144u8, 75u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRegistry {} + impl GetRegistry { + const METHOD_ID: [u8; 4] = [162u8, 98u8, 144u8, 75u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(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; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + } + 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 MaxId {} + impl MaxId { + const METHOD_ID: [u8; 4] = [12u8, 109u8, 120u8, 79u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 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::Function for MaxId { + const NAME: &'static str = "max_id"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetRegistry { - 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 MaxId {} - impl MaxId { - const METHOD_ID: [u8; 4] = [12u8, 109u8, 120u8, 79u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for MaxId { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RevertTransferOwnership {} + impl RevertTransferOwnership { + const METHOD_ID: [u8; 4] = [134u8, 251u8, 241u8, 147u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + } + impl substreams_ethereum::Function for RevertTransferOwnership { + const NAME: &'static str = "revert_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::rpc::RPCDecodable for RevertTransferOwnership { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetAddress { + pub u_id: substreams::scalar::BigInt, + pub u_address: Vec, + } + impl SetAddress { + const METHOD_ID: [u8; 4] = [106u8, 132u8, 202u8, 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::Uint(256usize), ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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 - } - } - } + }, + u_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for MaxId { - const NAME: &'static str = "max_id"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Uint( + ethabi::Uint::from_big_endian( + match self.u_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::Address(ethabi::Address::from_slice(&self.u_address)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable - for MaxId { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - #[derive(Debug, Clone, PartialEq)] - pub struct RevertTransferOwnership {} - impl RevertTransferOwnership { - const METHOD_ID: [u8; 4] = [134u8, 251u8, 241u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 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 - } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for RevertTransferOwnership { - const NAME: &'static str = "revert_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 SetAddress { + const NAME: &'static str = "set_address"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for RevertTransferOwnership { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetAddress { - pub u_id: substreams::scalar::BigInt, - pub u_address: Vec, - } - impl SetAddress { - const METHOD_ID: [u8; 4] = [106u8, 132u8, 202u8, 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::Uint(256usize), ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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) - }, - u_address: values - .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.u_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::Address( - ethabi::Address::from_slice(&self.u_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for SetAddress { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferOwnershipDeadline {} + impl TransferOwnershipDeadline { + const METHOD_ID: [u8; 4] = [224u8, 160u8, 181u8, 134u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 SetAddress { - const NAME: &'static str = "set_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::Function for TransferOwnershipDeadline { + const NAME: &'static str = "transfer_ownership_deadline"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for SetAddress { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferOwnershipDeadline {} - impl TransferOwnershipDeadline { - const METHOD_ID: [u8; 4] = [224u8, 160u8, 181u8, 134u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TransferOwnershipDeadline { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UnsetAddress { + pub u_id: substreams::scalar::BigInt, + } + impl UnsetAddress { + const METHOD_ID: [u8; 4] = [94u8, 236u8, 13u8, 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::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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 - } - } - } - } - impl substreams_ethereum::Function for TransferOwnershipDeadline { - const NAME: &'static str = "transfer_ownership_deadline"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for TransferOwnershipDeadline { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + }, + }) } - #[derive(Debug, Clone, PartialEq)] - pub struct UnsetAddress { - pub u_id: substreams::scalar::BigInt, - } - impl UnsetAddress { - const METHOD_ID: [u8; 4] = [94u8, 236u8, 13u8, 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::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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, - } + ), + ], + ); + let mut encoded = Vec::with_capacity(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 - } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for UnsetAddress { - const NAME: &'static str = "unset_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::Function for UnsetAddress { + const NAME: &'static str = "unset_address"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for UnsetAddress { - 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() } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct AddressModified { - pub id: substreams::scalar::BigInt, - pub new_address: Vec, - pub version: substreams::scalar::BigInt, - } - impl AddressModified { - const TOPIC_ID: [u8; 32] = [ - 231u8, - 166u8, - 51u8, - 76u8, - 79u8, - 87u8, - 62u8, - 253u8, - 242u8, - 146u8, - 212u8, - 4u8, - 213u8, - 154u8, - 218u8, - 206u8, - 195u8, - 69u8, - 244u8, - 247u8, - 199u8, - 100u8, - 149u8, - 160u8, - 52u8, - 0u8, - 142u8, - 221u8, - 160u8, - 172u8, - 239u8, - 71u8, - ]; - 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::Address, ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - id: { - 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 'id' 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) - }, - new_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - version: { - let mut v = [0 as u8; 32]; - values - .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::rpc::RPCDecodable for UnsetAddress { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::Event for AddressModified { - const NAME: &'static str = "AddressModified"; - 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) - } + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct AddressModified { + pub id: substreams::scalar::BigInt, + pub new_address: Vec, + pub version: substreams::scalar::BigInt, + } + impl AddressModified { + const TOPIC_ID: [u8; 32] = [ + 231u8, + 166u8, + 51u8, + 76u8, + 79u8, + 87u8, + 62u8, + 253u8, + 242u8, + 146u8, + 212u8, + 4u8, + 213u8, + 154u8, + 218u8, + 206u8, + 195u8, + 69u8, + 244u8, + 247u8, + 199u8, + 100u8, + 149u8, + 160u8, + 52u8, + 0u8, + 142u8, + 221u8, + 160u8, + 172u8, + 239u8, + 71u8, + ]; + 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 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(), + 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 { + id: { + 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 'admin' from topic of type 'address': {:?}", + "unable to decode param 'id' from topic of type 'uint256': {:?}", e ) })? .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) + }, + new_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + version: { + let mut v = [0 as u8; 32]; + values + .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 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) - } + } + impl substreams_ethereum::Event for AddressModified { + const NAME: &'static str = "AddressModified"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct NewAddressIdentifier { - pub id: substreams::scalar::BigInt, - pub addr: Vec, - pub description: String, - } - impl NewAddressIdentifier { - const TOPIC_ID: [u8; 32] = [ - 91u8, - 15u8, - 155u8, - 49u8, - 220u8, - 8u8, - 193u8, - 154u8, - 220u8, - 192u8, - 24u8, - 28u8, - 27u8, - 151u8, - 173u8, - 84u8, - 168u8, - 68u8, - 135u8, - 250u8, - 240u8, - 164u8, - 253u8, - 203u8, - 136u8, - 200u8, - 104u8, - 23u8, - 36u8, - 41u8, - 138u8, - 249u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::String], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - id: { - let mut v = [0 as u8; 32]; - ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.topics[1usize].as_ref(), + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[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 ) - .map_err(|e| { - format!( - "unable to decode param 'id' 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) - }, - addr: values + })? .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - description: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .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 NewAddressIdentifier { - const NAME: &'static str = "NewAddressIdentifier"; - 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 CommitNewAdmin { + const NAME: &'static str = "CommitNewAdmin"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(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], + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct NewAddressIdentifier { + pub id: substreams::scalar::BigInt, + pub addr: Vec, + pub description: String, + } + impl NewAddressIdentifier { + const TOPIC_ID: [u8; 32] = [ + 91u8, + 15u8, + 155u8, + 49u8, + 220u8, + 8u8, + 193u8, + 154u8, + 220u8, + 192u8, + 24u8, + 28u8, + 27u8, + 151u8, + 173u8, + 84u8, + 168u8, + 68u8, + 135u8, + 250u8, + 240u8, + 164u8, + 253u8, + 203u8, + 136u8, + 200u8, + 104u8, + 23u8, + 36u8, + 41u8, + 138u8, + 249u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::String], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + id: { + 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 'admin' from topic of type 'address': {:?}", + "unable to decode param 'id' from topic of type 'uint256': {:?}", e ) })? .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) + }, + addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + description: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) } - 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) - } + } + impl substreams_ethereum::Event for NewAddressIdentifier { + const NAME: &'static str = "NewAddressIdentifier"; + 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; } - } \ No newline at end of file + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/base_pool_registry.rs b/src/abi/curve/child_registries/base_pool_registry.rs index bdb3dc2..34c575a 100644 --- a/src/abi/curve/child_registries/base_pool_registry.rs +++ b/src/abi/curve/child_registries/base_pool_registry.rs @@ -1,2082 +1,1983 @@ - 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 AddBasePool { - pub u_pool: Vec, - pub u_lp_token: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_is_legacy: bool, - pub u_is_lending: bool, - pub u_is_v2: bool, - } - impl AddBasePool { - const METHOD_ID: [u8; 4] = [221u8, 27u8, 249u8, 23u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ethabi::ParamType::Bool, - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_lp_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_is_legacy: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - u_is_lending: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - u_is_v2: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 AddBasePool { + pub u_pool: Vec, + pub u_lp_token: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_is_legacy: bool, + pub u_is_lending: bool, + pub u_is_v2: bool, + } + impl AddBasePool { + const METHOD_ID: [u8; 4] = [221u8, 27u8, 249u8, 23u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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(), - ), - ), - ethabi::Token::Bool(self.u_is_legacy.clone()), - ethabi::Token::Bool(self.u_is_lending.clone()), - ethabi::Token::Bool(self.u_is_v2.clone()), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, + ethabi::ParamType::Bool, + ethabi::ParamType::Bool, ], - ); - 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 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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { 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 - } - } + }, + u_is_legacy: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + u_is_lending: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + u_is_v2: 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.u_pool)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), + ), + ), + ethabi::Token::Bool(self.u_is_legacy.clone()), + ethabi::Token::Bool(self.u_is_lending.clone()), + ethabi::Token::Bool(self.u_is_v2.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 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 AddBasePool { + const NAME: &'static str = "add_base_pool"; + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolList { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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(), + } + #[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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for BasePoolList { - 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 GetBasePoolForLpToken { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetBasePoolForLpToken { - const METHOD_ID: [u8; 4] = [145u8, 253u8, 136u8, 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], - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> 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::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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetBasePoolForLpToken { - const NAME: &'static str = "get_base_pool_for_lp_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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for GetBasePoolForLpToken { - 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 GetBasepoolForCoin1 { - pub u_coin: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetBasepoolForCoin1 { - const METHOD_ID: [u8; 4] = [17u8, 71u8, 96u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin))], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::rpc::RPCDecodable> for BasePoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasePoolForLpToken { + pub arg0: Vec, + } + impl GetBasePoolForLpToken { + const METHOD_ID: [u8; 4] = [145u8, 253u8, 136u8, 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], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 GetBasePoolForLpToken { + const NAME: &'static str = "get_base_pool_for_lp_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 GetBasePoolForLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasepoolForCoin1 { + pub u_coin: Vec, + } + impl GetBasepoolForCoin1 { + const METHOD_ID: [u8; 4] = [17u8, 71u8, 96u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetBasepoolForCoin1 { - const NAME: &'static str = "get_basepool_for_coin1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetBasepoolForCoin1 { + const NAME: &'static str = "get_basepool_for_coin1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetBasepoolForCoin1 { - 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 GetBasepoolForCoin2 { - pub u_coin: Vec, - pub u_idx: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl GetBasepoolForCoin2 { - const METHOD_ID: [u8; 4] = [213u8, 248u8, 199u8, 163u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_coin: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetBasepoolForCoin1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasepoolForCoin2 { + pub u_coin: Vec, + pub u_idx: substreams::scalar::BigInt, + } + impl GetBasepoolForCoin2 { + const METHOD_ID: [u8; 4] = [213u8, 248u8, 199u8, 163u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_idx: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_coin), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .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.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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 - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetBasepoolForCoin2 { - const NAME: &'static str = "get_basepool_for_coin2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetBasepoolForCoin2 { + const NAME: &'static str = "get_basepool_for_coin2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetBasepoolForCoin2 { - 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 GetBasepoolsForCoin { - pub u_coin: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetBasepoolsForCoin { - const METHOD_ID: [u8; 4] = [173u8, 135u8, 100u8, 66u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin))], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::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(), + } + impl substreams_ethereum::rpc::RPCDecodable> for GetBasepoolForCoin2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasepoolsForCoin { + pub u_coin: Vec, + } + impl GetBasepoolsForCoin { + const METHOD_ID: [u8; 4] = [173u8, 135u8, 100u8, 66u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option>> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::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 GetBasepoolsForCoin { - const NAME: &'static str = "get_basepools_for_coin"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetBasepoolsForCoin { + const NAME: &'static str = "get_basepools_for_coin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable>> - for GetBasepoolsForCoin { - 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 GetCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), } + } + impl substreams_ethereum::rpc::RPCDecodable>> for GetBasepoolsForCoin { + fn output(data: &[u8]) -> Result>, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins { + pub u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetCoins { + const NAME: &'static str = "get_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 8usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), } + } + impl substreams_ethereum::rpc::RPCDecodable<[Vec; 8usize]> for GetCoins { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetDecimals { + const NAME: &'static str = "get_decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLocation { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetLocation { - const METHOD_ID: [u8; 4] = [173u8, 246u8, 251u8, 138u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> + for GetDecimals { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLocation { + pub u_pool: Vec, + } + impl GetLocation { + const METHOD_ID: [u8; 4] = [173u8, 246u8, 251u8, 138u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 GetLocation { - const NAME: &'static str = "get_location"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetLocation { + const NAME: &'static str = "get_location"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetLocation { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLpToken { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetLpToken { - 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 { - u_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.u_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(), + } + impl substreams_ethereum::rpc::RPCDecodable + for GetLocation { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLpToken { + pub u_pool: Vec, + } + impl GetLpToken { + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 GetLpToken { - const NAME: &'static str = "get_lp_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::Function for GetLpToken { + const NAME: &'static str = "get_lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetLpToken { - 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 GetNCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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::rpc::RPCDecodable> for GetLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNCoins { + pub u_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 { + u_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.u_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::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) } - impl substreams_ethereum::rpc::RPCDecodable - for GetNCoins { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsLegacy { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl IsLegacy { - const METHOD_ID: [u8; 4] = [157u8, 82u8, 192u8, 182u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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), + } + impl substreams_ethereum::rpc::RPCDecodable + for GetNCoins { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsLegacy { + pub u_pool: Vec, + } + impl IsLegacy { + const METHOD_ID: [u8; 4] = [157u8, 82u8, 192u8, 182u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 IsLegacy { - const NAME: &'static str = "is_legacy"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IsLegacy { + const NAME: &'static str = "is_legacy"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsLegacy { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsLending { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl IsLending { - const METHOD_ID: [u8; 4] = [185u8, 255u8, 193u8, 238u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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), + } + impl substreams_ethereum::rpc::RPCDecodable for IsLegacy { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsLending { + pub u_pool: Vec, + } + impl IsLending { + const METHOD_ID: [u8; 4] = [185u8, 255u8, 193u8, 238u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 IsLending { - const NAME: &'static str = "is_lending"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IsLending { + const NAME: &'static str = "is_lending"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsLending { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsV2 { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl IsV2 { - const METHOD_ID: [u8; 4] = [198u8, 223u8, 24u8, 211u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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), + } + impl substreams_ethereum::rpc::RPCDecodable for IsLending { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsV2 { + pub u_pool: Vec, + } + impl IsV2 { + const METHOD_ID: [u8; 4] = [198u8, 223u8, 24u8, 211u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 IsV2 { - const NAME: &'static str = "is_v2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IsV2 { + const NAME: &'static str = "is_v2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsV2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct LastUpdated {} - impl LastUpdated { - const METHOD_ID: [u8; 4] = [104u8, 144u8, 9u8, 97u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 - } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IsV2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct LastUpdated {} + impl LastUpdated { + const METHOD_ID: [u8; 4] = [104u8, 144u8, 9u8, 97u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 LastUpdated { - const NAME: &'static str = "last_updated"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 LastUpdated { + const NAME: &'static str = "last_updated"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for LastUpdated { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable - for LastUpdated { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveBasePool { + pub u_pool: Vec, + } + impl RemoveBasePool { + const METHOD_ID: [u8; 4] = [242u8, 214u8, 215u8, 224u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_pool))], + ); + 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 RemoveBasePool { - pub u_pool: Vec, + } + impl substreams_ethereum::Function for RemoveBasePool { + const NAME: &'static str = "remove_base_pool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl RemoveBasePool { - const METHOD_ID: [u8; 4] = [242u8, 214u8, 215u8, 224u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( + 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 basepool: 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() != 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 { + basepool: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_pool))], - ); - 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 RemoveBasePool { - const NAME: &'static str = "remove_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() - } - } - } - /// 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 basepool: 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() != 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 { - basepool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'basepool' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'basepool' from topic of type 'address': {:?}", - e - ) - })? - .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 BasePoolRemoved { - pub basepool: Vec, - } - impl BasePoolRemoved { - const TOPIC_ID: [u8; 32] = [ - 182u8, - 21u8, - 76u8, - 29u8, - 67u8, - 212u8, - 144u8, - 212u8, - 42u8, - 142u8, - 156u8, - 204u8, - 193u8, - 144u8, - 232u8, - 173u8, - 132u8, - 170u8, - 92u8, - 207u8, - 97u8, - 95u8, - 30u8, - 59u8, - 181u8, - 143u8, - 209u8, - 227u8, - 31u8, - 183u8, - 108u8, - 104u8, - ]; - 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 { - basepool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + })? + .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 BasePoolRemoved { + pub basepool: Vec, + } + impl BasePoolRemoved { + const TOPIC_ID: [u8; 32] = [ + 182u8, + 21u8, + 76u8, + 29u8, + 67u8, + 212u8, + 144u8, + 212u8, + 42u8, + 142u8, + 156u8, + 204u8, + 193u8, + 144u8, + 232u8, + 173u8, + 132u8, + 170u8, + 92u8, + 207u8, + 97u8, + 95u8, + 30u8, + 59u8, + 181u8, + 143u8, + 209u8, + 227u8, + 31u8, + 183u8, + 108u8, + 104u8, + ]; + 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 { + basepool: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'basepool' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'basepool' 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 BasePoolRemoved { - const NAME: &'static str = "BasePoolRemoved"; - 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 BasePoolRemoved { + const NAME: &'static str = "BasePoolRemoved"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/crv_usd_pool_factory.rs b/src/abi/curve/child_registries/crv_usd_pool_factory.rs index 4ff770e..2318aab 100644 --- a/src/abi/curve/child_registries/crv_usd_pool_factory.rs +++ b/src/abi/curve/child_registries/crv_usd_pool_factory.rs @@ -1,3135 +1,1647 @@ - 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 AddBasePool { - pub u_base_pool: Vec, - pub u_fee_receiver: Vec, - pub u_asset_type: substreams::scalar::BigInt, - pub u_implementations: [Vec; 10usize], + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_base_pool: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddBasePool { + pub u_base_pool: Vec, + pub u_fee_receiver: Vec, + pub u_asset_type: substreams::scalar::BigInt, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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(), - u_fee_receiver: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementations: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_fee_receiver), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .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.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_fee_receiver), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - { - let v = self - .u_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, - } - } + ), + { + let v = self + .u_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 } - 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() + pub fn 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 AddExistingMetapools { - pub u_pools: [Vec; 10usize], + } + 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) } - 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 { - u_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( + 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 u_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( &[ - { - let v = self - .u_pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, + ), ], - ); - let mut encoded = Vec::with_capacity(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), + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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 + .u_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::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) } - impl substreams_ethereum::rpc::RPCDecodable for AddExistingMetapools { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AddTokenToWhitelist { - pub coin: Vec, - pub u_add: bool, + fn encode(&self) -> Vec { + self.encode() } - 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(), - u_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.u_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::rpc::RPCDecodable for AddExistingMetapools { + fn output(data: &[u8]) -> Result { + Self::output(data) } - 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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddTokenToWhitelist { + pub coin: Vec, + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .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(), + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for Admin { - 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 BasePoolAssets { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 - } + } + #[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 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 Admin { + const NAME: &'static str = "admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable - for BasePoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolList { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable> for Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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(), + } + #[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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for BasePoolList { - 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 BatchSetPoolAssetType { - pub u_pools: [Vec; 32usize], - pub u_asset_types: [substreams::scalar::BigInt; 32usize], + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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), - ] - }, - u_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 - .u_pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .u_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::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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitTransferOwnership { - pub u_addr: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_addr: values + 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(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, + .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 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 BasePoolList { + const NAME: &'static str = "base_pool_list"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable for ConvertMetapoolFees { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge { - pub u_pool: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for BasePoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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 { - u_pool: values + } + #[derive(Debug, Clone, PartialEq)] + pub struct BatchSetPoolAssetType { + pub u_pools: [Vec; 32usize], + pub u_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 { + u_pools: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 u_base_pool: Vec, - pub u_name: String, - pub u_symbol: String, - pub u_coin: Vec, - pub u_a: substreams::scalar::BigInt, - pub u_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 { - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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.u_base_pool), - ), - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_coin), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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.u_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 u_base_pool: Vec, - pub u_name: String, - pub u_symbol: String, - pub u_coin: Vec, - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_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 { - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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) - }, - u_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.u_base_pool), - ), - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_coin), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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.u_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.u_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 u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_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 { - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: 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), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + u_asset_types: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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.u_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() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_asset_type: substreams::scalar::BigInt, + .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), + ] + }, + }) } - 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 { - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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) - }, - u_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( + &[ + { + let v = self + .u_pools + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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.u_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.u_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") + { + let v = self + .u_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(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_asset_type: substreams::scalar::BigInt, - pub u_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 { - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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) - }, - u_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) + .as_slice(), + ), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - u_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.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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.u_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.u_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.u_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 - } - } - } + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - 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) + pub fn 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::rpc::RPCDecodable> for DeployPlainPool3 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub u_from: Vec, - pub u_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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 u_from: Vec, - pub u_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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 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) } - 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(), + 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 u_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 { + u_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.u_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, } - pub fn 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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_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 { + u_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.u_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 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::Function for DeployGauge { + const NAME: &'static str = "deploy_gauge"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeImplementation { - 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 GetA { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool1 { + pub u_base_pool: Vec, + pub u_name: String, + pub u_symbol: String, + pub u_coin: Vec, + pub u_a: substreams::scalar::BigInt, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_a: { + 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.u_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({ + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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.u_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 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::Function for DeployMetapool1 { + const NAME: &'static str = "deploy_metapool1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployMetapool1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool2 { + pub u_base_pool: Vec, + pub u_name: String, + pub u_symbol: String, + pub u_coin: Vec, + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_a: { + 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.u_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 + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + let mut v = [0 as u8; 32]; + 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 - } + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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.u_base_pool), + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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.u_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.u_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 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::Function for DeployMetapool2 { + const NAME: &'static str = "deploy_metapool2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]> - for GetAdminBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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({ + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployMetapool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool1 { + pub u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { let mut iter = values .pop() - .expect("one output data should have existed") + .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) + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() }); [ iter.next().expect(INTERNAL_ERR), @@ -3137,411 +1649,190 @@ 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 u_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 { - u_pool: values + }, + u_a: { + 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.u_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( + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + 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::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_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.u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for GetBasePool { - 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 GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), + ethabi::ParamType::String, + ethabi::ParamType::String, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 4usize, ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), } + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_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 { - u_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.u_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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -3554,130 +1845,219 @@ 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 - } + }, + u_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) + }, + u_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) + }, + u_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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_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.u_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.u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 4usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 4usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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({ + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool3 { + pub u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_asset_type: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { let mut iter = values .pop() - .expect("one output data should have existed") + .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) + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() }); [ iter.next().expect(INTERNAL_ERR), @@ -3685,3136 +2065,4420 @@ 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 u_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 { - u_pool: values + }, + u_a: { + 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.u_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( + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + 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 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 u_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 { - u_pool: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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) + }, + u_implementation_idx: { + 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.u_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) - }, + .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.u_name.clone()), + ethabi::Token::String(self.u_symbol.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 + .u_coins + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(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, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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.u_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.u_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.u_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 } } - 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 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 u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 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 u_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 { - u_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.u_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( + } + 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 u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for GetGauge { - 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 GetImplementationAddress { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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, + } + } + 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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_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 { + u_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.u_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 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::Function for GetA { + const NAME: &'static str = "get_A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> - for GetImplementationAddress { - 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 GetMetaNCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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) - }, - { + } + impl substreams_ethereum::rpc::RPCDecodable for GetA { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAdminBalances { + pub u_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 { + u_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.u_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) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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 - } + }); + [ + 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 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 u_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 { - u_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.u_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, + } + 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 u_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 { + u_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.u_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 } } - 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; 4usize]> + for GetBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasePool { + pub u_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 { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> - for GetMetapoolRates { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetBasePool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub u_pool: Vec, + pub u_from: Vec, + pub u_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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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({ + .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("one output data should have existed") - .into_uint() + .expect(INTERNAL_ERR) + .into_int() .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, + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetCoins { + const NAME: &'static str = "get_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetNCoins { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolAssetType { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetDecimals { + const NAME: &'static str = "get_decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetPoolAssetType { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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::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 u_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 { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetFeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees { + pub u_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 { + u_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.u_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_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.u_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 + .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("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 - } + .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 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::Function for GetFees { + const NAME: &'static str = "get_fees"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 8usize]> - for GetUnderlyingCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingDecimals { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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, + } + 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 u_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 { + u_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.u_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 } } - 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 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 u_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 { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsMeta { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetImplementationAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMetaNCoins { + pub u_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 { + u_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.u_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_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.u_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( + .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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 match_call(call: &substreams_ethereum::pb::eth::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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for Manager { - 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 MetapoolImplementations { - pub u_base_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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( + } + 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 u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), ], - ); - let mut encoded = Vec::with_capacity(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, + 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 } } - 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 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 u_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 { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 10usize]> - for MetapoolImplementations { - fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PlainImplementations { - pub arg0: substreams::scalar::BigInt, - pub arg1: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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()); + } + impl substreams_ethereum::rpc::RPCDecodable + for GetNCoins { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolAssetType { + pub u_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 { + u_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.u_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 } - 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: { + } + } + } + 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 u_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 { + u_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.u_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]; - 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) - }, - }) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_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 { + u_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.u_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::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(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 8usize, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for PlainImplementations { - 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 PlainWhitelist { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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), + } + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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 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 u_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 { + u_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.u_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 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::Function for IsMeta { + const NAME: &'static str = "is_meta"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for PoolCount { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable for IsMeta { + fn output(data: &[u8]) -> Result { + Self::output(data) } - 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()); + } + #[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 } - 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( + } + } + 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 u_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 { + u_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.u_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::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::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::Function for MetapoolImplementations { + const NAME: &'static str = "metapool_implementations"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for PoolList { - 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 SetFeeReceiver { - pub u_base_pool: Vec, - pub u_fee_receiver: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_base_pool: values + } + 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_fee_receiver: values + .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_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.u_base_pool), + .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::Address( - ethabi::Address::from_slice(&self.u_fee_receiver), + ), + 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetGaugeImplementation { - pub u_gauge_implementation: Vec, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for PlainImplementations { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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 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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetManager { - pub u_manager: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_manager: values + 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_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.u_manager), + .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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - 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) + } + 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 u_base_pool: Vec, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_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, } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) + } + } + 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 u_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 { + u_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.u_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, } - fn encode(&self) -> Vec { - self.encode() + } + } + 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 u_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 { + u_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.u_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetMetapoolImplementations { - pub u_base_pool: Vec, - pub u_implementations: [Vec; 10usize], + } + 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) } - 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 { - u_base_pool: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetMetapoolImplementations { + pub u_base_pool: Vec, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_implementations: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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), - ] + .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.u_base_pool), + ), + { + let v = self + .u_implementations + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - { - let v = self - .u_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, - } - } + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - 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() + pub fn 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 SetPlainImplementations { - pub u_n_coins: substreams::scalar::BigInt, - pub u_implementations: [Vec; 10usize], + } + 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) } - 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 { - u_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) - }, - u_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( + 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 u_n_coins: substreams::scalar::BigInt, + pub u_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::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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(), - ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), - { - let v = self - .u_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 + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementations: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .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 + .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.u_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 + .u_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_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) + }, + fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .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 + .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_address() + .into_fixed_array() .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 + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - pool: 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_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) + }, + 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) - } + } + 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) } - } \ No newline at end of file + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/crypto_pool_factory_v2.rs b/src/abi/curve/child_registries/crypto_pool_factory_v2.rs index 8a1e28a..f7d4d23 100644 --- a/src/abi/curve/child_registries/crypto_pool_factory_v2.rs +++ b/src/abi/curve/child_registries/crypto_pool_factory_v2.rs @@ -1,3559 +1,3395 @@ - 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() - } - } - #[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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for Admin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + 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 u_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 { + u_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.u_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 CommitTransferOwnership { - pub u_addr: 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 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 { - u_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.u_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, + 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 u_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 { + u_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.u_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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge { - pub u_pool: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(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()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + 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 u_name: String, + pub u_symbol: String, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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( + .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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_name: String, - pub u_symbol: String, - pub u_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 { - u_name: values + .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_string() - .expect(INTERNAL_ERR), - u_symbol: values + .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_string() - .expect(INTERNAL_ERR), - u_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) + .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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_coins + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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") - } + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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, + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 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 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(), + } + 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 u_from: Vec, + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for FeeReceiver { - 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 FindPoolForCoins1 { - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 u_from: Vec, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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::Function for FutureAdmin { + const NAME: &'static str = "future_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { - 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 FindPoolForCoins2 { - pub u_from: Vec, - pub u_to: Vec, - pub i: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[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 } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { + } + } + } + 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 u_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 { + u_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.u_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) - }, - }) + }); + [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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_pool: Vec, + pub u_from: Vec, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - ), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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( + 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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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( + .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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 match_call(call: &substreams_ethereum::pb::eth::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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeImplementation { - 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 GetBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetCoins { + const NAME: &'static str = "get_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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) - }, - { + 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) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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 - } + }); + [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 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 u_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 { - u_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.u_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 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 u_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 { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 2usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { - Self::output(data) - } + 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 GetDecimals { - pub u_pool: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable + for GetEthIndex { + fn output(data: &[u8]) -> Result { + Self::output(data) } - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauge { + pub u_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 { + u_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.u_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 { - u_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.u_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, + } + } + 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 u_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 { + u_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.u_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 } } - 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 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 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::Function for PoolCount { + const NAME: &'static str = "pool_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } + 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 GetEthIndex { - pub u_pool: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable + for PoolCount { + fn output(data: &[u8]) -> Result { + Self::output(data) } - 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()); + } + #[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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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 u_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 { - u_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.u_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 PoolImplementation { + const NAME: &'static str = "pool_implementation"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct GetToken { - pub u_pool: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for PoolImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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 { - u_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.u_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(), + } + #[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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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({ + .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") + .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 - } + }, + }) + } + 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 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(), + } + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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 substreams_ethereum::rpc::RPCDecodable> for PoolImplementation { - 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 PoolList { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeImplementation { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for PoolList { - 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 SetFeeReceiver { - pub u_fee_receiver: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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 SetPoolImplementation { + pub u_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 { + u_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.u_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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetGaugeImplementation { - pub u_gauge_implementation: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_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.u_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, - } - } + fn encode(&self) -> Vec { + self.encode() } - 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 SetTokenImplementation { + pub u_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 { + u_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.u_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetPoolImplementation { - pub u_pool_implementation: Vec, + } + 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) } - 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 { - u_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.u_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, + 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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetTokenImplementation { - pub u_token_implementation: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_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( + 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::Token::Address( - ethabi::Address::from_slice(&self.u_token_implementation), + 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, ], - ); - 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(), + log.data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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) - } - } - } - /// 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_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) - }, - deployer: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - 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) - } - 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 + .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(), - }) - } - } - 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 u_old_owner: Vec, - pub u_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 { - u_old_owner: 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(), - u_new_owner: 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(), - }) - } - } - 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 u_old_fee_receiver: Vec, - pub u_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 { - u_old_fee_receiver: 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(), - u_new_fee_receiver: values + .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_address() + .into_uint() .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 u_old_gauge_implementation: Vec, - pub u_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 { - u_old_gauge_implementation: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_gauge_implementation: values + .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_address() + .into_uint() .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 u_old_pool_implementation: Vec, - pub u_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 { - u_old_pool_implementation: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_pool_implementation: values + .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_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 u_old_token_implementation: Vec, - pub u_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 { - u_old_token_implementation: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_token_implementation: values + .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_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) + }, + 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) + } + 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) } - } \ No newline at end of file + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferOwnership { + pub u_old_owner: Vec, + pub u_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 { + u_old_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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 u_old_fee_receiver: Vec, + pub u_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 { + u_old_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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 u_old_gauge_implementation: Vec, + pub u_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 { + u_old_gauge_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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 u_old_pool_implementation: Vec, + pub u_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 { + u_old_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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 u_old_token_implementation: Vec, + pub u_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 { + u_old_token_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/crypto_swap_registry_old.rs b/src/abi/curve/child_registries/crypto_swap_registry_old.rs index 859664f..9b0a2f1 100644 --- a/src/abi/curve/child_registries/crypto_swap_registry_old.rs +++ b/src/abi/curve/child_registries/crypto_swap_registry_old.rs @@ -1,1873 +1,2286 @@ - 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 AddPool { - pub u_pool: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_lp_token: Vec, - pub u_gauge: Vec, - pub u_zap: Vec, - pub u_decimals: substreams::scalar::BigInt, - pub u_name: String, - } - impl AddPool { - const METHOD_ID: [u8; 4] = [201u8, 39u8, 37u8, 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), - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::String, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_lp_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_gauge: values +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 AddPool { + pub u_pool: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_lp_token: Vec, + pub u_gauge: Vec, + pub u_zap: Vec, + pub u_decimals: substreams::scalar::BigInt, + pub u_name: String, + } + impl AddPool { + const METHOD_ID: [u8; 4] = [201u8, 39u8, 37u8, 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), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::String, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_zap: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_zap: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_decimals: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_decimals: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_name: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), + } + .as_slice(), ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_zap)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_decimals.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_zap)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_decimals.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::String(self.u_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, - } - } + ), + ethabi::Token::String(self.u_name.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for AddPool { - const NAME: &'static str = "add_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() + pub fn 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 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()) + } + impl substreams_ethereum::Function for AddPool { + const NAME: &'static str = "add_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 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 + } } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values + } + } + 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 BatchSetLiquidityGauges { + pub u_pools: [Vec; 10usize], + pub u_liquidity_gauges: [Vec; 10usize], + } + impl BatchSetLiquidityGauges { + const METHOD_ID: [u8; 4] = [254u8, 198u8, 30u8, 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::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, + ), + 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 { + u_pools: { + let mut iter = values .pop() - .expect("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } + .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), + ] + }, + u_liquidity_gauges: { + 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 + .u_pools + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) + }, + { + let v = self + .u_liquidity_gauges + .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, } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for BatchSetLiquidityGauges { + const NAME: &'static str = "batch_set_liquidity_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 CoinCount {} + impl CoinCount { + const METHOD_ID: [u8; 4] = [80u8, 117u8, 119u8, 15u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 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::Function for CoinCount { + const NAME: &'static str = "coin_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for AddressProvider { - 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 BatchSetLiquidityGauges { - pub u_pools: [Vec; 10usize], - pub u_liquidity_gauges: [Vec; 10usize], + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for CoinCount { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl BatchSetLiquidityGauges { - const METHOD_ID: [u8; 4] = [254u8, 198u8, 30u8, 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - 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 { - u_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), - ] - }, - u_liquidity_gauges: { - 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( + } + } + 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 u_from: Vec, + pub u_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( &[ - { - let v = self - .u_pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .u_liquidity_gauges - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), ], - ); - 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 BatchSetLiquidityGauges { - const NAME: &'static str = "batch_set_liquidity_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 CoinCount {} - impl CoinCount { - const METHOD_ID: [u8; 4] = [80u8, 117u8, 119u8, 15u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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("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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 CoinCount { - const NAME: &'static str = "coin_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 FindPoolForCoins2 { + const NAME: &'static str = "find_pool_for_coins2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for CoinCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), + } + impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetA { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 GetD { + pub u_pool: Vec, + } + impl GetD { + const METHOD_ID: [u8; 4] = [227u8, 102u8, 60u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::Function for GetD { + const NAME: &'static str = "get_D"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { - 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 FindPoolForCoins2 { - pub u_from: Vec, - pub u_to: Vec, - pub i: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { + } + impl substreams_ethereum::rpc::RPCDecodable for GetD { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAdminBalances { + pub u_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 { + u_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.u_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]; - 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) - }, - }) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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; 8usize]> + for GetAdminBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::Function for GetBalances { + const NAME: &'static str = "get_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins2 { - 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 GetA { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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({ + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> + for GetBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoin { + pub arg0: substreams::scalar::BigInt, + } + impl GetCoin { + const METHOD_ID: [u8; 4] = [69u8, 240u8, 219u8, 36u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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 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::Function for GetCoin { + const NAME: &'static str = "get_coin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetD { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetD { - const METHOD_ID: [u8; 4] = [227u8, 102u8, 60u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetCoin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub u_pool: Vec, + pub u_from: Vec, + pub u_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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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_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.u_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({ + .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("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 - } + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::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 GetD { - const NAME: &'static str = "get_D"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetCoinIndices { + const NAME: &'static str = "get_coin_indices"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetD { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + 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 GetCoinSwapComplement { + pub u_coin: Vec, + pub u_index: substreams::scalar::BigInt, + } + impl GetCoinSwapComplement { + const METHOD_ID: [u8; 4] = [93u8, 33u8, 25u8, 130u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_index: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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() + .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) - }); - [ - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.next().expect(INTERNAL_ERR), - iter.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 - } + .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.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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 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::Function for GetCoinSwapComplement { + const NAME: &'static str = "get_coin_swap_complement"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetAdminBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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::rpc::RPCDecodable> for GetCoinSwapComplement { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinSwapCount { + pub u_coin: Vec, + } + impl GetCoinSwapCount { + const METHOD_ID: [u8; 4] = [152u8, 174u8, 222u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin))], + ); + let mut encoded = Vec::with_capacity(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 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::Function for GetCoinSwapCount { + const NAME: &'static str = "get_coin_swap_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoin { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl GetCoin { - const METHOD_ID: [u8; 4] = [69u8, 240u8, 219u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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( + } + impl substreams_ethereum::rpc::RPCDecodable + for GetCoinSwapCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins { + pub u_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 { + u_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.u_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::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::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 8usize, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 GetCoin { - const NAME: &'static str = "get_coin"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetCoins { + const NAME: &'static str = "get_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetCoin { - 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 GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable<[Vec; 8usize]> for GetCoins { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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) - }, - { + 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) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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 - } + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.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 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 GetCoinSwapComplement { - pub u_coin: Vec, - pub u_index: substreams::scalar::BigInt, - } - impl GetCoinSwapComplement { - const METHOD_ID: [u8; 4] = [93u8, 33u8, 25u8, 130u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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( + } + 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; 8usize]> + for GetDecimals { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees { + pub u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_coin), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 4usize, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 GetCoinSwapComplement { - const NAME: &'static str = "get_coin_swap_complement"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetFees { + const NAME: &'static str = "get_fees"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetCoinSwapComplement { - 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 GetCoinSwapCount { - pub u_coin: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetCoinSwapCount { - const METHOD_ID: [u8; 4] = [152u8, 174u8, 222u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin))], - ); - let mut encoded = Vec::with_capacity(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::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]> + for GetFees { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGamma { + pub u_pool: Vec, + } + impl GetGamma { + const METHOD_ID: [u8; 4] = [124u8, 64u8, 12u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 GetCoinSwapCount { - const NAME: &'static str = "get_coin_swap_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 GetGamma { + const NAME: &'static str = "get_gamma"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetCoinSwapCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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({ + } + impl substreams_ethereum::rpc::RPCDecodable + for GetGamma { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauges { + pub u_pool: Vec, + } + impl GetGauges { + const METHOD_ID: [u8; 4] = [86u8, 5u8, 159u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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], [substreams::scalar::BigInt; 10usize]), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Int(128usize)), + 10usize, + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -1883,131 +2296,24 @@ iter.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 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; 8usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub u_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 { - u_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.u_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") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner - .into_uint() + .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + substreams::scalar::BigInt::from_signed_bytes_be(&v) }); [ iter.next().expect(INTERNAL_ERR), @@ -2018,1816 +2324,1321 @@ iter.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 - } + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::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], [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 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::Function for GetGauges { + const NAME: &'static str = "get_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFees { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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::rpc::RPCDecodable< + ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), + > for GetGauges { + fn output( + data: &[u8], + ) -> Result< + ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLpToken { + pub arg0: Vec, + } + impl GetLpToken { + 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 { + 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for GetLpToken { + const NAME: &'static str = "get_lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]> - for GetFees { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGamma { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetGamma { - const METHOD_ID: [u8; 4] = [124u8, 64u8, 12u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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::rpc::RPCDecodable> for GetLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl substreams_ethereum::Function for GetGamma { - const NAME: &'static str = "get_gamma"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 GetNCoins { + pub u_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 { + u_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.u_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::rpc::RPCDecodable - for GetGamma { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauges { - pub u_pool: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl GetGauges { - const METHOD_ID: [u8; 4] = [86u8, 5u8, 159u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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], [substreams::scalar::BigInt; 10usize]), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Int(128usize)), - 10usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( - { - 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), - ] - }, - { - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_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<([Vec; 10usize], [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 - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for GetGauges { - const NAME: &'static str = "get_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn 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) } - impl substreams_ethereum::rpc::RPCDecodable< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - > for GetGauges { - fn output( - data: &[u8], - ) -> Result< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLpToken { - pub arg0: Vec, - } - impl GetLpToken { - 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolFromLpToken { + pub arg0: Vec, + } + impl GetPoolFromLpToken { + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetLpToken { - const NAME: &'static str = "get_lp_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::Function for GetPoolFromLpToken { + const NAME: &'static str = "get_pool_from_lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetLpToken { - 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 GetNCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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::rpc::RPCDecodable> for GetPoolFromLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolName { + pub u_pool: Vec, + } + impl GetPoolName { + 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 { + u_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.u_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 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::Function for GetPoolName { + const NAME: &'static str = "get_pool_name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetNCoins { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolFromLpToken { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetPoolFromLpToken { - 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::rpc::RPCDecodable for GetPoolName { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetVirtualPriceFromLpToken { + pub u_token: Vec, + } + impl GetVirtualPriceFromLpToken { + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 GetPoolFromLpToken { - const NAME: &'static str = "get_pool_from_lp_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::Function for GetVirtualPriceFromLpToken { + const NAME: &'static str = "get_virtual_price_from_lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetPoolFromLpToken { - 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 GetPoolName { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetPoolName { - 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 { - u_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.u_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), + } + impl substreams_ethereum::rpc::RPCDecodable + for GetVirtualPriceFromLpToken { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetZap { + pub arg0: Vec, + } + impl GetZap { + const METHOD_ID: [u8; 4] = [85u8, 51u8, 93u8, 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::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetPoolName { - const NAME: &'static str = "get_pool_name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for GetZap { + const NAME: &'static str = "get_zap"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for GetPoolName { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetVirtualPriceFromLpToken { - pub u_token: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetVirtualPriceFromLpToken { - 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 { - u_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.u_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::rpc::RPCDecodable> for GetZap { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct LastUpdated {} + impl LastUpdated { + const METHOD_ID: [u8; 4] = [104u8, 144u8, 9u8, 97u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 GetVirtualPriceFromLpToken { - const NAME: &'static str = "get_virtual_price_from_lp_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::Function for LastUpdated { + const NAME: &'static str = "last_updated"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetVirtualPriceFromLpToken { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetZap { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetZap { - const METHOD_ID: [u8; 4] = [85u8, 51u8, 93u8, 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::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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::rpc::RPCDecodable + for LastUpdated { + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 GetZap { - const NAME: &'static str = "get_zap"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 PoolCount { + const NAME: &'static str = "pool_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetZap { - 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 LastUpdated {} - impl LastUpdated { - const METHOD_ID: [u8; 4] = [104u8, 144u8, 9u8, 97u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + 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("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 - } + }, + }) + } + 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 LastUpdated { - const NAME: &'static str = "last_updated"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 PoolList { + const NAME: &'static str = "pool_list"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for LastUpdated { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[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 - } - } - } + fn encode(&self) -> Vec { + self.encode() } - 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 PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable - for PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemovePool { + pub u_pool: Vec, + } + impl RemovePool { + const METHOD_ID: [u8; 4] = [71u8, 73u8, 50u8, 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 { + u_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.u_pool))], + ); + 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 PoolList { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for RemovePool { + const NAME: &'static str = "remove_pool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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( + 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 SetLiquidityGauges { + pub u_pool: Vec, + pub u_liquidity_gauges: [Vec; 10usize], + } + impl SetLiquidityGauges { + const METHOD_ID: [u8; 4] = [239u8, 107u8, 151u8, 136u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - 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::ParamType::Address, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_liquidity_gauges: { + let mut iter = values .pop() - .expect("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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_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), + ] + }, + }) } - 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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + { + let v = self + .u_liquidity_gauges + .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 } - impl substreams_ethereum::rpc::RPCDecodable> for PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn 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 RemovePool { - pub u_pool: Vec, + } + impl substreams_ethereum::Function for SetLiquidityGauges { + const NAME: &'static str = "set_liquidity_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl RemovePool { - const METHOD_ID: [u8; 4] = [71u8, 73u8, 50u8, 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( + 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 PoolAdded { + pub pool: Vec, + } + impl PoolAdded { + const TOPIC_ID: [u8; 32] = [ + 115u8, + 204u8, + 166u8, + 42u8, + 177u8, + 181u8, + 32u8, + 201u8, + 113u8, + 91u8, + 244u8, + 230u8, + 199u8, + 30u8, + 62u8, + 81u8, + 140u8, + 117u8, + 78u8, + 113u8, + 72u8, + 246u8, + 81u8, + 2u8, + 244u8, + 50u8, + 137u8, + 167u8, + 223u8, + 14u8, + 254u8, + 166u8, + ]; + 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], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_pool))], - ); - 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, - } - } + .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::Function for RemovePool { - const NAME: &'static str = "remove_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::Event for PoolAdded { + const NAME: &'static str = "PoolAdded"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetLiquidityGauges { - pub u_pool: Vec, - pub u_liquidity_gauges: [Vec; 10usize], + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl SetLiquidityGauges { - const METHOD_ID: [u8; 4] = [239u8, 107u8, 151u8, 136u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolRemoved { + pub pool: Vec, + } + impl PoolRemoved { + const TOPIC_ID: [u8; 32] = [ + 65u8, + 6u8, + 223u8, + 218u8, + 165u8, + 119u8, + 87u8, + 61u8, + 181u8, + 28u8, + 12u8, + 169u8, + 63u8, + 118u8, + 109u8, + 190u8, + 223u8, + 160u8, + 117u8, + 143u8, + 170u8, + 46u8, + 127u8, + 91u8, + 205u8, + 183u8, + 193u8, + 66u8, + 190u8, + 128u8, + 60u8, + 63u8, + ]; + 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 call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_liquidity_gauges: { - 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.u_pool), - ), - { - let v = self - .u_liquidity_gauges - .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 SetLiquidityGauges { - const NAME: &'static str = "set_liquidity_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 PoolAdded { - pub pool: Vec, - } - impl PoolAdded { - const TOPIC_ID: [u8; 32] = [ - 115u8, - 204u8, - 166u8, - 42u8, - 177u8, - 181u8, - 32u8, - 201u8, - 113u8, - 91u8, - 244u8, - 230u8, - 199u8, - 30u8, - 62u8, - 81u8, - 140u8, - 117u8, - 78u8, - 113u8, - 72u8, - 246u8, - 81u8, - 2u8, - 244u8, - 50u8, - 137u8, - 167u8, - 223u8, - 14u8, - 254u8, - 166u8, - ]; - 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 PoolAdded { - const NAME: &'static str = "PoolAdded"; - 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 PoolRemoved { - pub pool: Vec, - } - impl PoolRemoved { - const TOPIC_ID: [u8; 32] = [ - 65u8, - 6u8, - 223u8, - 218u8, - 165u8, - 119u8, - 87u8, - 61u8, - 181u8, - 28u8, - 12u8, - 169u8, - 63u8, - 118u8, - 109u8, - 190u8, - 223u8, - 160u8, - 117u8, - 143u8, - 170u8, - 46u8, - 127u8, - 91u8, - 205u8, - 183u8, - 193u8, - 66u8, - 190u8, - 128u8, - 60u8, - 63u8, - ]; - 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 ) - .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 PoolRemoved { - const NAME: &'static str = "PoolRemoved"; - 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 PoolRemoved { + const NAME: &'static str = "PoolRemoved"; + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/crypto_swap_registry_v2.rs b/src/abi/curve/child_registries/crypto_swap_registry_v2.rs index 09aefeb..20c5f34 100644 --- a/src/abi/curve/child_registries/crypto_swap_registry_v2.rs +++ b/src/abi/curve/child_registries/crypto_swap_registry_v2.rs @@ -1,3589 +1,2594 @@ - 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 AddPool1 { - pub u_pool: Vec, - pub u_lp_token: Vec, - pub u_gauge: Vec, - pub u_zap: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_name: String, - } - impl AddPool1 { - const METHOD_ID: [u8; 4] = [63u8, 224u8, 39u8, 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::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::String, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_lp_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_zap: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_zap)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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(), - ), - ), - ethabi::Token::String(self.u_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 AddPool1 { - const NAME: &'static str = "add_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AddPool2 { - pub u_pool: Vec, - pub u_lp_token: Vec, - pub u_gauge: Vec, - pub u_zap: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_name: String, - pub u_base_pool: Vec, - } - impl AddPool2 { - const METHOD_ID: [u8; 4] = [78u8, 114u8, 77u8, 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::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::String, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_lp_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_zap: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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( +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 AddPool1 { + pub u_pool: Vec, + pub u_lp_token: Vec, + pub u_gauge: Vec, + pub u_zap: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_name: String, + } + impl AddPool1 { + const METHOD_ID: [u8; 4] = [63u8, 224u8, 39u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_zap)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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(), - ), - ), - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::String, ], - ); - 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 AddPool2 { - const NAME: &'static str = "add_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AddPool3 { - pub u_pool: Vec, - pub u_lp_token: Vec, - pub u_gauge: Vec, - pub u_zap: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_name: String, - pub u_base_pool: Vec, - pub u_has_positive_rebasing_tokens: bool, - } - impl AddPool3 { - const METHOD_ID: [u8; 4] = [46u8, 200u8, 98u8, 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::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::String, - ethabi::ParamType::Address, - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_lp_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_zap: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_base_pool: values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_zap: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_has_positive_rebasing_tokens: values - .pop() + .into_uint() .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.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_zap)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_zap)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), - ), - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), + } + .as_slice(), ), - ethabi::Token::Bool(self.u_has_positive_rebasing_tokens.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, - } - } + ), + ethabi::Token::String(self.u_name.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for AddPool3 { - const NAME: &'static str = "add_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() + pub fn 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 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 AddPool1 { + const NAME: &'static str = "add_pool1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable> for AddressProvider { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[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({ + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddPool2 { + pub u_pool: Vec, + pub u_lp_token: Vec, + pub u_gauge: Vec, + pub u_zap: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_name: String, + pub u_base_pool: Vec, + } + impl AddPool2 { + const METHOD_ID: [u8; 4] = [78u8, 114u8, 77u8, 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::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::String, + ethabi::ParamType::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_zap: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { 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 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 BasePoolRegistry {} - impl BasePoolRegistry { - const METHOD_ID: [u8; 4] = [36u8, 62u8, 72u8, 215u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + }, + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_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.u_pool)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_zap)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), + ), + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + ], + ); + 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 BasePoolRegistry { - const NAME: &'static str = "base_pool_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::Function for AddPool2 { + const NAME: &'static str = "add_pool2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for BasePoolRegistry { - 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 BatchSetLiquidityGauges { - pub u_pools: [Vec; 10usize], - pub u_liquidity_gauges: [Vec; 10usize], + fn encode(&self) -> Vec { + self.encode() } - impl BatchSetLiquidityGauges { - const METHOD_ID: [u8; 4] = [254u8, 198u8, 30u8, 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - 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 { - u_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), - ] - }, - u_liquidity_gauges: { - 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( + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddPool3 { + pub u_pool: Vec, + pub u_lp_token: Vec, + pub u_gauge: Vec, + pub u_zap: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_name: String, + pub u_base_pool: Vec, + pub u_has_positive_rebasing_tokens: bool, + } + impl AddPool3 { + const METHOD_ID: [u8; 4] = [46u8, 200u8, 98u8, 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( &[ - { - let v = self - .u_pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .u_liquidity_gauges - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::String, + ethabi::ParamType::Address, + ethabi::ParamType::Bool, ], - ); - 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 BatchSetLiquidityGauges { - const NAME: &'static str = "batch_set_liquidity_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 CoinCount {} - impl CoinCount { - const METHOD_ID: [u8; 4] = [80u8, 117u8, 119u8, 15u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_zap: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { 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 - } - } + }, + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_has_positive_rebasing_tokens: 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.u_pool)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_zap)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), + ), + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + ethabi::Token::Bool(self.u_has_positive_rebasing_tokens.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 CoinCount { - const NAME: &'static str = "coin_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 AddPool3 { + const NAME: &'static str = "add_pool3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for CoinCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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()); + } + #[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 } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), + } + } + 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 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 BasePoolRegistry {} + impl BasePoolRegistry { + const METHOD_ID: [u8; 4] = [36u8, 62u8, 72u8, 215u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for BasePoolRegistry { + const NAME: &'static str = "base_pool_registry"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { - 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 FindPoolForCoins2 { - pub u_from: Vec, - pub u_to: Vec, - pub i: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 GetA { - pub u_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 { - u_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.u_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 GetD { - pub u_pool: Vec, - } - impl GetD { - const METHOD_ID: [u8; 4] = [227u8, 102u8, 60u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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 GetD { - const NAME: &'static str = "get_D"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for GetD { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances { - pub u_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 { - u_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.u_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 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; 8usize]> - for GetAdminBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub u_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 { - u_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.u_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 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; 8usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBasePool { - pub u_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 { - u_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.u_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 GetCoin { - pub arg0: substreams::scalar::BigInt, - } - impl GetCoin { - const METHOD_ID: [u8; 4] = [69u8, 240u8, 219u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 GetCoin { - const NAME: &'static str = "get_coin"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable> for GetCoin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for BasePoolRegistry { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct BatchSetLiquidityGauges { + pub u_pools: [Vec; 10usize], + pub u_liquidity_gauges: [Vec; 10usize], + } + impl BatchSetLiquidityGauges { + const METHOD_ID: [u8; 4] = [254u8, 198u8, 30u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 u_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 { - u_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.u_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 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; 8usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub u_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 { - u_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.u_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 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; 8usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFees { - pub u_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 { - u_pool: values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pools: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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({ + .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), + ] + }, + u_liquidity_gauges: { let mut iter = values .pop() - .expect("one output data should have existed") + .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) + 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 + .u_pools + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) + }, + { + let v = self + .u_liquidity_gauges + .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, } - pub fn 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 BatchSetLiquidityGauges { + const NAME: &'static str = "batch_set_liquidity_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 CoinCount {} + impl CoinCount { + const METHOD_ID: [u8; 4] = [80u8, 117u8, 119u8, 15u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - 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 CoinCount { + const NAME: &'static str = "coin_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 CoinCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]> - for GetFees { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGamma { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetGamma { - const METHOD_ID: [u8; 4] = [124u8, 64u8, 12u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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({ + } + impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins2 { + pub u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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("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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 GetGamma { - const NAME: &'static str = "get_gamma"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FindPoolForCoins2 { + const NAME: &'static str = "find_pool_for_coins2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetGamma { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauges { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetGauges { - const METHOD_ID: [u8; 4] = [86u8, 5u8, 159u8, 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()); + } + impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetA { + pub u_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 { + u_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.u_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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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], [substreams::scalar::BigInt; 10usize]), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Int(128usize)), - 10usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( - { - 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), - ] - }, - { - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_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, + } + } + 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 GetD { + pub u_pool: Vec, + } + impl GetD { + const METHOD_ID: [u8; 4] = [227u8, 102u8, 60u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 } } - pub fn call( - &self, - address: Vec, - ) -> Option<([Vec; 10usize], [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(), } + } + } + impl substreams_ethereum::Function for GetD { + const NAME: &'static str = "get_D"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for GetD { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAdminBalances { + pub u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 GetGauges { - const NAME: &'static str = "get_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetAdminBalances { + const NAME: &'static str = "get_admin_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - > for GetGauges { - fn output( - data: &[u8], - ) -> Result< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLpToken { - pub arg0: Vec, - } - impl GetLpToken { - 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + 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 GetAdminBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 GetLpToken { - const NAME: &'static str = "get_lp_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::Function for GetBalances { + const NAME: &'static str = "get_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetLpToken { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins { - pub u_pool: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> + for GetBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) } - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasePool { + pub u_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 { + u_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.u_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 { - u_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.u_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({ + } + } + } + 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 GetCoin { + pub arg0: substreams::scalar::BigInt, + } + impl GetCoin { + const METHOD_ID: [u8; 4] = [69u8, 240u8, 219u8, 36u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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 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::Function for GetCoin { + const NAME: &'static str = "get_coin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetNCoins { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNUnderlyingCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetNUnderlyingCoins { - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetCoin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub u_pool: Vec, + pub u_from: Vec, + pub u_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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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({ + .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("one output data should have existed") - .into_uint() + .expect(INTERNAL_ERR) + .into_int() .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, + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 GetNUnderlyingCoins { - const NAME: &'static str = "get_n_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::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) } - impl substreams_ethereum::rpc::RPCDecodable - for GetNUnderlyingCoins { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolFromLpToken { - pub arg0: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable<[Vec; 8usize]> for GetCoins { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) } - impl GetPoolFromLpToken { - 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 GetPoolFromLpToken { - const NAME: &'static str = "get_pool_from_lp_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::Function for GetDecimals { + const NAME: &'static str = "get_decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetPoolFromLpToken { - 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 GetPoolName { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetPoolName { - 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 { - u_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.u_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), + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> + for GetDecimals { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 GetPoolName { - const NAME: &'static str = "get_pool_name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for GetFees { + const NAME: &'static str = "get_fees"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for GetPoolName { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]> + for GetFees { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 4usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGamma { + pub u_pool: Vec, + } + impl GetGamma { + const METHOD_ID: [u8; 4] = [124u8, 64u8, 12u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::Function for GetGamma { + const NAME: &'static str = "get_gamma"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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({ + } + impl substreams_ethereum::rpc::RPCDecodable + for GetGamma { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauges { + pub u_pool: Vec, + } + impl GetGauges { + const METHOD_ID: [u8; 4] = [86u8, 5u8, 159u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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], [substreams::scalar::BigInt; 10usize]), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Int(128usize)), + 10usize, + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -3599,132 +2604,24 @@ iter.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 u_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 { - u_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.u_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") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner - .into_uint() + .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + substreams::scalar::BigInt::from_signed_bytes_be(&v) }); [ iter.next().expect(INTERNAL_ERR), @@ -3735,1127 +2632,2008 @@ iter.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 match_call(call: &substreams_ethereum::pb::eth::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], [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 } } - 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 GetGauges { + const NAME: &'static str = "get_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + 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], [substreams::scalar::BigInt; 10usize]), + > for GetGauges { + fn output( + data: &[u8], + ) -> Result< + ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLpToken { + pub arg0: Vec, + } + impl GetLpToken { + 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 { + 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for GetLpToken { + const NAME: &'static str = "get_lp_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 GetLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNCoins { + pub u_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 { + u_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.u_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::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) + } + 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 GetNUnderlyingCoins { + pub u_pool: Vec, + } + impl GetNUnderlyingCoins { + 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 { + u_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.u_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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct GetVirtualPriceFromLpToken { - pub u_token: Vec, + } + impl substreams_ethereum::Function for GetNUnderlyingCoins { + const NAME: &'static str = "get_n_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 GetNUnderlyingCoins { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl GetVirtualPriceFromLpToken { - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolFromLpToken { + pub arg0: Vec, + } + impl GetPoolFromLpToken { + 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 { + 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 { - u_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.u_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, + } + } + impl substreams_ethereum::Function for GetPoolFromLpToken { + const NAME: &'static str = "get_pool_from_lp_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 GetPoolFromLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolName { + pub u_pool: Vec, + } + impl GetPoolName { + 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 { + u_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.u_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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + impl substreams_ethereum::Function for GetPoolName { + const NAME: &'static str = "get_pool_name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for GetPoolName { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingBalances { + pub u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; + 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 } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_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 { + u_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.u_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 GetVirtualPriceFromLpToken { - const NAME: &'static str = "get_virtual_price_from_lp_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::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) } - impl substreams_ethereum::rpc::RPCDecodable - for GetVirtualPriceFromLpToken { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetZap { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetZap { - const METHOD_ID: [u8; 4] = [85u8, 51u8, 93u8, 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::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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 GetZap { - const NAME: &'static str = "get_zap"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetUnderlyingDecimals { + const NAME: &'static str = "get_underlying_decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetZap { - 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 IsMeta { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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), + } + 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 GetVirtualPriceFromLpToken { + pub u_token: Vec, + } + impl GetVirtualPriceFromLpToken { + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for GetVirtualPriceFromLpToken { + const NAME: &'static str = "get_virtual_price_from_lp_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 GetVirtualPriceFromLpToken { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetZap { + pub arg0: Vec, + } + impl GetZap { + const METHOD_ID: [u8; 4] = [85u8, 51u8, 93u8, 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::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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for GetZap { + const NAME: &'static str = "get_zap"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsMeta { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct LastUpdated {} - impl LastUpdated { - const METHOD_ID: [u8; 4] = [104u8, 144u8, 9u8, 97u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GetZap { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsMeta { + pub u_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 { + u_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.u_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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 LastUpdated {} + impl LastUpdated { + const METHOD_ID: [u8; 4] = [104u8, 144u8, 9u8, 97u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 LastUpdated { - const NAME: &'static str = "last_updated"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 LastUpdated { + const NAME: &'static str = "last_updated"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for LastUpdated { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[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()) + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for LastUpdated { + 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 + } } - 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({ + } + } + 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("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 - } + }, + }) + } + 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 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::Function for PoolList { + const NAME: &'static str = "pool_list"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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) - }, - }) + } + impl substreams_ethereum::rpc::RPCDecodable> for PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemovePool { + pub u_pool: Vec, + } + impl RemovePool { + const METHOD_ID: [u8; 4] = [71u8, 73u8, 50u8, 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 { + u_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.u_pool))], + ); + 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 encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for RemovePool { + const NAME: &'static str = "remove_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 SetLiquidityGauges { + pub u_pool: Vec, + pub u_liquidity_gauges: [Vec; 10usize], + } + impl SetLiquidityGauges { + const METHOD_ID: [u8; 4] = [239u8, 107u8, 151u8, 136u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - 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::ParamType::Address, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_liquidity_gauges: { + let mut iter = values .pop() - .expect("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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_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), + ] + }, + }) } - 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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + { + let v = self + .u_liquidity_gauges + .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 } - impl substreams_ethereum::rpc::RPCDecodable> for PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn 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 RemovePool { - pub u_pool: Vec, + } + impl substreams_ethereum::Function for SetLiquidityGauges { + const NAME: &'static str = "set_liquidity_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl RemovePool { - const METHOD_ID: [u8; 4] = [71u8, 73u8, 50u8, 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( + 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 basepool: 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() != 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 { + basepool: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_pool))], - ); - 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, - } - } + .map_err(|e| { + format!( + "unable to decode param 'basepool' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for RemovePool { - const NAME: &'static str = "remove_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::Event for BasePoolAdded { + const NAME: &'static str = "BasePoolAdded"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetLiquidityGauges { - pub u_pool: Vec, - pub u_liquidity_gauges: [Vec; 10usize], + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl SetLiquidityGauges { - const METHOD_ID: [u8; 4] = [239u8, 107u8, 151u8, 136u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolAdded { + pub pool: Vec, + } + impl PoolAdded { + const TOPIC_ID: [u8; 32] = [ + 115u8, + 204u8, + 166u8, + 42u8, + 177u8, + 181u8, + 32u8, + 201u8, + 113u8, + 91u8, + 244u8, + 230u8, + 199u8, + 30u8, + 62u8, + 81u8, + 140u8, + 117u8, + 78u8, + 113u8, + 72u8, + 246u8, + 81u8, + 2u8, + 244u8, + 50u8, + 137u8, + 167u8, + 223u8, + 14u8, + 254u8, + 166u8, + ]; + 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 call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_liquidity_gauges: { - 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.u_pool), - ), - { - let v = self - .u_liquidity_gauges - .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 SetLiquidityGauges { - const NAME: &'static str = "set_liquidity_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 basepool: 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() != 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 { - basepool: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'basepool' from topic of type 'address': {:?}", - e - ) - })? - .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 PoolAdded { - pub pool: Vec, - } - impl PoolAdded { - const TOPIC_ID: [u8; 32] = [ - 115u8, - 204u8, - 166u8, - 42u8, - 177u8, - 181u8, - 32u8, - 201u8, - 113u8, - 91u8, - 244u8, - 230u8, - 199u8, - 30u8, - 62u8, - 81u8, - 140u8, - 117u8, - 78u8, - 113u8, - 72u8, - 246u8, - 81u8, - 2u8, - 244u8, - 50u8, - 137u8, - 167u8, - 223u8, - 14u8, - 254u8, - 166u8, - ]; - 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 ) - .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 PoolAdded { - const NAME: &'static str = "PoolAdded"; - 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 PoolRemoved { - pub pool: Vec, - } - impl PoolRemoved { - const TOPIC_ID: [u8; 32] = [ - 65u8, - 6u8, - 223u8, - 218u8, - 165u8, - 119u8, - 87u8, - 61u8, - 181u8, - 28u8, - 12u8, - 169u8, - 63u8, - 118u8, - 109u8, - 190u8, - 223u8, - 160u8, - 117u8, - 143u8, - 170u8, - 46u8, - 127u8, - 91u8, - 205u8, - 183u8, - 193u8, - 66u8, - 190u8, - 128u8, - 60u8, - 63u8, - ]; - 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(), + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for PoolAdded { + const NAME: &'static str = "PoolAdded"; + 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 PoolRemoved { + pub pool: Vec, + } + impl PoolRemoved { + const TOPIC_ID: [u8; 32] = [ + 65u8, + 6u8, + 223u8, + 218u8, + 165u8, + 119u8, + 87u8, + 61u8, + 181u8, + 28u8, + 12u8, + 169u8, + 63u8, + 118u8, + 109u8, + 190u8, + 223u8, + 160u8, + 117u8, + 143u8, + 170u8, + 46u8, + 127u8, + 91u8, + 205u8, + 183u8, + 193u8, + 66u8, + 190u8, + 128u8, + 60u8, + 63u8, + ]; + 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 ) - .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 PoolRemoved { - const NAME: &'static str = "PoolRemoved"; - 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 PoolRemoved { + const NAME: &'static str = "PoolRemoved"; + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/metapool_factory_old.rs b/src/abi/curve/child_registries/metapool_factory_old.rs index 685ed24..2376a18 100644 --- a/src/abi/curve/child_registries/metapool_factory_old.rs +++ b/src/abi/curve/child_registries/metapool_factory_old.rs @@ -1,3401 +1,3237 @@ - 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 AddBasePool { - pub u_base_pool: Vec, - pub u_metapool_implementation: Vec, - pub u_fee_receiver: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl AddBasePool { - const METHOD_ID: [u8; 4] = [100u8, 10u8, 218u8, 80u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_metapool_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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( + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddBasePool { + pub u_base_pool: Vec, + pub u_metapool_implementation: Vec, + pub u_fee_receiver: Vec, + } + impl AddBasePool { + const METHOD_ID: [u8; 4] = [100u8, 10u8, 218u8, 80u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_metapool_implementation), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_fee_receiver), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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(), + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_metapool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_metapool_implementation), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_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, } - pub fn 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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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 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 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({ + } + 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("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 - } + }, + }) + } + 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 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 BasePoolList { + const NAME: &'static str = "base_pool_list"; + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolList { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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(), + } + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .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 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::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::rpc::RPCDecodable> for BasePoolList { - 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 CommitTransferOwnership { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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, + } + #[derive(Debug, Clone, PartialEq)] + pub struct ConvertFees {} + impl ConvertFees { + const METHOD_ID: [u8; 4] = [220u8, 18u8, 85u8, 119u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 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 ConvertFees {} - impl ConvertFees { - const METHOD_ID: [u8; 4] = [220u8, 18u8, 85u8, 119u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 ConvertFees { + const NAME: &'static str = "convert_fees"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for ConvertFees { - const NAME: &'static str = "convert_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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable for ConvertFees { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployMetapool { - pub u_base_pool: Vec, - pub u_name: String, - pub u_symbol: String, - pub u_coin: Vec, - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable for ConvertFees { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl DeployMetapool { - 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 { - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_name: values + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool { + pub u_base_pool: Vec, + pub u_name: String, + pub u_symbol: String, + pub u_coin: Vec, + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + } + impl DeployMetapool { + 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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_coin: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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.u_base_pool), - ), - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_coin), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .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.u_base_pool), + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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 - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - 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::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 DeployMetapool { - 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 FeeReceiver { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl FeeReceiver { - const METHOD_ID: [u8; 4] = [114u8, 179u8, 141u8, 152u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployMetapool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FeeReceiver { + pub arg0: Vec, + } + impl FeeReceiver { + const METHOD_ID: [u8; 4] = [114u8, 179u8, 141u8, 152u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for FeeReceiver { + const NAME: &'static str = "fee_receiver"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FeeReceiver { - 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 FindPoolForCoins1 { - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for FeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_from: Vec, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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::Function for FutureAdmin { + const NAME: &'static str = "future_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { - 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 FindPoolForCoins2 { - pub u_from: Vec, - pub u_to: Vec, - pub i: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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()); + } + impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetA { + pub u_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 { + u_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.u_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 } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - ), + } + } + 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 u_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 { + u_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.u_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, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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(), + } + 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; 2usize]> + for GetAdminBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetBalances { + const NAME: &'static str = "get_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { - 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 GetA { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + 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 u_pool: Vec, + pub u_from: Vec, + pub u_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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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({ + .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("one output data should have existed") - .into_uint() + .expect(INTERNAL_ERR) + .into_int() .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, + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_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 { - u_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.u_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 GetCoinIndices { + const NAME: &'static str = "get_coin_indices"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> - for GetAdminBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub u_pool: Vec, + } + 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) } - 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 { - u_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.u_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(), } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins { + pub u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetCoins { + const NAME: &'static str = "get_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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) - }, - { + 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) - .into_int() + inner + .into_uint() .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 - } + 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 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::Function for GetDecimals { + const NAME: &'static str = "get_decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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 u_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 { - u_pool: values + 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 GetFees { + pub u_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 { + u_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.u_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_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.u_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 + .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("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 - } + .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 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::Function for GetFees { + const NAME: &'static str = "get_fees"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 2usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + 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 GetNCoins { + pub u_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 { + u_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.u_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_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.u_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 + .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("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 - } + .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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFees { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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) - }, - { + } + impl substreams_ethereum::rpc::RPCDecodable< + (substreams::scalar::BigInt, substreams::scalar::BigInt), + > for GetNCoins { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRates { + pub u_pool: Vec, + } + impl GetRates { + const METHOD_ID: [u8; 4] = [206u8, 153u8, 228u8, 90u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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 - } + }); + [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 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 GetNCoins { - pub u_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 { - u_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.u_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) - }, - { + } + impl substreams_ethereum::Function for GetRates { + const NAME: &'static str = "get_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 GetRates { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingBalances { + pub u_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 { + u_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.u_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]; - 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) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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 - } + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.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 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< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - > for GetNCoins { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetRates { - pub u_pool: Vec, - } - impl GetRates { - const METHOD_ID: [u8; 4] = [206u8, 153u8, 228u8, 90u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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 GetUnderlyingBalances { + const NAME: &'static str = "get_underlying_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for GetRates { - const NAME: &'static str = "get_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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> - for GetRates { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances { - pub u_pool: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> + for GetUnderlyingBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) } - 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 { - u_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.u_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(), } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingCoins { + pub u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 8usize]> - for GetUnderlyingCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingDecimals { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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::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 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 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 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({ + } + 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("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 - } + }, + }) + } + 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 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::Function for PoolList { + const NAME: &'static str = "pool_list"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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(), + } + impl substreams_ethereum::rpc::RPCDecodable> for PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub u_base_pool: Vec, + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_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 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::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 substreams_ethereum::rpc::RPCDecodable> for PoolList { - 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 SetFeeReceiver { - pub u_base_pool: Vec, - pub u_fee_receiver: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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( + } +} +/// 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, + pub implementat: Vec, + } + impl BasePoolAdded { + const TOPIC_ID: [u8; 32] = [ + 209u8, + 149u8, + 30u8, + 25u8, + 120u8, + 139u8, + 36u8, + 195u8, + 199u8, + 91u8, + 60u8, + 108u8, + 25u8, + 167u8, + 149u8, + 205u8, + 49u8, + 43u8, + 21u8, + 35u8, + 208u8, + 144u8, + 118u8, + 252u8, + 65u8, + 228u8, + 50u8, + 205u8, + 60u8, + 205u8, + 193u8, + 76u8, + ]; + 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 { + base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + implementat: 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 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::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_fee_receiver), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, ], - ); - 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() - } - } - } - /// 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, - pub implementat: Vec, - } - impl BasePoolAdded { - const TOPIC_ID: [u8; 32] = [ - 209u8, - 149u8, - 30u8, - 25u8, - 120u8, - 139u8, - 36u8, - 195u8, - 199u8, - 91u8, - 60u8, - 108u8, - 25u8, - 167u8, - 149u8, - 205u8, - 49u8, - 43u8, - 21u8, - 35u8, - 208u8, - 144u8, - 118u8, - 252u8, - 65u8, - 228u8, - 50u8, - 205u8, - 60u8, - 205u8, - 193u8, - 76u8, - ]; - 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 { - base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - implementat: 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 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 + 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_address() + .into_uint() .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 + .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_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) + }, + 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) - } + } + 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) } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/pool_registry_v1.rs b/src/abi/curve/child_registries/pool_registry_v1.rs index a29fcb0..e1a8cc0 100644 --- a/src/abi/curve/child_registries/pool_registry_v1.rs +++ b/src/abi/curve/child_registries/pool_registry_v1.rs @@ -1,3480 +1,744 @@ - 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 AddBasePool { - pub u_base_pool: Vec, - pub u_fee_receiver: Vec, - pub u_asset_type: substreams::scalar::BigInt, - pub u_implementations: [Vec; 10usize], + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_base_pool: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddBasePool { + pub u_base_pool: Vec, + pub u_fee_receiver: Vec, + pub u_asset_type: substreams::scalar::BigInt, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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(), - u_fee_receiver: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementations: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_fee_receiver), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .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.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_fee_receiver), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - { - let v = self - .u_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, - } - } + ), + { + let v = self + .u_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 } - 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() + pub fn 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 AddExistingMetapools { - pub u_pools: [Vec; 10usize], + } + 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) } - 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 { - u_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( + 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 u_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( &[ - { - let v = self - .u_pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, + ), ], - ); - let mut encoded = Vec::with_capacity(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), + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pools: { + let mut iter = values .pop() - .expect("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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_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 + .u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for Admin { - 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 BasePoolAssets { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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::rpc::RPCDecodable for AddExistingMetapools { + fn output(data: &[u8]) -> Result { + Self::output(data) } - 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 - } + } + #[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) } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolList { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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(), + } + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_pools: [Vec; 32usize], - pub u_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 { - u_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), - ] - }, - u_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 - .u_pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .u_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 BasePoolAssets { + const NAME: &'static str = "base_pool_assets"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitTransferOwnership { - pub u_addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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::rpc::RPCDecodable for BasePoolAssets { + fn output(data: &[u8]) -> Result { + Self::output(data) } - 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), + } + #[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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable for ConvertMetapoolFees { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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( + } + 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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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 BasePoolList { + const NAME: &'static str = "base_pool_list"; + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployMetapool1 { - pub u_base_pool: Vec, - pub u_name: String, - pub u_symbol: String, - pub u_coin: Vec, - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_base_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for BasePoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BatchSetPoolAssetType { + pub u_pools: [Vec; 32usize], + pub u_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 { + u_pools: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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.u_base_pool), - ), - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_coin), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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.u_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 u_base_pool: Vec, - pub u_name: String, - pub u_symbol: String, - pub u_coin: Vec, - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_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 { - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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) - }, - u_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.u_base_pool), - ), - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_coin), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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.u_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.u_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 u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_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 { - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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.u_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 u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_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 { - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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) - }, - u_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.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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.u_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.u_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 u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_asset_type: substreams::scalar::BigInt, - pub u_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 { - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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) - }, - u_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) - }, - u_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.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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.u_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.u_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.u_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 u_from: Vec, - pub u_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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 u_from: Vec, - pub u_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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 u_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 { - u_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.u_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 u_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 { - u_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.u_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 u_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 { - u_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.u_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 u_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 { - u_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.u_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 u_pool: Vec, - pub u_from: Vec, - pub u_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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 u_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 { - u_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.u_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() + .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { @@ -3485,121 +749,40 @@ iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.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; 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 u_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 { - u_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.u_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({ + }, + u_asset_types: { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -3616,1250 +799,976 @@ 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 u_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 { - u_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.u_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 u_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 { - u_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.u_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 u_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 { - u_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.u_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 u_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 { - u_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.u_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 u_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 { - u_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.u_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) + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.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 + .u_pools + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(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 + .u_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) }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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 - } - } + ], + ); + 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 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 u_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 { - u_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.u_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)] - }) + } + 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 u_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 { + u_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.u_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, } - pub fn 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 } } - 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 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 u_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 { + u_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.u_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 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::Function for DeployGauge { + const NAME: &'static str = "deploy_gauge"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> - for GetMetapoolRates { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool1 { + pub u_base_pool: Vec, + pub u_name: String, + pub u_symbol: String, + pub u_coin: Vec, + pub u_a: substreams::scalar::BigInt, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_a: { + 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.u_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({ + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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.u_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 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::Function for DeployMetapool1 { + const NAME: &'static str = "deploy_metapool1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetNCoins { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolAssetType { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployMetapool1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool2 { + pub u_base_pool: Vec, + pub u_name: String, + pub u_symbol: String, + pub u_coin: Vec, + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_a: { + 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.u_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({ + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { 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 - } + }, + u_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.u_base_pool), + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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.u_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.u_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 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::Function for DeployMetapool2 { + const NAME: &'static str = "deploy_metapool2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetPoolAssetType { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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({ + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployMetapool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool1 { + pub u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { let mut iter = values .pop() - .expect("one output data should have existed") + .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) + 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<[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 - } + }, + u_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) + }, + u_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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_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.u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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({ + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool2 { + pub u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -4871,1764 +1780,4530 @@ iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR), iter.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 - } + }, + u_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) + }, + u_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) + }, + u_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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_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.u_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.u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 8usize]> - for GetUnderlyingCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingDecimals { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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({ + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool3 { + pub u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_asset_type: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { let mut iter = values .pop() - .expect("one output data should have existed") + .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) + 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, + }, + u_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) + }, + u_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) + }, + u_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) + }, + u_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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_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.u_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.u_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.u_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.u_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 } } - 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 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 u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsMeta { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins2 { + pub u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, + .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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return 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 } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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(), + } + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for Manager { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub u_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 { + u_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.u_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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct MetapoolImplementations { - pub u_base_pool: Vec, + } + 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 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()); + } + 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 u_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 { + u_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.u_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 { - u_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( + } + } + 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 u_pool: Vec, + pub u_from: Vec, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - let mut encoded = Vec::with_capacity(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 + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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("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, + .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 } } - 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(), } + } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetCoins { + const NAME: &'static str = "get_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 10usize]> - for MetapoolImplementations { - fn output(data: &[u8]) -> Result<[Vec; 10usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PlainImplementations { - pub arg0: substreams::scalar::BigInt, - pub arg1: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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: { + } + 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 u_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 { + u_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.u_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) - }, - }) + }); + [ + 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 u_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 { + u_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.u_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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_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 { + u_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.u_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::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(), - ), - ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + 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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return 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 u_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 { + u_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.u_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 } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_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 { + u_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.u_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 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({ + } + 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 u_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 { + u_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.u_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("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, + }, + { + let mut v = [0 as u8; 32]; + values + .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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable - for PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNCoins { + pub u_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 { + u_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.u_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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolList { - pub arg0: substreams::scalar::BigInt, + } + 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) } - 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()); + 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 u_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 { + u_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.u_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 } - 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: { + } + } + } + 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 u_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 { + u_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.u_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]; - 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) - }, - }) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_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 { + u_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.u_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::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::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 8usize, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for PoolList { - 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<[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 u_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 { + u_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.u_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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetFeeReceiver { - pub u_base_pool: Vec, - pub u_fee_receiver: Vec, + } + 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) } - 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()); + } + #[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 } - 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 { - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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( + } + } + 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 u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_fee_receiver), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), ], - ); - 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, + 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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetGaugeImplementation { - pub u_gauge_implementation: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_gauge_implementation: values + 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_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.u_gauge_implementation), + .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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + ), + 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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetManager { - pub u_manager: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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()); + 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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_manager: values + } + } + } + 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_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.u_manager), + .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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - 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) + } + 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 u_base_pool: Vec, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_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, } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) + } + } + 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 u_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 { + u_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.u_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, } - fn encode(&self) -> Vec { - self.encode() + } + } + 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 u_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 { + u_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.u_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetMetapoolImplementations { - pub u_base_pool: Vec, - pub u_implementations: [Vec; 10usize], + } + 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) } - 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 { - u_base_pool: values + 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 u_base_pool: Vec, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_implementations: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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), - ] + .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.u_base_pool), + ), + { + let v = self + .u_implementations + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - { - let v = self - .u_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, - } - } + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - 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() + pub fn 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 SetPlainImplementations { - pub u_n_coins: substreams::scalar::BigInt, - pub u_implementations: [Vec; 10usize], + } + 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) } - 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 { - u_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) - }, - u_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( + 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 u_n_coins: substreams::scalar::BigInt, + pub u_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::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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(), - ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), - { - let v = self - .u_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 + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_n_coins: { + 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) + }, + u_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::Uint( + ethabi::Uint::from_big_endian( + match self.u_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 + .u_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_address() + .into_uint() .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 + .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_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) + }, + 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_address() + .into_fixed_array() .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 + .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_address() + .into_uint() .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_unsigned_bytes_be(&v) + }, + 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) + }, + 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) - } + } + 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) } - } \ No newline at end of file + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/pool_registry_v1_old.rs b/src/abi/curve/child_registries/pool_registry_v1_old.rs index ba60c54..f9ccdff 100644 --- a/src/abi/curve/child_registries/pool_registry_v1_old.rs +++ b/src/abi/curve/child_registries/pool_registry_v1_old.rs @@ -1,1717 +1,2844 @@ - 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 AddMetapool1 { - pub u_pool: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_lp_token: Vec, - pub u_decimals: substreams::scalar::BigInt, - pub u_name: String, - } - impl AddMetapool1 { - const METHOD_ID: [u8; 4] = [206u8, 111u8, 148u8, 225u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::String, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values +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 AddMetapool1 { + pub u_pool: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_lp_token: Vec, + pub u_decimals: substreams::scalar::BigInt, + pub u_name: String, + } + impl AddMetapool1 { + const METHOD_ID: [u8; 4] = [206u8, 111u8, 148u8, 225u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::String, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_lp_token: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_decimals: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_decimals: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_name: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_decimals.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_decimals.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::String(self.u_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, - } + ), + ethabi::Token::String(self.u_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 AddMetapool1 { - const NAME: &'static str = "add_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AddMetapool2 { - pub u_pool: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_lp_token: Vec, - pub u_decimals: substreams::scalar::BigInt, - pub u_name: String, - pub u_base_pool: Vec, - } - impl AddMetapool2 { - const METHOD_ID: [u8; 4] = [210u8, 160u8, 107u8, 175u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::String, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_lp_token: values + } + impl substreams_ethereum::Function for AddMetapool1 { + const NAME: &'static str = "add_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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddMetapool2 { + pub u_pool: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_lp_token: Vec, + pub u_decimals: substreams::scalar::BigInt, + pub u_name: String, + pub u_base_pool: Vec, + } + impl AddMetapool2 { + const METHOD_ID: [u8; 4] = [210u8, 160u8, 107u8, 175u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::String, + ethabi::ParamType::Address, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_decimals: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_name: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_base_pool: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_decimals: { + 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.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_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.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_decimals.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_decimals.clone().to_bytes_be() { + (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.u_name.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), + } + .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, - } + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + ], + ); + 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 AddMetapool2 { - const NAME: &'static str = "add_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AddPool { - pub u_pool: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_lp_token: Vec, - pub u_rate_info: [u8; 32usize], - pub u_decimals: substreams::scalar::BigInt, - pub u_underlying_decimals: substreams::scalar::BigInt, - pub u_has_initial_a: bool, - pub u_is_v1: bool, - pub u_name: String, - } - impl AddPool { - const METHOD_ID: [u8; 4] = [153u8, 32u8, 154u8, 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), - ethabi::ParamType::Address, - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ethabi::ParamType::Bool, - ethabi::ParamType::String, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + } + impl substreams_ethereum::Function for AddMetapool2 { + const NAME: &'static str = "add_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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddPool { + pub u_pool: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_lp_token: Vec, + pub u_rate_info: [u8; 32usize], + pub u_decimals: substreams::scalar::BigInt, + pub u_underlying_decimals: substreams::scalar::BigInt, + pub u_has_initial_a: bool, + pub u_is_v1: bool, + pub u_name: String, + } + impl AddPool { + const METHOD_ID: [u8; 4] = [153u8, 32u8, 154u8, 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), + ethabi::ParamType::Address, + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, + ethabi::ParamType::Bool, + ethabi::ParamType::String, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_lp_token: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_rate_info: { + let mut result = [0u8; 32]; + let v = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_rate_info: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - u_decimals: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_underlying_decimals: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_has_initial_a: values + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + u_decimals: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - u_is_v1: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - u_name: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_underlying_decimals: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_has_initial_a: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + u_is_v1: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), + } + .as_slice(), ), - ethabi::Token::FixedBytes(self.u_rate_info.as_ref().to_vec()), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_decimals.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::FixedBytes(self.u_rate_info.as_ref().to_vec()), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_decimals.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_underlying_decimals.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_underlying_decimals.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Bool(self.u_has_initial_a.clone()), - ethabi::Token::Bool(self.u_is_v1.clone()), - ethabi::Token::String(self.u_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, - } + ), + ethabi::Token::Bool(self.u_has_initial_a.clone()), + ethabi::Token::Bool(self.u_is_v1.clone()), + ethabi::Token::String(self.u_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 AddPool { - const NAME: &'static str = "add_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 AddPoolWithoutUnderlying { - pub u_pool: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_lp_token: Vec, - pub u_rate_info: [u8; 32usize], - pub u_decimals: substreams::scalar::BigInt, - pub u_use_rates: substreams::scalar::BigInt, - pub u_has_initial_a: bool, - pub u_is_v1: bool, - pub u_name: String, - } - impl AddPoolWithoutUnderlying { - const METHOD_ID: [u8; 4] = [220u8, 238u8, 134u8, 163u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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::Address, - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ethabi::ParamType::Bool, - ethabi::ParamType::String, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + } + impl substreams_ethereum::Function for AddPool { + const NAME: &'static str = "add_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 AddPoolWithoutUnderlying { + pub u_pool: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_lp_token: Vec, + pub u_rate_info: [u8; 32usize], + pub u_decimals: substreams::scalar::BigInt, + pub u_use_rates: substreams::scalar::BigInt, + pub u_has_initial_a: bool, + pub u_is_v1: bool, + pub u_name: String, + } + impl AddPoolWithoutUnderlying { + const METHOD_ID: [u8; 4] = [220u8, 238u8, 134u8, 163u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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::Address, + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, + ethabi::ParamType::Bool, + ethabi::ParamType::String, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_lp_token: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_rate_info: { + let mut result = [0u8; 32]; + let v = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_rate_info: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - u_decimals: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_use_rates: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_has_initial_a: values + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + u_decimals: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - u_is_v1: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - u_name: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_use_rates: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_has_initial_a: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + u_is_v1: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), + } + .as_slice(), ), - ethabi::Token::FixedBytes(self.u_rate_info.as_ref().to_vec()), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_decimals.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::FixedBytes(self.u_rate_info.as_ref().to_vec()), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_decimals.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_use_rates.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_use_rates.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Bool(self.u_has_initial_a.clone()), - ethabi::Token::Bool(self.u_is_v1.clone()), - ethabi::Token::String(self.u_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, - } + ), + ethabi::Token::Bool(self.u_has_initial_a.clone()), + ethabi::Token::Bool(self.u_is_v1.clone()), + ethabi::Token::String(self.u_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 AddPoolWithoutUnderlying { - const NAME: &'static str = "add_pool_without_underlying"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AddPoolWithoutUnderlying { + const NAME: &'static str = "add_pool_without_underlying"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[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 - } + 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::Function for AddressProvider { + const NAME: &'static str = "address_provider"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for AddressProvider { - 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 BatchSetPoolAssetType { - pub u_pools: [Vec; 32usize], - pub u_asset_types: [substreams::scalar::BigInt; 32usize], + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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), - ] - }, - u_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( + } + impl substreams_ethereum::rpc::RPCDecodable> for AddressProvider { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BatchSetPoolAssetType { + pub u_pools: [Vec; 32usize], + pub u_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( &[ - { - let v = self - .u_pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .u_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) - }, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 32usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 32usize, + ), ], - ); - 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 CoinCount {} - impl CoinCount { - const METHOD_ID: [u8; 4] = [80u8, 117u8, 119u8, 15u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pools: { + let mut iter = 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) - }) + .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), + ] + }, + u_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 + .u_pools + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) + }, + { + let v = self + .u_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, } - pub fn 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 CoinCount {} + impl CoinCount { + const METHOD_ID: [u8; 4] = [80u8, 117u8, 119u8, 15u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + impl substreams_ethereum::Function for CoinCount { + const NAME: &'static str = "coin_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 CoinCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct EstimateGasUsed { + pub u_pool: Vec, + pub u_from: Vec, + pub u_to: Vec, + } + impl EstimateGasUsed { + const METHOD_ID: [u8; 4] = [176u8, 187u8, 54u8, 91u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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, ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 { + 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 CoinCount { - const NAME: &'static str = "coin_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 EstimateGasUsed { + const NAME: &'static str = "estimate_gas_used"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for CoinCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct EstimateGasUsed { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for EstimateGasUsed { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl EstimateGasUsed { - const METHOD_ID: [u8; 4] = [176u8, 187u8, 54u8, 91u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 FindPoolForCoins1 { + pub u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_from: Vec, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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("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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 GaugeController {} + impl GaugeController { + const METHOD_ID: [u8; 4] = [216u8, 185u8, 160u8, 24u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for EstimateGasUsed { - const NAME: &'static str = "estimate_gas_used"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GaugeController { + const NAME: &'static str = "gauge_controller"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for EstimateGasUsed { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub u_from: Vec, - pub u_to: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for GaugeController { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetA { + pub u_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 { + u_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.u_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 } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { - 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 FindPoolForCoins2 { - pub u_from: Vec, - pub u_to: Vec, - pub i: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> + for GetAdminBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub u_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 { + u_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.u_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]; - 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) - }, - }) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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( + } + } + 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; 8usize]> + for GetBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoin { + pub arg0: substreams::scalar::BigInt, + } + impl GetCoin { + const METHOD_ID: [u8; 4] = [69u8, 240u8, 219u8, 36u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for GetCoin { + const NAME: &'static str = "get_coin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins2 { - 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 GaugeController {} - impl GaugeController { - const METHOD_ID: [u8; 4] = [216u8, 185u8, 160u8, 24u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GetCoin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub u_pool: Vec, + pub u_from: Vec, + pub u_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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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_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 GaugeController { - const NAME: &'static str = "gauge_controller"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetCoinIndices { + const NAME: &'static str = "get_coin_indices"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeController { - 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 GetA { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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({ + } + 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 GetCoinSwapComplement { + pub u_coin: Vec, + pub u_index: substreams::scalar::BigInt, + } + impl GetCoinSwapComplement { + const METHOD_ID: [u8; 4] = [93u8, 33u8, 25u8, 130u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_index: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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 + } } - pub fn 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 GetCoinSwapComplement { + const NAME: &'static str = "get_coin_swap_complement"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GetCoinSwapComplement { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinSwapCount { + pub u_coin: Vec, + } + impl GetCoinSwapCount { + const METHOD_ID: [u8; 4] = [152u8, 174u8, 222u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin))], + ); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + impl substreams_ethereum::Function for GetCoinSwapCount { + const NAME: &'static str = "get_coin_swap_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 GetCoinSwapCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoins { + pub u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::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 GetA { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::rpc::RPCDecodable<[Vec; 8usize]> for GetCoins { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub u_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 { + u_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.u_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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances { - pub u_pool: Vec, + } + 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; 8usize]> + for GetDecimals { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) } - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees { + pub u_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 { + u_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.u_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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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({ + } + } + } + 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; 2usize]> + for GetFees { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauges { + pub u_pool: Vec, + } + impl GetGauges { + const METHOD_ID: [u8; 4] = [86u8, 5u8, 159u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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], [substreams::scalar::BigInt; 10usize]), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Int(128usize)), + 10usize, + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { let mut iter = values .pop() - .expect("one output data should have existed") + .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) + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() }); [ iter.next().expect(INTERNAL_ERR), @@ -1722,137 +2849,24 @@ iter.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 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; 8usize]> - for GetAdminBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub u_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 { - u_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.u_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") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner - .into_uint() + .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + substreams::scalar::BigInt::from_signed_bytes_be(&v) }); [ iter.next().expect(INTERNAL_ERR), @@ -1863,1707 +2877,501 @@ iter.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 match_call(call: &substreams_ethereum::pb::eth::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], [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 } } - 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 GetGauges { + const NAME: &'static str = "get_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + 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], [substreams::scalar::BigInt; 10usize]), + > for GetGauges { + fn output( + data: &[u8], + ) -> Result< + ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLpToken { + pub arg0: Vec, + } + impl GetLpToken { + 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 { + 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for GetLpToken { + const NAME: &'static str = "get_lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoin { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl GetCoin { - const METHOD_ID: [u8; 4] = [69u8, 240u8, 219u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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: { + } + impl substreams_ethereum::rpc::RPCDecodable> for GetLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNCoins { + pub u_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 { + u_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.u_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) - }, - }) - } - 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 - } - } + }); + [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 GetCoin { - const NAME: &'static str = "get_coin"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetNCoins { + const NAME: &'static str = "get_n_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetCoin { - 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 GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> + for GetNCoins { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) } - 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() - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetParameters { + pub u_pool: Vec, + } + impl GetParameters { + const METHOD_ID: [u8; 4] = [31u8, 128u8, 169u8, 87u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(call.return_data.as_ref()) } - 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 GetCoinSwapComplement { - pub u_coin: Vec, - pub u_index: substreams::scalar::BigInt, - } - impl GetCoinSwapComplement { - const METHOD_ID: [u8; 4] = [93u8, 33u8, 25u8, 130u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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( + pub fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_coin), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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::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, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for GetCoinSwapComplement { - const NAME: &'static str = "get_coin_swap_complement"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable> for GetCoinSwapComplement { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinSwapCount { - pub u_coin: Vec, - } - impl GetCoinSwapCount { - const METHOD_ID: [u8; 4] = [152u8, 174u8, 222u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_coin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin))], - ); - let mut encoded = Vec::with_capacity(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({ + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { 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 GetCoinSwapCount { - const NAME: &'static str = "get_coin_swap_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 GetCoinSwapCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins { - pub u_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 { - u_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.u_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 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; 8usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub u_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 { - u_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.u_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 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; 8usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFees { - pub u_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 { - u_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.u_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 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; 2usize]> - for GetFees { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauges { - pub u_pool: Vec, - } - impl GetGauges { - const METHOD_ID: [u8; 4] = [86u8, 5u8, 159u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + }, + { + 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.u_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], [substreams::scalar::BigInt; 10usize]), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Int(128usize)), - 10usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( - { - 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), - ] - }, - { - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_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<([Vec; 10usize], [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 GetGauges { - const NAME: &'static str = "get_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - 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], [substreams::scalar::BigInt; 10usize]), - > for GetGauges { - fn output( - data: &[u8], - ) -> Result< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLpToken { - pub arg0: Vec, - } - impl GetLpToken { - 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 { - arg0: 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_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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + .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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for GetLpToken { - const NAME: &'static str = "get_lp_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 GetLpToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins { - pub u_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 { - u_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.u_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() + .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) - }); - [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 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<[substreams::scalar::BigInt; 2usize]> - for GetNCoins { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetParameters { - pub u_pool: Vec, - } - impl GetParameters { - const METHOD_ID: [u8; 4] = [31u8, 128u8, 169u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: 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_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.u_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, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .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) - }, + .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_address() + .into_uint() .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) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call( - &self, - address: Vec, - ) -> Option< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - > { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .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(), + { + let mut v = [0 as u8; 32]; + values + .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) + }, + )) } - impl substreams_ethereum::Function for GetParameters { - const NAME: &'static str = "get_parameters"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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< + pub fn call( + &self, + address: Vec, + ) -> Option< ( substreams::scalar::BigInt, substreams::scalar::BigInt, @@ -3576,700 +3384,1520 @@ substreams::scalar::BigInt, substreams::scalar::BigInt, ), - > for GetParameters { - fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolAssetType { - pub u_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()); + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 { - u_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.u_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, + } + } + impl substreams_ethereum::Function for GetParameters { + const NAME: &'static str = "get_parameters"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > for GetParameters { + fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolAssetType { + pub u_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 { + u_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.u_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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 GetPoolFromLpToken { + pub arg0: Vec, + } + impl GetPoolFromLpToken { + 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 { + 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for GetPoolFromLpToken { + const NAME: &'static str = "get_pool_from_lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetPoolAssetType { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolFromLpToken { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetPoolFromLpToken { - 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::rpc::RPCDecodable> for GetPoolFromLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolName { + pub u_pool: Vec, + } + impl GetPoolName { + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + impl substreams_ethereum::Function for GetPoolName { + const NAME: &'static str = "get_pool_name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for GetPoolName { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRates { + pub u_pool: Vec, + } + impl GetRates { + const METHOD_ID: [u8; 4] = [206u8, 153u8, 228u8, 90u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 GetPoolFromLpToken { - const NAME: &'static str = "get_pool_from_lp_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::Function for GetRates { + const NAME: &'static str = "get_rates"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetPoolFromLpToken { - 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 GetPoolName { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetPoolName { - 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 { - u_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.u_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), + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> + for GetRates { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingBalances { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 GetPoolName { - const NAME: &'static str = "get_pool_name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::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) } - impl substreams_ethereum::rpc::RPCDecodable for GetPoolName { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetRates { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetRates { - const METHOD_ID: [u8; 4] = [206u8, 153u8, 228u8, 90u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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, + } + 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 u_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 { + u_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.u_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 } } - 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(), } + } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; + 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 } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 GetVirtualPriceFromLpToken { + pub u_token: Vec, + } + impl GetVirtualPriceFromLpToken { + 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 { + u_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.u_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 GetRates { - const NAME: &'static str = "get_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::Function for GetVirtualPriceFromLpToken { + const NAME: &'static str = "get_virtual_price_from_lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetRates { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetVirtualPriceFromLpToken { + fn output(data: &[u8]) -> Result { + Self::output(data) } - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsMeta { + pub u_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 { + u_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.u_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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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, + } + } + 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 LastUpdated {} + impl LastUpdated { + const METHOD_ID: [u8; 4] = [104u8, 144u8, 9u8, 97u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - 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 LastUpdated { + const NAME: &'static str = "last_updated"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for LastUpdated { + 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 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::Function for PoolCount { + const NAME: &'static str = "pool_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + 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_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.u_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({ + .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 RemovePool { + pub u_pool: Vec, + } + impl RemovePool { + const METHOD_ID: [u8; 4] = [71u8, 73u8, 50u8, 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 { + u_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.u_pool))], + ); + 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 RemovePool { + const NAME: &'static str = "remove_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 SetCoinGasEstimates { + pub u_addr: [Vec; 10usize], + pub u_amount: [substreams::scalar::BigInt; 10usize], + } + impl SetCoinGasEstimates { + const METHOD_ID: [u8; 4] = [35u8, 127u8, 137u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 10usize, + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_addr: { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -4285,122 +4913,14 @@ iter.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 u_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 { - u_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.u_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({ + }, + u_amount: { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -4421,1410 +4941,660 @@ 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 GetVirtualPriceFromLpToken { - pub u_token: Vec, - } - impl GetVirtualPriceFromLpToken { - 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 { - u_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.u_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 GetVirtualPriceFromLpToken { - const NAME: &'static str = "get_virtual_price_from_lp_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 GetVirtualPriceFromLpToken { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsMeta { - pub u_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 { - u_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.u_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 LastUpdated {} - impl LastUpdated { - const METHOD_ID: [u8; 4] = [104u8, 144u8, 9u8, 97u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 LastUpdated { - const NAME: &'static str = "last_updated"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for LastUpdated { - 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, + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + ] + }, + }) } - 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( + &[ + { + let v = self + .u_addr + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(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") + { + let v = self + .u_amount + .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(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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::FixedArray(v) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - 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() + pub fn 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 PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + } + impl substreams_ethereum::Function for SetCoinGasEstimates { + const NAME: &'static str = "set_coin_gas_estimates"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RemovePool { - pub u_pool: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl RemovePool { - const METHOD_ID: [u8; 4] = [71u8, 73u8, 50u8, 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 { - u_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.u_pool))], - ); - 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 RemovePool { - const NAME: &'static str = "remove_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 SetGasEstimateContract { + pub u_pool: Vec, + pub u_estimator: Vec, + } + impl SetGasEstimateContract { + const METHOD_ID: [u8; 4] = [202u8, 153u8, 27u8, 20u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_estimator: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_estimator), + ), + ], + ); + 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 SetCoinGasEstimates { - pub u_addr: [Vec; 10usize], - pub u_amount: [substreams::scalar::BigInt; 10usize], - } - impl SetCoinGasEstimates { - const METHOD_ID: [u8; 4] = [35u8, 127u8, 137u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 10usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_addr: { - 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), - ] - }, - u_amount: { - 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), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_addr - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .u_amount - .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 SetGasEstimateContract { + const NAME: &'static str = "set_gas_estimate_contract"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for SetCoinGasEstimates { - const NAME: &'static str = "set_coin_gas_estimates"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetGasEstimateContract { - pub u_pool: Vec, - pub u_estimator: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl SetGasEstimateContract { - const METHOD_ID: [u8; 4] = [202u8, 153u8, 27u8, 20u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_estimator: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetLiquidityGauges { + pub u_pool: Vec, + pub u_liquidity_gauges: [Vec; 10usize], + } + impl SetLiquidityGauges { + const METHOD_ID: [u8; 4] = [239u8, 107u8, 151u8, 136u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_estimator), + ethabi::ParamType::Address, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), ], - ); - 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 SetGasEstimateContract { - const NAME: &'static str = "set_gas_estimate_contract"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetLiquidityGauges { - pub u_pool: Vec, - pub u_liquidity_gauges: [Vec; 10usize], - } - impl SetLiquidityGauges { - const METHOD_ID: [u8; 4] = [239u8, 107u8, 151u8, 136u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_pool: values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_liquidity_gauges: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_liquidity_gauges: { - 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), - ] + .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.u_pool)), + { + let v = self + .u_liquidity_gauges + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - { - let v = self - .u_liquidity_gauges - .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, - } - } + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for SetLiquidityGauges { - const NAME: &'static str = "set_liquidity_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 SetPoolAssetType { - pub u_pool: Vec, - pub u_asset_type: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for SetLiquidityGauges { + const NAME: &'static str = "set_liquidity_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetPoolAssetType { - const METHOD_ID: [u8; 4] = [9u8, 231u8, 103u8, 116u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_pool: values + 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 SetPoolAssetType { + pub u_pool: Vec, + pub u_asset_type: substreams::scalar::BigInt, + } + impl SetPoolAssetType { + const METHOD_ID: [u8; 4] = [9u8, 231u8, 103u8, 116u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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(), - u_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::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .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.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for SetPoolAssetType { - const NAME: &'static str = "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() + pub fn 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 SetPoolGasEstimates { - pub u_addr: [Vec; 5usize], - pub u_amount: [[substreams::scalar::BigInt; 2usize]; 5usize], + } + impl substreams_ethereum::Function for SetPoolAssetType { + const NAME: &'static str = "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) } - impl SetPoolGasEstimates { - const METHOD_ID: [u8; 4] = [7u8, 51u8, 182u8, 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 5usize, - ), - ethabi::ParamType::FixedArray( - Box::new( - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetPoolGasEstimates { + pub u_addr: [Vec; 5usize], + pub u_amount: [[substreams::scalar::BigInt; 2usize]; 5usize], + } + impl SetPoolGasEstimates { + const METHOD_ID: [u8; 4] = [7u8, 51u8, 182u8, 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::FixedArray( + Box::new(ethabi::ParamType::Address), + 5usize, + ), + ethabi::ParamType::FixedArray( + Box::new( + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), - 5usize, ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_addr: { - 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), - ] - }, - u_amount: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - let mut iter = inner - .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), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_addr - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .u_amount - .iter() - .map(|inner| { - let v = inner - .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) - }) - .collect(); - ethabi::Token::FixedArray(v) - }, + 5usize, + ), ], - ); - 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 SetPoolGasEstimates { - const NAME: &'static str = "set_pool_gas_estimates"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 PoolAdded { - pub pool: Vec, - pub rate_method_id: Vec, - } - impl PoolAdded { - const TOPIC_ID: [u8; 32] = [ - 228u8, - 133u8, - 193u8, - 100u8, - 121u8, - 171u8, - 112u8, - 146u8, - 192u8, - 179u8, - 252u8, - 70u8, - 73u8, - 132u8, - 60u8, - 6u8, - 190u8, - 127u8, - 7u8, - 33u8, - 148u8, - 103u8, - 82u8, - 97u8, - 89u8, - 12u8, - 132u8, - 71u8, - 58u8, - 176u8, - 174u8, - 169u8, - ]; - 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::Bytes], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - 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 - ) - })? + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_addr: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - rate_method_id: values - .pop() + .into_fixed_array() .expect(INTERNAL_ERR) - .into_bytes() - .expect(INTERNAL_ERR), - }) - } - } - impl substreams_ethereum::Event for PoolAdded { - const NAME: &'static str = "PoolAdded"; - 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 PoolRemoved { - pub pool: Vec, - } - impl PoolRemoved { - const TOPIC_ID: [u8; 32] = [ - 65u8, - 6u8, - 223u8, - 218u8, - 165u8, - 119u8, - 87u8, - 61u8, - 181u8, - 28u8, - 12u8, - 169u8, - 63u8, - 118u8, - 109u8, - 190u8, - 223u8, - 160u8, - 117u8, - 143u8, - 170u8, - 46u8, - 127u8, - 91u8, - 205u8, - 183u8, - 193u8, - 66u8, - 190u8, - 128u8, - 60u8, - 63u8, - ]; - 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 - ) - })? + .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), + ] + }, + u_amount: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + .into_iter() + .map(|inner| { + let mut iter = inner + .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), + ] + }, + }) } - impl substreams_ethereum::Event for PoolRemoved { - const NAME: &'static str = "PoolRemoved"; - 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_addr + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) + }, + { + let v = self + .u_amount + .iter() + .map(|inner| { + let v = inner + .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) + }) + .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, } } - } \ No newline at end of file + } + impl substreams_ethereum::Function for SetPoolGasEstimates { + const NAME: &'static str = "set_pool_gas_estimates"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 PoolAdded { + pub pool: Vec, + pub rate_method_id: Vec, + } + impl PoolAdded { + const TOPIC_ID: [u8; 32] = [ + 228u8, + 133u8, + 193u8, + 100u8, + 121u8, + 171u8, + 112u8, + 146u8, + 192u8, + 179u8, + 252u8, + 70u8, + 73u8, + 132u8, + 60u8, + 6u8, + 190u8, + 127u8, + 7u8, + 33u8, + 148u8, + 103u8, + 82u8, + 97u8, + 89u8, + 12u8, + 132u8, + 71u8, + 58u8, + 176u8, + 174u8, + 169u8, + ]; + 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::Bytes], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + 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(), + rate_method_id: values + .pop() + .expect(INTERNAL_ERR) + .into_bytes() + .expect(INTERNAL_ERR), + }) + } + } + impl substreams_ethereum::Event for PoolAdded { + const NAME: &'static str = "PoolAdded"; + 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 PoolRemoved { + pub pool: Vec, + } + impl PoolRemoved { + const TOPIC_ID: [u8; 32] = [ + 65u8, + 6u8, + 223u8, + 218u8, + 165u8, + 119u8, + 87u8, + 61u8, + 181u8, + 28u8, + 12u8, + 169u8, + 63u8, + 118u8, + 109u8, + 190u8, + 223u8, + 160u8, + 117u8, + 143u8, + 170u8, + 46u8, + 127u8, + 91u8, + 205u8, + 183u8, + 193u8, + 66u8, + 190u8, + 128u8, + 60u8, + 63u8, + ]; + 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 PoolRemoved { + const NAME: &'static str = "PoolRemoved"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/pool_registry_v2_old.rs b/src/abi/curve/child_registries/pool_registry_v2_old.rs index 8bae52c..aa30e2f 100644 --- a/src/abi/curve/child_registries/pool_registry_v2_old.rs +++ b/src/abi/curve/child_registries/pool_registry_v2_old.rs @@ -1,1716 +1,2040 @@ - 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 AddMetapool { - pub u_pool: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_lp_token: Vec, - pub u_decimals: substreams::scalar::BigInt, - } - impl AddMetapool { - const METHOD_ID: [u8; 4] = [207u8, 237u8, 173u8, 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::Address, - 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 { - u_pool: values +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 AddMetapool { + pub u_pool: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_lp_token: Vec, + pub u_decimals: substreams::scalar::BigInt, + } + impl AddMetapool { + const METHOD_ID: [u8; 4] = [207u8, 237u8, 173u8, 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::Address, + 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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_lp_token: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_decimals: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_decimals: { - let mut v = [0 as u8; 32]; - values - .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.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .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.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_decimals.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_decimals.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for AddMetapool { - const NAME: &'static str = "add_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() + pub fn 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 AddPool { - pub u_pool: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_lp_token: Vec, - pub u_rate_method_id: [u8; 32usize], - pub u_decimals: substreams::scalar::BigInt, - pub u_underlying_decimals: substreams::scalar::BigInt, - pub u_has_initial_a: bool, - pub u_is_v1: bool, - } - impl AddPool { - const METHOD_ID: [u8; 4] = [41u8, 11u8, 30u8, 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::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + } + impl substreams_ethereum::Function for AddMetapool { + const NAME: &'static str = "add_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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddPool { + pub u_pool: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_lp_token: Vec, + pub u_rate_method_id: [u8; 32usize], + pub u_decimals: substreams::scalar::BigInt, + pub u_underlying_decimals: substreams::scalar::BigInt, + pub u_has_initial_a: bool, + pub u_is_v1: bool, + } + impl AddPool { + const METHOD_ID: [u8; 4] = [41u8, 11u8, 30u8, 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::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, + ethabi::ParamType::Bool, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_lp_token: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_rate_method_id: { + let mut result = [0u8; 32]; + let v = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_rate_method_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 - }, - u_decimals: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_underlying_decimals: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_has_initial_a: values + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + u_decimals: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - u_is_v1: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_underlying_decimals: { + let mut v = [0 as u8; 32]; + 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.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_has_initial_a: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + u_is_v1: 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.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), + } + .as_slice(), ), - ethabi::Token::FixedBytes( - self.u_rate_method_id.as_ref().to_vec(), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_decimals.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::FixedBytes(self.u_rate_method_id.as_ref().to_vec()), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_decimals.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_underlying_decimals.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_underlying_decimals.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Bool(self.u_has_initial_a.clone()), - ethabi::Token::Bool(self.u_is_v1.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, - } - } + ), + ethabi::Token::Bool(self.u_has_initial_a.clone()), + ethabi::Token::Bool(self.u_is_v1.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for AddPool { - const NAME: &'static str = "add_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() + pub fn 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 AddPoolWithoutUnderlying { - pub u_pool: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_lp_token: Vec, - pub u_rate_method_id: [u8; 32usize], - pub u_decimals: substreams::scalar::BigInt, - pub u_use_rates: substreams::scalar::BigInt, - pub u_has_initial_a: bool, - pub u_is_v1: bool, - } - impl AddPoolWithoutUnderlying { - const METHOD_ID: [u8; 4] = [96u8, 192u8, 111u8, 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::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + } + impl substreams_ethereum::Function for AddPool { + const NAME: &'static str = "add_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 AddPoolWithoutUnderlying { + pub u_pool: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_lp_token: Vec, + pub u_rate_method_id: [u8; 32usize], + pub u_decimals: substreams::scalar::BigInt, + pub u_use_rates: substreams::scalar::BigInt, + pub u_has_initial_a: bool, + pub u_is_v1: bool, + } + impl AddPoolWithoutUnderlying { + const METHOD_ID: [u8; 4] = [96u8, 192u8, 111u8, 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::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, + ethabi::ParamType::Bool, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_lp_token: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_rate_method_id: { + let mut result = [0u8; 32]; + let v = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_rate_method_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 - }, - u_decimals: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_use_rates: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_has_initial_a: values + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + u_decimals: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - u_is_v1: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_use_rates: { + let mut v = [0 as u8; 32]; + 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.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_has_initial_a: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + u_is_v1: 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.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_lp_token), + } + .as_slice(), ), - ethabi::Token::FixedBytes( - self.u_rate_method_id.as_ref().to_vec(), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_decimals.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_lp_token), + ), + ethabi::Token::FixedBytes(self.u_rate_method_id.as_ref().to_vec()), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_decimals.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_use_rates.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_use_rates.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Bool(self.u_has_initial_a.clone()), - ethabi::Token::Bool(self.u_is_v1.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, - } - } + ), + ethabi::Token::Bool(self.u_has_initial_a.clone()), + ethabi::Token::Bool(self.u_is_v1.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for AddPoolWithoutUnderlying { - const NAME: &'static str = "add_pool_without_underlying"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 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(), - ) + } + impl substreams_ethereum::Function for AddPoolWithoutUnderlying { + const NAME: &'static str = "add_pool_without_underlying"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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(), } + } + } + 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 EstimateGasUsed { + pub u_pool: Vec, + pub u_from: Vec, + pub u_to: Vec, + } + impl EstimateGasUsed { + const METHOD_ID: [u8; 4] = [176u8, 187u8, 54u8, 91u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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, ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - 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) + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 { + 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, } - fn encode(&self) -> Vec { - self.encode() + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(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 AddressProvider { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + } + impl substreams_ethereum::Function for EstimateGasUsed { + const NAME: &'static str = "estimate_gas_used"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for EstimateGasUsed { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct EstimateGasUsed { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, - } - impl EstimateGasUsed { - const METHOD_ID: [u8; 4] = [176u8, 187u8, 54u8, 91u8]; - pub fn decode( - call: &substreams_ethereum::pb::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::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + } + } + } + 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 u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 { - 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() + .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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 - } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for EstimateGasUsed { - const NAME: &'static str = "estimate_gas_used"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 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 GaugeController {} + impl GaugeController { + const METHOD_ID: [u8; 4] = [216u8, 185u8, 160u8, 24u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable - for EstimateGasUsed { - fn output(data: &[u8]) -> Result { - Self::output(data) + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 FindPoolForCoins1 { - pub u_from: Vec, - pub u_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()); + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), + } + } + impl substreams_ethereum::Function for GaugeController { + const NAME: &'static str = "gauge_controller"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GaugeController { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetA { + pub u_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 { + u_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.u_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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 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::Function for GetA { + const NAME: &'static str = "get_A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { - 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 FindPoolForCoins2 { - pub u_from: Vec, - pub u_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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { + 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 u_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 { + u_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.u_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]; - 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) - }, - }) + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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; 8usize]> + for GetAdminBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBalances { + pub u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 8usize, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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<[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 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::Function for GetBalances { + const NAME: &'static str = "get_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins2 { - 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 GaugeController {} - impl GaugeController { - const METHOD_ID: [u8; 4] = [216u8, 185u8, 160u8, 24u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> + for GetBalances { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub u_pool: Vec, + pub u_from: Vec, + pub u_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, ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for GaugeController { - const NAME: &'static str = "gauge_controller"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address(ethabi::Address::from_slice(&self.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeController { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + 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()) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetA { - pub u_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 { - u_pool: values + 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(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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({ + .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("one output data should have existed") - .into_uint() + .expect(INTERNAL_ERR) + .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) + 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 match_call(call: &substreams_ethereum::pb::eth::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + 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), + ] + }) } - 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) + pub fn 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) - } - fn encode(&self) -> Vec { - self.encode() + } + 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::rpc::RPCDecodable - for GetA { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + 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; 8usize]> for GetCoins { + fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub u_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 { + u_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.u_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances { - pub u_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 { - u_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.u_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 - } + 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 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::Function for GetDecimals { + const NAME: &'static str = "get_decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetAdminBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub u_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 { - u_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.u_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 - } - } - } + fn encode(&self) -> Vec { + self.encode() } - 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; 8usize]> + for GetDecimals { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees { + pub u_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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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) - }, - { + 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) - .into_int() + inner + .into_uint() .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, - } + 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, 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 - } + } + 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 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::Function for GetFees { + const NAME: &'static str = "get_fees"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoins { - pub u_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 { - u_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.u_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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> + for GetFees { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGauges { + pub u_pool: Vec, + } + impl GetGauges { + const METHOD_ID: [u8; 4] = [86u8, 5u8, 159u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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], [substreams::scalar::BigInt; 10usize]), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Int(128usize)), + 10usize, + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -1726,131 +2050,24 @@ iter.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 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; 8usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub u_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 { - u_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.u_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") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner - .into_uint() + .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + substreams::scalar::BigInt::from_signed_bytes_be(&v) }); [ iter.next().expect(INTERNAL_ERR), @@ -1861,884 +2078,567 @@ iter.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 match_call(call: &substreams_ethereum::pb::eth::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 - } + } + pub fn call( + &self, + address: Vec, + ) -> Option<([Vec; 10usize], [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 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::Function for GetGauges { + const NAME: &'static str = "get_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFees { - pub u_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 { - u_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.u_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)] - }) + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable< + ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), + > for GetGauges { + fn output( + data: &[u8], + ) -> Result< + ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLpToken { + pub arg0: Vec, + } + impl GetLpToken { + 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 { + 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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<[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(), } + } + } + impl substreams_ethereum::Function for GetLpToken { + const NAME: &'static str = "get_lp_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 GetLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNCoins { + pub u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + 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)] + }) } - 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() + pub fn 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<[substreams::scalar::BigInt; 2usize]> - for GetFees { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) + 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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauges { - pub u_pool: Vec, - } - impl GetGauges { - const METHOD_ID: [u8; 4] = [86u8, 5u8, 159u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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], [substreams::scalar::BigInt; 10usize]), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 10usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Int(128usize)), - 10usize, - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( - { - 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), - ] - }, - { - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_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<([Vec; 10usize], [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 GetNCoins { + const NAME: &'static str = "get_n_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for GetGauges { - const NAME: &'static str = "get_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - > for GetGauges { - fn output( - data: &[u8], - ) -> Result< - ([Vec; 10usize], [substreams::scalar::BigInt; 10usize]), - String, - > { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLpToken { - pub arg0: Vec, - } - impl GetLpToken { - 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 { - arg0: values + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> + for GetNCoins { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetParameters { + pub u_pool: Vec, + } + impl GetParameters { + const METHOD_ID: [u8; 4] = [31u8, 128u8, 169u8, 87u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + .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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for GetLpToken { - const NAME: &'static str = "get_lp_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 GetLpToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins { - pub u_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 { - u_pool: values + .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_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.u_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 + .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("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 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<[substreams::scalar::BigInt; 2usize]> - for GetNCoins { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetParameters { - pub u_pool: Vec, - } - impl GetParameters { - const METHOD_ID: [u8; 4] = [31u8, 128u8, 169u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + .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_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.u_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, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .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) - }, + .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_address() + .into_uint() .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) - }, - { - let mut v = [0 as u8; 32]; - values - .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, - } + .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(), + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn call( - &self, - address: Vec, - ) -> Option< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - > { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + pub fn call( + &self, + address: Vec, + ) -> Option< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetParameters { - const NAME: &'static str = "get_parameters"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetParameters { + const NAME: &'static str = "get_parameters"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::rpc::RPCDecodable< + } + impl substreams_ethereum::rpc::RPCDecodable< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > for GetParameters { + fn output( + data: &[u8], + ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, @@ -2751,478 +2651,1054 @@ substreams::scalar::BigInt, substreams::scalar::BigInt, ), - > for GetParameters { - fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(data) - } + String, + > { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolFromLpToken { - pub arg0: Vec, - } - impl GetPoolFromLpToken { - 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolFromLpToken { + pub arg0: Vec, + } + impl GetPoolFromLpToken { + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .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(), + }) } - impl substreams_ethereum::Function for GetPoolFromLpToken { - const NAME: &'static str = "get_pool_from_lp_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() - } + 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 } - impl substreams_ethereum::rpc::RPCDecodable> for GetPoolFromLpToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetRates { - pub u_pool: Vec, - } - impl GetRates { - const METHOD_ID: [u8; 4] = [206u8, 153u8, 228u8, 90u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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 output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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<[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(), } + } + } + impl substreams_ethereum::Function for GetPoolFromLpToken { + const NAME: &'static str = "get_pool_from_lp_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 GetPoolFromLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRates { + pub u_pool: Vec, + } + impl GetRates { + const METHOD_ID: [u8; 4] = [206u8, 153u8, 228u8, 90u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + 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), + ] + }) } - impl substreams_ethereum::Function for GetRates { - const NAME: &'static str = "get_rates"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + pub fn 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) - } - fn encode(&self) -> Vec { - self.encode() + } + 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::rpc::RPCDecodable<[substreams::scalar::BigInt; 8usize]> - for GetRates { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) + } + impl substreams_ethereum::Function for GetRates { + const NAME: &'static str = "get_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; 8usize]> + for GetRates { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 8usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingBalances { + pub u_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 { + u_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.u_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingBalances { - pub u_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()); + 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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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), - ] - }) + } + } + 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 u_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 { + u_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.u_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 match_call(call: &substreams_ethereum::pb::eth::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 } } - 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(), } + } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + 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::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) + 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 + } } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) + } + } + 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 GetVirtualPriceFromLpToken { + pub u_token: Vec, + } + impl GetVirtualPriceFromLpToken { + 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 { + u_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.u_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, } - fn encode(&self) -> Vec { - self.encode() + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(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<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) + } + impl substreams_ethereum::Function for GetVirtualPriceFromLpToken { + const NAME: &'static str = "get_virtual_price_from_lp_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 GetVirtualPriceFromLpToken { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins { - pub u_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()); + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 { - u_pool: values + } + } + } + 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_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::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 encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool))], - ); - 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; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result<[Vec; 8usize], String> { - Self::output(call.return_data.as_ref()) + } + } + 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 RemovePool { + pub u_pool: Vec, + } + impl RemovePool { + const METHOD_ID: [u8; 4] = [71u8, 73u8, 50u8, 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 { + u_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.u_pool))], + ); + 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(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({ + } + } + impl substreams_ethereum::Function for RemovePool { + const NAME: &'static str = "remove_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 SetCoinGasEstimates { + pub u_addr: [Vec; 10usize], + pub u_amount: [substreams::scalar::BigInt; 10usize], + } + impl SetCoinGasEstimates { + const METHOD_ID: [u8; 4] = [35u8, 127u8, 137u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 10usize, + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_addr: { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -3238,122 +3714,14 @@ iter.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 u_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 { - u_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.u_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({ + }, + u_amount: { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -3374,1124 +3742,576 @@ iter.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 GetVirtualPriceFromLpToken { - pub u_token: Vec, - } - impl GetVirtualPriceFromLpToken { - 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 { - u_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.u_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 - } - } - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_addr + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) + }, + { + let v = self + .u_amount + .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 } - impl substreams_ethereum::Function for GetVirtualPriceFromLpToken { - const NAME: &'static str = "get_virtual_price_from_lp_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() + pub fn 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 GetVirtualPriceFromLpToken { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for SetCoinGasEstimates { + const NAME: &'static str = "set_coin_gas_estimates"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[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 - } - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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() - } + 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 SetGasEstimateContract { + pub u_pool: Vec, + pub u_estimator: Vec, + } + impl SetGasEstimateContract { + const METHOD_ID: [u8; 4] = [202u8, 153u8, 27u8, 20u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_estimator: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - #[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::Address(ethabi::Address::from_slice(&self.u_pool)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_estimator), + ), + ], + ); + 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 encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for SetGasEstimateContract { + const NAME: &'static str = "set_gas_estimate_contract"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetLiquidityGauges { + pub u_pool: Vec, + pub u_liquidity_gauges: [Vec; 10usize], + } + impl SetLiquidityGauges { + const METHOD_ID: [u8; 4] = [239u8, 107u8, 151u8, 136u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - 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::ParamType::Address, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_liquidity_gauges: { + let mut iter = values .pop() - .expect("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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_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), + ] + }, + }) } - 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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + { + let v = self + .u_liquidity_gauges + .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 } - impl substreams_ethereum::rpc::RPCDecodable> for PoolList { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn 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 RemovePool { - pub u_pool: Vec, - } - impl RemovePool { - const METHOD_ID: [u8; 4] = [71u8, 73u8, 50u8, 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 { - u_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.u_pool))], - ); - 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 SetLiquidityGauges { + const NAME: &'static str = "set_liquidity_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for RemovePool { - const NAME: &'static str = "remove_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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetCoinGasEstimates { - pub u_addr: [Vec; 10usize], - pub u_amount: [substreams::scalar::BigInt; 10usize], - } - impl SetCoinGasEstimates { - const METHOD_ID: [u8; 4] = [35u8, 127u8, 137u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 10usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_addr: { - 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), - ] - }, - u_amount: { - 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), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetPoolGasEstimates { + pub u_addr: [Vec; 5usize], + pub u_amount: [[substreams::scalar::BigInt; 2usize]; 5usize], + } + impl SetPoolGasEstimates { + const METHOD_ID: [u8; 4] = [7u8, 51u8, 182u8, 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( &[ - { - let v = self - .u_addr - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .u_amount - .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) - }, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 5usize, + ), + ethabi::ParamType::FixedArray( + Box::new( + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ), + 5usize, + ), ], - ); - 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 SetCoinGasEstimates { - const NAME: &'static str = "set_coin_gas_estimates"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetGasEstimateContract { - pub u_pool: Vec, - pub u_estimator: Vec, - } - impl SetGasEstimateContract { - const METHOD_ID: [u8; 4] = [202u8, 153u8, 27u8, 20u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_pool: values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_addr: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_estimator: 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), + ] + }, + u_amount: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_estimator), - ), - ], - ); - 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 SetGasEstimateContract { - const NAME: &'static str = "set_gas_estimate_contract"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + .into_iter() + .map(|inner| { + let mut iter = inner + .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), + ] + }, + }) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetLiquidityGauges { - pub u_pool: Vec, - pub u_liquidity_gauges: [Vec; 10usize], - } - impl SetLiquidityGauges { - const METHOD_ID: [u8; 4] = [239u8, 107u8, 151u8, 136u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_liquidity_gauges: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_addr + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) + }, + { + let v = self + .u_amount + .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), - ] + let v = inner + .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) + }) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - { - let v = self - .u_liquidity_gauges - .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, - } - } + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for SetLiquidityGauges { - const NAME: &'static str = "set_liquidity_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 SetPoolGasEstimates { - pub u_addr: [Vec; 5usize], - pub u_amount: [[substreams::scalar::BigInt; 2usize]; 5usize], - } - impl SetPoolGasEstimates { - const METHOD_ID: [u8; 4] = [7u8, 51u8, 182u8, 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 5usize, - ), - ethabi::ParamType::FixedArray( - Box::new( - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ), - 5usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_addr: { - 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), - ] - }, - u_amount: { - let mut iter = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| { - let mut iter = inner - .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), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_addr - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .u_amount - .iter() - .map(|inner| { - let v = inner - .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) - }) - .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 SetPoolGasEstimates { + const NAME: &'static str = "set_pool_gas_estimates"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for SetPoolGasEstimates { - const NAME: &'static str = "set_pool_gas_estimates"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 PoolAdded { - pub pool: Vec, - pub rate_method_id: Vec, - } - impl PoolAdded { - const TOPIC_ID: [u8; 32] = [ - 228u8, - 133u8, - 193u8, - 100u8, - 121u8, - 171u8, - 112u8, - 146u8, - 192u8, - 179u8, - 252u8, - 70u8, - 73u8, - 132u8, - 60u8, - 6u8, - 190u8, - 127u8, - 7u8, - 33u8, - 148u8, - 103u8, - 82u8, - 97u8, - 89u8, - 12u8, - 132u8, - 71u8, - 58u8, - 176u8, - 174u8, - 169u8, - ]; - 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::Bytes], - log.data.as_ref(), +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct PoolAdded { + pub pool: Vec, + pub rate_method_id: Vec, + } + impl PoolAdded { + const TOPIC_ID: [u8; 32] = [ + 228u8, + 133u8, + 193u8, + 100u8, + 121u8, + 171u8, + 112u8, + 146u8, + 192u8, + 179u8, + 252u8, + 70u8, + 73u8, + 132u8, + 60u8, + 6u8, + 190u8, + 127u8, + 7u8, + 33u8, + 148u8, + 103u8, + 82u8, + 97u8, + 89u8, + 12u8, + 132u8, + 71u8, + 58u8, + 176u8, + 174u8, + 169u8, + ]; + 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::Bytes], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + pool: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - 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(), - rate_method_id: values - .pop() - .expect(INTERNAL_ERR) - .into_bytes() - .expect(INTERNAL_ERR), - }) - } + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + rate_method_id: values + .pop() + .expect(INTERNAL_ERR) + .into_bytes() + .expect(INTERNAL_ERR), + }) } - impl substreams_ethereum::Event for PoolAdded { - const NAME: &'static str = "PoolAdded"; - 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 PoolAdded { + const NAME: &'static str = "PoolAdded"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolRemoved { - pub pool: Vec, - } - impl PoolRemoved { - const TOPIC_ID: [u8; 32] = [ - 65u8, - 6u8, - 223u8, - 218u8, - 165u8, - 119u8, - 87u8, - 61u8, - 181u8, - 28u8, - 12u8, - 169u8, - 63u8, - 118u8, - 109u8, - 190u8, - 223u8, - 160u8, - 117u8, - 143u8, - 170u8, - 46u8, - 127u8, - 91u8, - 205u8, - 183u8, - 193u8, - 66u8, - 190u8, - 128u8, - 60u8, - 63u8, - ]; - 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(), + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolRemoved { + pub pool: Vec, + } + impl PoolRemoved { + const TOPIC_ID: [u8; 32] = [ + 65u8, + 6u8, + 223u8, + 218u8, + 165u8, + 119u8, + 87u8, + 61u8, + 181u8, + 28u8, + 12u8, + 169u8, + 63u8, + 118u8, + 109u8, + 190u8, + 223u8, + 160u8, + 117u8, + 143u8, + 170u8, + 46u8, + 127u8, + 91u8, + 205u8, + 183u8, + 193u8, + 66u8, + 190u8, + 128u8, + 60u8, + 63u8, + ]; + 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 ) - .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 PoolRemoved { - const NAME: &'static str = "PoolRemoved"; - 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 PoolRemoved { + const NAME: &'static str = "PoolRemoved"; + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/stable_swap_factory_ng.rs b/src/abi/curve/child_registries/stable_swap_factory_ng.rs index 26d92ef..1d537a8 100644 --- a/src/abi/curve/child_registries/stable_swap_factory_ng.rs +++ b/src/abi/curve/child_registries/stable_swap_factory_ng.rs @@ -1,879 +1,710 @@ - 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 u_id: substreams::scalar::BigInt, - pub u_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 { - u_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) - }, - u_name: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddAssetType { + pub u_id: substreams::scalar::BigInt, + pub u_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()); + } + 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 { + u_id: { + let mut v = [0 as u8; 32]; + 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.u_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") - } + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::String(self.u_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, - } - } + ), + ethabi::Token::String(self.u_name.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - 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() + pub fn 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 AddBasePool { - pub u_base_pool: Vec, - pub u_base_lp_token: Vec, - pub u_asset_types: Vec, - pub u_n_coins: substreams::scalar::BigInt, + } + 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) } - 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 { - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_base_lp_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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(), - u_n_coins: { + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddBasePool { + pub u_base_pool: Vec, + pub u_base_lp_token: Vec, + pub u_asset_types: Vec, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_base_lp_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_lp_token), - ), - { - let v = self - .u_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") - } + }) + .collect(), + u_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.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_lp_token), + ), + { + let v = self + .u_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.u_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(), + ), + )) + .collect(); + ethabi::Token::Array(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - 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 - } - } + pub fn 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for Admin { - 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 AssetTypes { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 - } + } + #[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 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::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 AssetTypes { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolAssets { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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::rpc::RPCDecodable> for Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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({ + } + #[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("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 - } + }, + }) + } + 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 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 AssetTypes { + const NAME: &'static str = "asset_types"; + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePoolData { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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>, - 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, + } + 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 } } - 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 - } + } + } + 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 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::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>, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + Vec, + ), + String, + > { + Self::output(call.return_data.as_ref()) } - impl substreams_ethereum::rpc::RPCDecodable< + pub fn output( + data: &[u8], + ) -> Result< ( Vec, Vec>, @@ -881,5307 +712,5164 @@ substreams::scalar::BigInt, Vec, ), - > for BasePoolData { - fn output( - data: &[u8], - ) -> Result< + 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() + 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) }, - }) - } - 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() + tuple_elements[4usize] + .clone() + .into_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + .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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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< + ( + 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 } } } - 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for BasePoolList { - 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 CommitTransferOwnership { - pub u_addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_addr: values + } + 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(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.u_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, + .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 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() + } + 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 u_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 { + u_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.u_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 u_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) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(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 encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployGauge { + pub u_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 { + u_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.u_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 { - u_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 DeployMetapool { + pub u_base_pool: Vec, + pub u_name: String, + pub u_symbol: String, + pub u_coin: Vec, + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_offpeg_fee_multiplier: substreams::scalar::BigInt, + pub u_ma_exp_time: substreams::scalar::BigInt, + pub u_implementation_idx: substreams::scalar::BigInt, + pub u_asset_type: substreams::scalar::BigInt, + pub u_method_id: [u8; 4usize], + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_a: { + 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.u_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( + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + 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 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 u_base_pool: Vec, - pub u_name: String, - pub u_symbol: String, - pub u_coin: Vec, - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_offpeg_fee_multiplier: substreams::scalar::BigInt, - pub u_ma_exp_time: substreams::scalar::BigInt, - pub u_implementation_idx: substreams::scalar::BigInt, - pub u_asset_type: substreams::scalar::BigInt, - pub u_method_id: [u8; 4usize], - pub u_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 { - u_base_pool: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_offpeg_fee_multiplier: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_name: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_ma_exp_time: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_coin: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementation_idx: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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) - }, - u_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) - }, - u_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) - }, - u_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) - }, - u_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) - }, - u_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 - }, - u_oracle: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_coin), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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 + }, + u_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.u_base_pool), + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), + ), + ), + ethabi::Token::FixedBytes(self.u_method_id.as_ref().to_vec()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 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 u_name: String, + pub u_symbol: String, + pub u_coins: Vec>, + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_offpeg_fee_multiplier: substreams::scalar::BigInt, + pub u_ma_exp_time: substreams::scalar::BigInt, + pub u_implementation_idx: substreams::scalar::BigInt, + pub u_asset_types: Vec, + pub u_method_ids: Vec<[u8; 4usize]>, + pub u_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::Token::FixedBytes(self.u_method_id.as_ref().to_vec()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_oracle), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::FixedBytes(4usize)), ), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_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(), + u_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 - } - } - } - } - 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 u_name: String, - pub u_symbol: String, - pub u_coins: Vec>, - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_offpeg_fee_multiplier: substreams::scalar::BigInt, - pub u_ma_exp_time: substreams::scalar::BigInt, - pub u_implementation_idx: substreams::scalar::BigInt, - pub u_asset_types: Vec, - pub u_method_ids: Vec<[u8; 4usize]>, - pub u_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 { - u_name: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_offpeg_fee_multiplier: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_coins: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_ma_exp_time: { + 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(), - u_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) - }, - u_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) - }, - u_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) - }, - u_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) - }, - u_implementation_idx: { + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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) + }, + u_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) + }) + .collect(), + u_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(), + u_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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_coins + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::Array(v) }, - u_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(), - u_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(), - u_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.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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") - } + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - { - let v = self - .u_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") - } + ), + { + let v = self + .u_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 - .u_method_ids - .iter() - .map(|inner| ethabi::Token::FixedBytes( - inner.as_ref().to_vec(), - )) - .collect(); - ethabi::Token::Array(v) - }, - { - let v = self - .u_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, + } + .as_slice(), + ), + )) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .u_method_ids + .iter() + .map(|inner| ethabi::Token::FixedBytes( + inner.as_ref().to_vec(), + )) + .collect(); + ethabi::Token::Array(v) + }, + { + let v = self + .u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + 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 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(), + } + 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 u_from: Vec, + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for FeeReceiver { - 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 FindPoolForCoins1 { - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 u_from: Vec, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { - 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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins2 { - pub u_from: Vec, - pub u_to: Vec, - pub i: substreams::scalar::BigInt, + } + 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) } - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetA { + pub u_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 { + u_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.u_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 } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { + } + } + } + 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 u_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 { + u_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.u_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]; - 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) - }, - }) + }) + .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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), ), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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 GetBalances { + const NAME: &'static str = "get_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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(), + fn 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeImplementation { - 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 GetA { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetBasePool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub u_pool: Vec, + pub u_from: Vec, + pub u_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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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({ + .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("one output data should have existed") - .into_uint() + .expect(INTERNAL_ERR) + .into_int() .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 - } + 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable - for GetA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), + } + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 } } - pub fn call( - &self, - address: Vec, - ) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + 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 u_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 { + u_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.u_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)), + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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::Function for GetDecimals { + const NAME: &'static str = "get_decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> - for GetAdminBalances { - 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 GetBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> + for GetDecimals { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees { + pub u_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 { + u_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.u_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_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.u_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( + .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("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 - } + .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 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::Function for GetFees { + const NAME: &'static str = "get_fees"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> - for GetBalances { - 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 GetBasePool { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), + } + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_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 { + u_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.u_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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for GetBasePool { - 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 GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetImplementationAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMetaNCoins { + pub u_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 { + u_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.u_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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: 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_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 match_call(call: &substreams_ethereum::pb::eth::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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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) - }, - { + 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]; - values - .pop() - .expect(INTERNAL_ERR) - .into_int() + inner + .into_uint() .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 - } + 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 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::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) } - 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 u_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 { - u_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.u_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(), + fn 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option>> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable>> for GetCoins { - 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 GetDecimals { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), + } + impl substreams_ethereum::rpc::RPCDecodable + for GetNCoins { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolAssetTypes { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call( - &self, - address: Vec, - ) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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)), + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> - for GetDecimals { - 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 GetFees { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(( - { + } + impl substreams_ethereum::rpc::RPCDecodable> + for GetPoolAssetTypes { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingBalances { + pub u_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 { + u_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.u_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]; - 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) - }, - { + }) + .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 u_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 { + u_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.u_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 u_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 { + u_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.u_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]; - 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) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + }) + .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 } } - 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 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 u_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 { + u_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.u_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 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 u_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()); + } + 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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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( + } + } + } + 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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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::Function for PoolCount { + const NAME: &'static str = "pool_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetGauge { - 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 GetImplementationAddress { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + 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_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.u_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( + .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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for PoolList { + const NAME: &'static str = "pool_list"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> - for GetImplementationAddress { - 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 PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub u_pool: Vec, + pub u_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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_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 GetMetaNCoins { - pub u_pool: 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 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 { - u_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.u_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 - } - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 u_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 { - u_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.u_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(), + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeImplementation { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call( - &self, - address: Vec, - ) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> - for GetMetapoolRates { - 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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetMathImplementation { + pub u_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 { + u_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.u_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct GetNCoins { - pub u_pool: Vec, + } + 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) } - 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 { - u_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.u_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({ + 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 u_implementation_index: substreams::scalar::BigInt, + pub u_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 { + u_implementation_index: { 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 - } - } + }, + u_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.u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable - for GetNCoins { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolAssetTypes { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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( + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetPoolImplementations { + pub u_implementation_index: substreams::scalar::BigInt, + pub u_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 { + u_implementation_index: { + let mut v = [0 as u8; 32]; 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 - } - } + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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.u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> - for GetPoolAssetTypes { - 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 GetUnderlyingBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetViewsImplementation { + pub u_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 { + u_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.u_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, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call( - &self, - address: Vec, - ) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + 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 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::Function for ViewsImplementation { + const NAME: &'static str = "views_implementation"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> - for GetUnderlyingBalances { - 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 GetUnderlyingCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + 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_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.u_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( + .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("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() - } + .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::rpc::RPCDecodable>> - for GetUnderlyingCoins { - fn output(data: &[u8]) -> Result>, String> { - Self::output(data) - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingDecimals { - pub u_pool: Vec, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - 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 { - u_pool: values + } + #[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_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.u_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( + .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("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 u_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 { - u_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.u_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 u_pool: Vec, - pub u_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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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 u_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 { - u_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.u_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 u_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 { - u_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.u_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 u_implementation_index: substreams::scalar::BigInt, - pub u_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 { - u_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) - }, - u_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.u_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.u_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 u_implementation_index: substreams::scalar::BigInt, - pub u_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 { - u_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) - }, - u_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.u_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.u_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 u_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 { - u_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.u_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 - } - } - } + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - 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) } - 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) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/tricrypto_factory_ng.rs b/src/abi/curve/child_registries/tricrypto_factory_ng.rs index b833086..0a1c90d 100644 --- a/src/abi/curve/child_registries/tricrypto_factory_ng.rs +++ b/src/abi/curve/child_registries/tricrypto_factory_ng.rs @@ -1,3795 +1,3628 @@ - 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() - } - } - #[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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for Admin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + 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 u_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 { + u_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.u_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 CommitTransferOwnership { - pub u_addr: 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 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 { - u_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.u_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, + 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 u_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 { + u_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.u_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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge { - pub u_pool: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(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()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + 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 u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 3usize], + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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( + .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), + ] + }, + u_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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 3usize], - pub u_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 { - u_name: values + .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_string() - .expect(INTERNAL_ERR), - u_symbol: values + .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_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_weth: values + .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_address() + .into_uint() .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), - ] + .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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_coins + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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") - } + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + { + 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 - } + } + .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 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::Function for FeeReceiver { + const NAME: &'static str = "fee_receiver"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FeeReceiver { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub u_from: Vec, - pub u_to: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for FeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins1 { + pub u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_from: Vec, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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::Function for FutureAdmin { + const NAME: &'static str = "future_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins2 { - pub u_from: Vec, - pub u_to: Vec, - pub i: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[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 } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { + } + } + } + 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 u_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 { + u_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.u_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) - }, - }) + }); + [ + 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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_pool: Vec, + pub u_from: Vec, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - ), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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( + 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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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( + .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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 match_call(call: &substreams_ethereum::pb::eth::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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeImplementation { - 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 GetBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetCoins { + const NAME: &'static str = "get_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 3usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 3usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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) - }, - { + 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) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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 - } + }); + [ + 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 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 u_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 { - u_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.u_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, + } + 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 u_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 { + u_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.u_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 } } - 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 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 3usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 3usize], String> { - Self::output(data) - } + 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 GetDecimals { - pub u_pool: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable + for GetMarketCounts { + fn output(data: &[u8]) -> Result { + Self::output(data) } - 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 { - u_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.u_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 - } + } + #[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 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::Function for MathImplementation { + const NAME: &'static str = "math_implementation"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 3usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 3usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetGauge { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), + } + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::Function for PoolCount { + const NAME: &'static str = "pool_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetGauge { - 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 GetMarketCounts { - pub coin_a: Vec, - pub coin_b: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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({ + } + 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("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 - } + }, + }) + } + 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 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 PoolImplementations { + const NAME: &'static str = "pool_implementations"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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({ + fn 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("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 - } + }, + }) + } + 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 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::Function for PoolList { + const NAME: &'static str = "pool_list"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolImplementations { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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(), + } + impl substreams_ethereum::rpc::RPCDecodable> for PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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 substreams_ethereum::rpc::RPCDecodable> for PoolImplementations { - 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 PoolList { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeImplementation { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for PoolList { - 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 SetFeeReceiver { - pub u_fee_receiver: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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 SetMathImplementation { + pub u_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 { + u_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.u_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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetGaugeImplementation { - pub u_gauge_implementation: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_gauge_implementation: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetPoolImplementation { + pub u_pool_implementation: Vec, + pub u_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 { + u_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_implementation_index: { + 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.u_gauge_implementation), + .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.u_pool_implementation), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - 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() + pub fn 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 SetMathImplementation { - pub u_math_implementation: Vec, + } + 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) } - 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 { - u_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.u_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, - } - } + fn encode(&self) -> Vec { + self.encode() } - 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 SetViewsImplementation { + pub u_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 { + u_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.u_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetPoolImplementation { - pub u_pool_implementation: Vec, - pub u_implementation_index: substreams::scalar::BigInt, + } + 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) } - 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 { - u_pool_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_pool_implementation), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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, + 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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetViewsImplementation { - pub u_views_implementation: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_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( + 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 u_old_owner: Vec, + pub u_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 { + u_old_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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::Token::Address( - ethabi::Address::from_slice(&self.u_views_implementation), + 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, ], - ); - 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(), + log.data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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 u_old_owner: Vec, - pub u_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 { - u_old_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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 u_old_fee_receiver: Vec, - pub u_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 { - u_old_fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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 u_old_gauge_implementation: Vec, - pub u_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 { - u_old_gauge_implementation: values + .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_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_gauge_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), + 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_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 u_old_math_implementation: Vec, - pub u_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 { - u_old_math_implementation: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_math_implementation: values + .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_address() + .into_uint() .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 u_implemention_id: substreams::scalar::BigInt, - pub u_old_pool_implementation: Vec, - pub u_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 { - u_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) - }, - u_old_pool_implementation: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_pool_implementation: values + .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_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 UpdateViewsImplementation { - pub u_old_views_implementation: Vec, - pub u_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 { - u_old_views_implementation: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_views_implementation: values + .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 u_old_fee_receiver: Vec, + pub u_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 { + u_old_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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 u_old_gauge_implementation: Vec, + pub u_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 { + u_old_gauge_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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 u_old_math_implementation: Vec, + pub u_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 { + u_old_math_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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 u_implemention_id: substreams::scalar::BigInt, + pub u_old_pool_implementation: Vec, + pub u_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 { + u_implemention_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) + }, + u_old_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_new_pool_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::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 u_old_views_implementation: Vec, + pub u_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 { + u_old_views_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_new_views_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - } \ No newline at end of file + } + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/child_registries/twocrypto_factory.rs b/src/abi/curve/child_registries/twocrypto_factory.rs index 14de2b5..f0a614f 100644 --- a/src/abi/curve/child_registries/twocrypto_factory.rs +++ b/src/abi/curve/child_registries/twocrypto_factory.rs @@ -1,3827 +1,3654 @@ - 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() - } - } - #[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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for Admin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + 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 u_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 { + u_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.u_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 CommitTransferOwnership { - pub u_addr: 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 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 { - u_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.u_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, + 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 u_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 { + u_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.u_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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge { - pub u_pool: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(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()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + 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 u_name: String, + pub u_symbol: String, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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( + .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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_name: String, - pub u_symbol: String, - pub u_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 { - u_name: values + .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_string() - .expect(INTERNAL_ERR), - u_symbol: values + .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_string() - .expect(INTERNAL_ERR), - u_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) + .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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_coins + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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") - } + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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") - } + ), + 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(), - ), + } + .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, + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 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 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(), + } + 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 u_from: Vec, + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for FeeReceiver { - 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 FindPoolForCoins1 { - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 u_from: Vec, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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::Function for FutureAdmin { + const NAME: &'static str = "future_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { - 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 FindPoolForCoins2 { - pub u_from: Vec, - pub u_to: Vec, - pub i: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[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 } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { + } + } + } + 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 u_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 { + u_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.u_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) - }, - }) + }); + [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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_pool: Vec, + pub u_from: Vec, + pub u_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::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - ), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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( + 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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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( + .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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 match_call(call: &substreams_ethereum::pb::eth::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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeImplementation { - 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 GetBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetCoins { + const NAME: &'static str = "get_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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) - }, - { + 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) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + }); + [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 } } - 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 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 u_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 { + u_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.u_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 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 u_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()); + } + 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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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, - } + } + } + 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 u_fee_receiver: Vec, + pub u_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 { + u_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_fee_receiver), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, } - 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 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 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::Function for MathImplementation { + const NAME: &'static str = "math_implementation"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 2usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 2usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDecimals { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for MathImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + } + } + } + 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_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.u_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 - } + .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 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 u_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 { - u_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.u_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 PoolImplementations { + const NAME: &'static str = "pool_implementations"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetGauge { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct GetMarketCounts { - pub coin_a: Vec, - pub coin_b: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for PoolImplementations { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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({ + } + #[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("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 - } + }, + }) + } + 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 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::Function for PoolList { + const NAME: &'static str = "pool_list"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetMarketCounts { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct InitialiseOwnership { - pub u_fee_receiver: Vec, - pub u_admin: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_fee_receiver), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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::rpc::RPCDecodable> for PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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 substreams_ethereum::rpc::RPCDecodable - for PoolCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolImplementations { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeImplementation { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for PoolImplementations { - 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 PoolList { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetMathImplementation { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for PoolList { - 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 SetFeeReceiver { - pub u_fee_receiver: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_fee_receiver: values + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetPoolImplementation { + pub u_pool_implementation: Vec, + pub u_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 { + u_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_implementation_index: { + 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.u_fee_receiver), + .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.u_pool_implementation), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - 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() + pub fn 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 SetGaugeImplementation { - pub u_gauge_implementation: Vec, + } + 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) } - 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 { - u_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.u_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, - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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() + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetViewsImplementation { + pub u_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 { + u_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.u_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetMathImplementation { - pub u_math_implementation: Vec, + } + 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) } - 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 { - u_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.u_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, + 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 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() - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetPoolImplementation { - pub u_pool_implementation: Vec, - pub u_implementation_index: substreams::scalar::BigInt, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_pool_implementation: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_pool_implementation), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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, - } - } + fn encode(&self) -> Vec { + self.encode() } - 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() - } + } + impl substreams_ethereum::rpc::RPCDecodable> for ViewsImplementation { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetViewsImplementation { - pub u_views_implementation: Vec, + } +} +/// 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 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 { - u_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( + } + 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 u_old_owner: Vec, + pub u_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 { + u_old_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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::Token::Address( - ethabi::Address::from_slice(&self.u_views_implementation), + 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, ], - ); - 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(), + log.data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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 u_old_owner: Vec, - pub u_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 { - u_old_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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 u_old_fee_receiver: Vec, - pub u_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 { - u_old_fee_receiver: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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 u_old_gauge_implementation: Vec, - pub u_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 { - u_old_gauge_implementation: values + .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_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_gauge_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)] + }, + 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_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 u_old_math_implementation: Vec, - pub u_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 { - u_old_math_implementation: values + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + precisions: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_math_implementation: values + .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_address() + .into_uint() .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 u_implemention_id: substreams::scalar::BigInt, - pub u_old_pool_implementation: Vec, - pub u_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 { - u_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) - }, - u_old_pool_implementation: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_pool_implementation: values + .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_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 UpdateViewsImplementation { - pub u_old_views_implementation: Vec, - pub u_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 { - u_old_views_implementation: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_views_implementation: values + .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 u_old_fee_receiver: Vec, + pub u_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 { + u_old_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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 u_old_gauge_implementation: Vec, + pub u_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 { + u_old_gauge_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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 u_old_math_implementation: Vec, + pub u_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 { + u_old_math_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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 u_implemention_id: substreams::scalar::BigInt, + pub u_old_pool_implementation: Vec, + pub u_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 { + u_implemention_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) + }, + u_old_pool_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_new_pool_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::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 u_old_views_implementation: Vec, + pub u_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 { + u_old_views_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_new_views_implementation: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - } \ No newline at end of file + } + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/crv_token.rs b/src/abi/curve/crv_token.rs index 445448b..07c3e9e 100644 --- a/src/abi/curve/crv_token.rs +++ b/src/abi/curve/crv_token.rs @@ -1,2893 +1,2763 @@ - 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 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 - } +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 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::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 Admin { - 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 Allowance { - pub u_owner: Vec, - pub u_spender: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl Allowance { - const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + impl substreams_ethereum::rpc::RPCDecodable> for Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Allowance { + pub u_owner: Vec, + pub u_spender: Vec, + } + impl Allowance { + const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } - 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 { - u_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_owner), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + } + impl substreams_ethereum::Function for Allowance { + const NAME: &'static str = "allowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Allowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approve { + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approve { + const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Allowance { - const NAME: &'static str = "allowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Approve { + const NAME: &'static str = "approve"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Allowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Approve { - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Approve { - const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + impl substreams_ethereum::rpc::RPCDecodable for Approve { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AvailableSupply {} + impl AvailableSupply { + const METHOD_ID: [u8; 4] = [36u8, 249u8, 42u8, 37u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 Approve { - const NAME: &'static str = "approve"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for AvailableSupply { + const NAME: &'static str = "available_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Approve { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AvailableSupply {} - impl AvailableSupply { - const METHOD_ID: [u8; 4] = [36u8, 249u8, 42u8, 37u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 - } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AvailableSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BalanceOf { + pub arg0: Vec, + } + impl BalanceOf { + const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + 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::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 AvailableSupply { - const NAME: &'static str = "available_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 BalanceOf { + const NAME: &'static str = "balanceOf"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AvailableSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct BalanceOf { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl BalanceOf { - const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable + for BalanceOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Burn { + pub u_value: substreams::scalar::BigInt, + } + impl Burn { + const METHOD_ID: [u8; 4] = [66u8, 150u8, 108u8, 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::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Burn { + const NAME: &'static str = "burn"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Burn { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Decimals {} + impl Decimals { + const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for BalanceOf { - const NAME: &'static str = "balanceOf"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Decimals { + const NAME: &'static str = "decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for BalanceOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Burn { - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Burn { - const METHOD_ID: [u8; 4] = [66u8, 150u8, 108u8, 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::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + impl substreams_ethereum::rpc::RPCDecodable + for Decimals { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureEpochTimeWrite {} + impl FutureEpochTimeWrite { + const METHOD_ID: [u8; 4] = [178u8, 107u8, 35u8, 142u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for FutureEpochTimeWrite { + const NAME: &'static str = "future_epoch_time_write"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureEpochTimeWrite { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MiningEpoch {} + impl MiningEpoch { + const METHOD_ID: [u8; 4] = [249u8, 164u8, 11u8, 246u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 Burn { - const NAME: &'static str = "burn"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 MiningEpoch { + const NAME: &'static str = "mining_epoch"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Burn { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Decimals {} - impl Decimals { - const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for MiningEpoch { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Mint { + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Mint { + const METHOD_ID: [u8; 4] = [64u8, 193u8, 15u8, 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, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Decimals { - const NAME: &'static str = "decimals"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Mint { + const NAME: &'static str = "mint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Decimals { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureEpochTimeWrite {} - impl FutureEpochTimeWrite { - const METHOD_ID: [u8; 4] = [178u8, 107u8, 35u8, 142u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Mint { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MintableInTimeframe { + pub start: substreams::scalar::BigInt, + pub end: substreams::scalar::BigInt, + } + impl MintableInTimeframe { + const METHOD_ID: [u8; 4] = [215u8, 37u8, 169u8, 202u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + start: { 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 FutureEpochTimeWrite { - const NAME: &'static str = "future_epoch_time_write"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureEpochTimeWrite { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct MiningEpoch {} - impl MiningEpoch { - const METHOD_ID: [u8; 4] = [249u8, 164u8, 11u8, 246u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + end: { let mut v = [0 as u8; 32]; values .pop() - .expect("one output data should have existed") - .into_int() + .expect(INTERNAL_ERR) + .into_uint() .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, + 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.start.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.end.clone().to_bytes_be() { + (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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for MintableInTimeframe { + const NAME: &'static str = "mintable_in_timeframe"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for MintableInTimeframe { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Minter {} + impl Minter { + const METHOD_ID: [u8; 4] = [7u8, 84u8, 97u8, 114u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for MiningEpoch { - const NAME: &'static str = "mining_epoch"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Minter { + const NAME: &'static str = "minter"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for MiningEpoch { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Mint { - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Minter { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl Mint { - const METHOD_ID: [u8; 4] = [64u8, 193u8, 15u8, 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, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Name {} + impl Name { + const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Mint { - const NAME: &'static str = "mint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Name { + const NAME: &'static str = "name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Mint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct MintableInTimeframe { - pub start: substreams::scalar::BigInt, - pub end: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl MintableInTimeframe { - const METHOD_ID: [u8; 4] = [215u8, 37u8, 169u8, 202u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - start: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - end: { - let mut v = [0 as u8; 32]; - values - .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.start.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.end.clone().to_bytes_be() { - (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::rpc::RPCDecodable for Name { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Rate {} + impl Rate { + const METHOD_ID: [u8; 4] = [44u8, 78u8, 114u8, 46u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 MintableInTimeframe { - const NAME: &'static str = "mintable_in_timeframe"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Rate { + const NAME: &'static str = "rate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for MintableInTimeframe { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Minter {} - impl Minter { - const METHOD_ID: [u8; 4] = [7u8, 84u8, 97u8, 114u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Rate { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetAdmin { + pub u_admin: Vec, + } + impl SetAdmin { + const METHOD_ID: [u8; 4] = [233u8, 51u8, 63u8, 171u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 Minter { - const NAME: &'static str = "minter"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 SetAdmin { + const NAME: &'static str = "set_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Minter { - 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 Name {} - impl Name { - const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetMinter { + pub u_minter: Vec, + } + impl SetMinter { + const METHOD_ID: [u8; 4] = [22u8, 82u8, 233u8, 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], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_minter: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_minter))], + ); + 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 Name { - const NAME: &'static str = "name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for SetMinter { + const NAME: &'static str = "set_minter"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Name { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Rate {} - impl Rate { - const METHOD_ID: [u8; 4] = [44u8, 78u8, 114u8, 46u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for Rate { - const NAME: &'static str = "rate"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetName { + pub u_name: String, + pub u_symbol: String, + } + impl SetName { + const METHOD_ID: [u8; 4] = [225u8, 67u8, 14u8, 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::String, ethabi::ParamType::String], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.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::rpc::RPCDecodable - for Rate { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for SetName { + const NAME: &'static str = "set_name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetAdmin { - pub u_admin: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl SetAdmin { - const METHOD_ID: [u8; 4] = [233u8, 51u8, 63u8, 171u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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, + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct StartEpochTime {} + impl StartEpochTime { + const METHOD_ID: [u8; 4] = [115u8, 117u8, 190u8, 38u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 SetAdmin { - const NAME: &'static str = "set_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::Function for StartEpochTime { + const NAME: &'static str = "start_epoch_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetMinter { - pub u_minter: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl SetMinter { - const METHOD_ID: [u8; 4] = [22u8, 82u8, 233u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_minter: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_minter), - ), - ], - ); - 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::rpc::RPCDecodable + for StartEpochTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct StartEpochTimeWrite {} + impl StartEpochTimeWrite { + const METHOD_ID: [u8; 4] = [173u8, 196u8, 207u8, 67u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 SetMinter { - const NAME: &'static str = "set_minter"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 StartEpochTimeWrite { + const NAME: &'static str = "start_epoch_time_write"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetName { - pub u_name: String, - pub u_symbol: String, + fn encode(&self) -> Vec { + self.encode() } - impl SetName { - const METHOD_ID: [u8; 4] = [225u8, 67u8, 14u8, 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()); + } + impl substreams_ethereum::rpc::RPCDecodable + for StartEpochTimeWrite { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Symbol {} + impl Symbol { + const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } - let mut values = ethabi::decode( - &[ethabi::ParamType::String, ethabi::ParamType::String], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.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 Symbol { + const NAME: &'static str = "symbol"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Symbol { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TotalSupply {} + impl TotalSupply { + const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for SetName { - const NAME: &'static str = "set_name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct StartEpochTime {} - impl StartEpochTime { - const METHOD_ID: [u8; 4] = [115u8, 117u8, 190u8, 38u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + } + impl substreams_ethereum::Function for TotalSupply { + const NAME: &'static str = "totalSupply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for StartEpochTime { - const NAME: &'static str = "start_epoch_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Transfer { + const NAME: &'static str = "transfer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for StartEpochTime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct StartEpochTimeWrite {} - impl StartEpochTimeWrite { - const METHOD_ID: [u8; 4] = [173u8, 196u8, 207u8, 67u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Transfer { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferFrom { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl TransferFrom { + const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for StartEpochTimeWrite { - const NAME: &'static str = "start_epoch_time_write"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 TransferFrom { + const NAME: &'static str = "transferFrom"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for StartEpochTimeWrite { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Symbol {} - impl Symbol { - const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for Symbol { - const NAME: &'static str = "symbol"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable for Symbol { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateMiningParameters {} + impl UpdateMiningParameters { + const METHOD_ID: [u8; 4] = [212u8, 59u8, 64u8, 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 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 TotalSupply {} - impl TotalSupply { - const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), + } + impl substreams_ethereum::Function for UpdateMiningParameters { + const NAME: &'static str = "update_mining_parameters"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Approval { + pub u_owner: Vec, + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approval { + const TOPIC_ID: [u8; 32] = [ + 140u8, + 91u8, + 225u8, + 229u8, + 235u8, + 236u8, + 125u8, + 91u8, + 209u8, + 79u8, + 113u8, + 66u8, + 125u8, + 30u8, + 132u8, + 243u8, + 221u8, + 3u8, + 20u8, + 192u8, + 247u8, + 178u8, + 41u8, + 30u8, + 91u8, + 32u8, + 10u8, + 200u8, + 199u8, + 195u8, + 185u8, + 37u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'u_owner' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'u_spender' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 TotalSupply { - const NAME: &'static str = "totalSupply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + }, + }) } - impl substreams_ethereum::rpc::RPCDecodable - for TotalSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Event for Approval { + const NAME: &'static str = "Approval"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl Transfer { - const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetAdmin { + pub admin: Vec, + } + impl SetAdmin { + const TOPIC_ID: [u8; 32] = [ + 90u8, + 39u8, + 36u8, + 3u8, + 180u8, + 2u8, + 216u8, + 146u8, + 151u8, + 125u8, + 245u8, + 102u8, + 37u8, + 244u8, + 22u8, + 76u8, + 202u8, + 247u8, + 12u8, + 163u8, + 134u8, + 57u8, + 145u8, + 196u8, + 62u8, + 207u8, + 231u8, + 106u8, + 105u8, + 5u8, + 176u8, + 161u8, + ]; + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Transfer { - const NAME: &'static str = "transfer"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::rpc::RPCDecodable for Transfer { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Event for SetAdmin { + const NAME: &'static str = "SetAdmin"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferFrom { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl TransferFrom { - const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetMinter { + pub minter: Vec, + } + impl SetMinter { + const TOPIC_ID: [u8; 32] = [ + 206u8, + 197u8, + 33u8, + 150u8, + 233u8, + 114u8, + 4u8, + 78u8, + 221u8, + 232u8, + 104u8, + 154u8, + 27u8, + 96u8, + 142u8, + 69u8, + 156u8, + 89u8, + 70u8, + 183u8, + 243u8, + 229u8, + 200u8, + 205u8, + 61u8, + 109u8, + 142u8, + 18u8, + 109u8, + 66u8, + 46u8, + 28u8, + ]; + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + minter: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for TransferFrom { - const NAME: &'static str = "transferFrom"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Event for SetMinter { + const NAME: &'static str = "SetMinter"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateMiningParameters {} - impl UpdateMiningParameters { - const METHOD_ID: [u8; 4] = [212u8, 59u8, 64u8, 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 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(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl substreams_ethereum::Function for UpdateMiningParameters { - const NAME: &'static str = "update_mining_parameters"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Approval { - pub u_owner: Vec, - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Approval { - const TOPIC_ID: [u8; 32] = [ - 140u8, - 91u8, - 225u8, - 229u8, - 235u8, - 236u8, - 125u8, - 91u8, - 209u8, - 79u8, - 113u8, - 66u8, - 125u8, - 30u8, - 132u8, - 243u8, - 221u8, - 3u8, - 20u8, - 192u8, - 247u8, - 178u8, - 41u8, - 30u8, - 91u8, - 32u8, - 10u8, - 200u8, - 199u8, - 195u8, - 185u8, - 37u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 242u8, + 82u8, + 173u8, + 27u8, + 226u8, + 200u8, + 155u8, + 105u8, + 194u8, + 176u8, + 104u8, + 252u8, + 55u8, + 141u8, + 170u8, + 149u8, + 43u8, + 167u8, + 241u8, + 99u8, + 196u8, + 161u8, + 22u8, + 40u8, + 245u8, + 90u8, + 77u8, + 245u8, + 35u8, + 179u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_owner: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_owner' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_from' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_spender' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Approval { - const NAME: &'static str = "Approval"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetAdmin { - pub admin: Vec, - } - impl SetAdmin { - const TOPIC_ID: [u8; 32] = [ - 90u8, - 39u8, - 36u8, - 3u8, - 180u8, - 2u8, - 216u8, - 146u8, - 151u8, - 125u8, - 245u8, - 102u8, - 37u8, - 244u8, - 22u8, - 76u8, - 202u8, - 247u8, - 12u8, - 163u8, - 134u8, - 57u8, - 145u8, - 196u8, - 62u8, - 207u8, - 231u8, - 106u8, - 105u8, - 5u8, - 176u8, - 161u8, - ]; - 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( + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values + .map_err(|e| { + format!( + "unable to decode param 'u_to' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + 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 SetAdmin { - const NAME: &'static str = "SetAdmin"; - 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 SetMinter { - pub minter: Vec, - } - impl SetMinter { - const TOPIC_ID: [u8; 32] = [ - 206u8, - 197u8, - 33u8, - 150u8, - 233u8, - 114u8, - 4u8, - 78u8, - 221u8, - 232u8, - 104u8, - 154u8, - 27u8, - 96u8, - 142u8, - 69u8, - 156u8, - 89u8, - 70u8, - 183u8, - 243u8, - 229u8, - 200u8, - 205u8, - 61u8, - 109u8, - 142u8, - 18u8, - 109u8, - 66u8, - 46u8, - 28u8, - ]; - 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 { - minter: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Transfer { + const NAME: &'static str = "Transfer"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateMiningParameters { + pub time: substreams::scalar::BigInt, + pub rate: substreams::scalar::BigInt, + pub supply: substreams::scalar::BigInt, + } + impl UpdateMiningParameters { + const TOPIC_ID: [u8; 32] = [ + 39u8, + 228u8, + 99u8, + 98u8, + 161u8, + 230u8, + 18u8, + 155u8, + 109u8, + 213u8, + 57u8, + 201u8, + 132u8, + 206u8, + 115u8, + 146u8, + 145u8, + 169u8, + 113u8, + 40u8, + 223u8, + 202u8, + 236u8, + 161u8, + 37u8, + 94u8, + 138u8, + 200u8, + 58u8, + 189u8, + 148u8, + 65u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + time: { + 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 SetMinter { - const NAME: &'static str = "SetMinter"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Transfer { - const TOPIC_ID: [u8; 32] = [ - 221u8, - 242u8, - 82u8, - 173u8, - 27u8, - 226u8, - 200u8, - 155u8, - 105u8, - 194u8, - 176u8, - 104u8, - 252u8, - 55u8, - 141u8, - 170u8, - 149u8, - 43u8, - 167u8, - 241u8, - 99u8, - 196u8, - 161u8, - 22u8, - 40u8, - 245u8, - 90u8, - 77u8, - 245u8, - 35u8, - 179u8, - 239u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_from' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + rate: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_to' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Transfer { - const NAME: &'static str = "Transfer"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateMiningParameters { - pub time: substreams::scalar::BigInt, - pub rate: substreams::scalar::BigInt, - pub supply: substreams::scalar::BigInt, - } - impl UpdateMiningParameters { - const TOPIC_ID: [u8; 32] = [ - 39u8, - 228u8, - 99u8, - 98u8, - 161u8, - 230u8, - 18u8, - 155u8, - 109u8, - 213u8, - 57u8, - 201u8, - 132u8, - 206u8, - 115u8, - 146u8, - 145u8, - 169u8, - 113u8, - 40u8, - 223u8, - 202u8, - 236u8, - 161u8, - 37u8, - 94u8, - 138u8, - 200u8, - 58u8, - 189u8, - 148u8, - 65u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - rate: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - supply: { - let mut v = [0 as u8; 32]; - values - .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 UpdateMiningParameters { - const NAME: &'static str = "UpdateMiningParameters"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - } \ No newline at end of file + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for UpdateMiningParameters { + const NAME: &'static str = "UpdateMiningParameters"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/gauge_controller.rs b/src/abi/curve/gauge_controller.rs index 486352b..ca00806 100644 --- a/src/abi/curve/gauge_controller.rs +++ b/src/abi/curve/gauge_controller.rs @@ -1,4988 +1,4806 @@ - 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 AddGauge1 { - pub addr: Vec, - pub gauge_type: substreams::scalar::BigInt, - } - impl AddGauge1 { - const METHOD_ID: [u8; 4] = [58u8, 4u8, 249u8, 0u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Int(128usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - addr: values +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 AddGauge1 { + pub addr: Vec, + pub gauge_type: substreams::scalar::BigInt, + } + impl AddGauge1 { + const METHOD_ID: [u8; 4] = [58u8, 4u8, 249u8, 0u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Int(128usize)], + 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(), + gauge_type: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge_type: { - 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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.addr)), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.addr)), + { + let non_full_signed_bytes = self.gauge_type.to_signed_bytes_be(); + let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 + == 0x80 { - let non_full_signed_bytes = self - .gauge_type - .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()), - ) - }, - ], - ); - 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, - } - } + 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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for AddGauge1 { - const NAME: &'static str = "add_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() + pub fn 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 AddGauge2 { - pub addr: Vec, - pub gauge_type: substreams::scalar::BigInt, - pub weight: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for AddGauge1 { + const NAME: &'static str = "add_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) } - impl AddGauge2 { - const METHOD_ID: [u8; 4] = [24u8, 223u8, 233u8, 33u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - addr: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddGauge2 { + pub addr: Vec, + pub gauge_type: substreams::scalar::BigInt, + pub weight: substreams::scalar::BigInt, + } + impl AddGauge2 { + const METHOD_ID: [u8; 4] = [24u8, 223u8, 233u8, 33u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + 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(), + gauge_type: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge_type: { - 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) - }, - weight: { - let mut v = [0 as u8; 32]; - values - .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.addr)), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + weight: { + let mut v = [0 as u8; 32]; + values + .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.addr)), + { + let non_full_signed_bytes = self.gauge_type.to_signed_bytes_be(); + let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 + == 0x80 { - let non_full_signed_bytes = self - .gauge_type - .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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.weight.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + 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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.weight.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for AddGauge2 { - const NAME: &'static str = "add_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() + pub fn 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 AddType1 { - pub u_name: String, + } + impl substreams_ethereum::Function for AddGauge2 { + const NAME: &'static str = "add_gauge2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl AddType1 { - const METHOD_ID: [u8; 4] = [38u8, 229u8, 109u8, 94u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[ethabi::Token::String(self.u_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 decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for AddType1 { - const NAME: &'static str = "add_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() + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddType1 { + pub u_name: String, + } + impl AddType1 { + const METHOD_ID: [u8; 4] = [38u8, 229u8, 109u8, 94u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ethabi::Token::String(self.u_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct AddType2 { - pub u_name: String, - pub weight: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for AddType1 { + const NAME: &'static str = "add_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) } - impl AddType2 { - const METHOD_ID: [u8; 4] = [146u8, 208u8, 210u8, 50u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_name: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddType2 { + pub u_name: String, + pub weight: substreams::scalar::BigInt, + } + impl AddType2 { + const METHOD_ID: [u8; 4] = [146u8, 208u8, 210u8, 50u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + weight: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - weight: { - let mut v = [0 as u8; 32]; - values - .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.u_name.clone()), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.weight.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .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.u_name.clone()), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.weight.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for AddType2 { - const NAME: &'static str = "add_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() - } - } - #[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 - } - } + pub fn 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 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::Function for AddType2 { + const NAME: &'static str = "add_type2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Admin { - 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 ApplyTransferOwnership {} - impl ApplyTransferOwnership { - const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 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() + } + } + #[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 ApplyTransferOwnership { - const NAME: &'static str = "apply_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 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 ApplyTransferOwnership {} + impl ApplyTransferOwnership { + const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 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 ChangeGaugeWeight { - pub addr: Vec, - pub weight: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for ApplyTransferOwnership { + const NAME: &'static str = "apply_transfer_ownership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl ChangeGaugeWeight { - const METHOD_ID: [u8; 4] = [212u8, 210u8, 100u8, 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::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - addr: values + 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 ChangeGaugeWeight { + pub addr: Vec, + pub weight: substreams::scalar::BigInt, + } + impl ChangeGaugeWeight { + const METHOD_ID: [u8; 4] = [212u8, 210u8, 100u8, 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::Address, ethabi::ParamType::Uint(256usize)], + 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(), + weight: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - weight: { - let mut v = [0 as u8; 32]; - values - .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.addr)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.weight.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .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.addr)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.weight.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for ChangeGaugeWeight { - const NAME: &'static str = "change_gauge_weight"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 ChangeTypeWeight { - pub type_id: substreams::scalar::BigInt, - pub weight: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for ChangeGaugeWeight { + const NAME: &'static str = "change_gauge_weight"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl ChangeTypeWeight { - const METHOD_ID: [u8; 4] = [219u8, 28u8, 162u8, 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - type_id: { - 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) - }, - weight: { - let mut v = [0 as u8; 32]; - values - .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( + 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 ChangeTypeWeight { + pub type_id: substreams::scalar::BigInt, + pub weight: substreams::scalar::BigInt, + } + impl ChangeTypeWeight { + const METHOD_ID: [u8; 4] = [219u8, 28u8, 162u8, 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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + type_id: { + 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) + }, + weight: { + let mut v = [0 as u8; 32]; + values + .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( + &[ + { + let non_full_signed_bytes = self.type_id.to_signed_bytes_be(); + let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 + == 0x80 { - let non_full_signed_bytes = self - .type_id - .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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.weight.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + 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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.weight.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for ChangeTypeWeight { - const NAME: &'static str = "change_type_weight"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Checkpoint {} - impl Checkpoint { - const METHOD_ID: [u8; 4] = [194u8, 196u8, 197u8, 193u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 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 Checkpoint { - const NAME: &'static str = "checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 ChangeTypeWeight { + const NAME: &'static str = "change_type_weight"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CheckpointGauge { - pub addr: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl CheckpointGauge { - const METHOD_ID: [u8; 4] = [97u8, 94u8, 82u8, 55u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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, - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for CheckpointGauge { - const NAME: &'static str = "checkpoint_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() + } + #[derive(Debug, Clone, PartialEq)] + pub struct Checkpoint {} + impl Checkpoint { + const METHOD_ID: [u8; 4] = [194u8, 196u8, 197u8, 193u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitTransferOwnership { - pub addr: Vec, + } + impl substreams_ethereum::Function for Checkpoint { + const NAME: &'static str = "checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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, - } + 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 CheckpointGauge { + pub addr: Vec, + } + impl CheckpointGauge { + const METHOD_ID: [u8; 4] = [97u8, 94u8, 82u8, 55u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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 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(), + } + impl substreams_ethereum::Function for CheckpointGauge { + const NAME: &'static str = "checkpoint_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() + } + } + #[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, } - pub fn 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 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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 GaugeRelativeWeight1 { + pub addr: Vec, + } + impl GaugeRelativeWeight1 { + const METHOD_ID: [u8; 4] = [98u8, 7u8, 216u8, 102u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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 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 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::Function for GaugeRelativeWeight1 { + const NAME: &'static str = "gauge_relative_weight1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { - 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 GaugeRelativeWeight1 { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GaugeRelativeWeight1 { - const METHOD_ID: [u8; 4] = [98u8, 7u8, 216u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 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({ + } + impl substreams_ethereum::rpc::RPCDecodable + for GaugeRelativeWeight1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeRelativeWeight2 { + pub addr: Vec, + pub time: substreams::scalar::BigInt, + } + impl GaugeRelativeWeight2 { + const METHOD_ID: [u8; 4] = [211u8, 7u8, 140u8, 148u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + time: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.addr)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.time.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn 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 GaugeRelativeWeight1 { - const NAME: &'static str = "gauge_relative_weight1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GaugeRelativeWeight2 { + const NAME: &'static str = "gauge_relative_weight2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GaugeRelativeWeight1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeRelativeWeight2 { - pub addr: Vec, - pub time: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GaugeRelativeWeight2 { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl GaugeRelativeWeight2 { - const METHOD_ID: [u8; 4] = [211u8, 7u8, 140u8, 148u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 GaugeRelativeWeightWrite1 { + pub addr: Vec, + } + impl GaugeRelativeWeightWrite1 { + const METHOD_ID: [u8; 4] = [149u8, 207u8, 206u8, 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 { + 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 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 } - 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 { - addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.addr)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.time.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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({ + } + } + impl substreams_ethereum::Function for GaugeRelativeWeightWrite1 { + const NAME: &'static str = "gauge_relative_weight_write1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GaugeRelativeWeightWrite1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeRelativeWeightWrite2 { + pub addr: Vec, + pub time: substreams::scalar::BigInt, + } + impl GaugeRelativeWeightWrite2 { + const METHOD_ID: [u8; 4] = [100u8, 114u8, 238u8, 225u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + time: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.addr)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.time.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn 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 GaugeRelativeWeight2 { - const NAME: &'static str = "gauge_relative_weight2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GaugeRelativeWeightWrite2 { + const NAME: &'static str = "gauge_relative_weight_write2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GaugeRelativeWeight2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeRelativeWeightWrite1 { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GaugeRelativeWeightWrite1 { - const METHOD_ID: [u8; 4] = [149u8, 207u8, 206u8, 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 { - 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 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({ + } + impl substreams_ethereum::rpc::RPCDecodable + for GaugeRelativeWeightWrite2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeTypeNames { + pub arg0: substreams::scalar::BigInt, + } + impl GaugeTypeNames { + const METHOD_ID: [u8; 4] = [217u8, 88u8, 168u8, 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::Int(128usize)], + 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_uint() + .expect(INTERNAL_ERR) + .into_int() .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 - } + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.arg0.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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(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 GaugeRelativeWeightWrite1 { - const NAME: &'static str = "gauge_relative_weight_write1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GaugeTypeNames { + const NAME: &'static str = "gauge_type_names"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GaugeRelativeWeightWrite1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeRelativeWeightWrite2 { - pub addr: Vec, - pub time: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl GaugeRelativeWeightWrite2 { - const METHOD_ID: [u8; 4] = [100u8, 114u8, 238u8, 225u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + impl substreams_ethereum::rpc::RPCDecodable for GaugeTypeNames { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeTypes { + pub u_addr: Vec, + } + impl GaugeTypes { + const METHOD_ID: [u8; 4] = [63u8, 144u8, 149u8, 183u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_addr))], + ); + let mut encoded = Vec::with_capacity(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 } - 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 { - addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.addr)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.time.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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({ + } + } + impl substreams_ethereum::Function for GaugeTypes { + const NAME: &'static str = "gauge_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 GaugeTypes { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Gauges { + pub arg0: substreams::scalar::BigInt, + } + impl Gauges { + const METHOD_ID: [u8; 4] = [176u8, 83u8, 145u8, 135u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Gauges { + const NAME: &'static str = "gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Gauges { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetGaugeWeight { + pub addr: Vec, + } + impl GetGaugeWeight { + const METHOD_ID: [u8; 4] = [78u8, 121u8, 26u8, 58u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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 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 GaugeRelativeWeightWrite2 { - const NAME: &'static str = "gauge_relative_weight_write2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetGaugeWeight { + const NAME: &'static str = "get_gauge_weight"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GaugeRelativeWeightWrite2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeTypeNames { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetGaugeWeight { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl GaugeTypeNames { - const METHOD_ID: [u8; 4] = [217u8, 88u8, 168u8, 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetTotalWeight {} + impl GetTotalWeight { + const METHOD_ID: [u8; 4] = [105u8, 119u8, 255u8, 146u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Int(128usize)], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let non_full_signed_bytes = self.arg0.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()), - ) - }, - ], - ); - let mut encoded = Vec::with_capacity(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( + } + } + impl substreams_ethereum::Function for GetTotalWeight { + const NAME: &'static str = "get_total_weight"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetTotalWeight { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetTypeWeight { + pub type_id: substreams::scalar::BigInt, + } + impl GetTypeWeight { + const METHOD_ID: [u8; 4] = [114u8, 253u8, 204u8, 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::Int(128usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + type_id: { + let mut v = [0 as u8; 32]; values .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + .expect(INTERNAL_ERR) + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.type_id.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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 GaugeTypeNames { - const NAME: &'static str = "gauge_type_names"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetTypeWeight { + const NAME: &'static str = "get_type_weight"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for GaugeTypeNames { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeTypes { - pub u_addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GaugeTypes { - const METHOD_ID: [u8; 4] = [63u8, 144u8, 149u8, 183u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_addr))], - ); - let mut encoded = Vec::with_capacity(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({ + } + impl substreams_ethereum::rpc::RPCDecodable + for GetTypeWeight { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetWeightsSumPerType { + pub type_id: substreams::scalar::BigInt, + } + impl GetWeightsSumPerType { + const METHOD_ID: [u8; 4] = [111u8, 33u8, 74u8, 106u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Int(128usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + type_id: { let mut v = [0 as u8; 32]; values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.type_id.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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(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 GaugeTypes { - const NAME: &'static str = "gauge_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::Function for GetWeightsSumPerType { + const NAME: &'static str = "get_weights_sum_per_type"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GaugeTypes { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct Gauges { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable + for GetWeightsSumPerType { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl Gauges { - const METHOD_ID: [u8; 4] = [176u8, 83u8, 145u8, 135u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 LastUserVote { + pub arg0: Vec, + pub arg1: Vec, + } + impl LastUserVote { + const METHOD_ID: [u8; 4] = [126u8, 65u8, 143u8, 160u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 } - 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(), + } + } + impl substreams_ethereum::Function for LastUserVote { + const NAME: &'static str = "last_user_vote"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for LastUserVote { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct NGaugeTypes {} + impl NGaugeTypes { + const METHOD_ID: [u8; 4] = [159u8, 186u8, 3u8, 161u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for NGaugeTypes { + const NAME: &'static str = "n_gauge_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 NGaugeTypes { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct NGauges {} + impl NGauges { + const METHOD_ID: [u8; 4] = [233u8, 56u8, 65u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + 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 Gauges { - const NAME: &'static str = "gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 NGauges { + const NAME: &'static str = "n_gauges"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Gauges { - 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 GetGaugeWeight { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetGaugeWeight { - const METHOD_ID: [u8; 4] = [78u8, 121u8, 26u8, 58u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 + } + impl substreams_ethereum::rpc::RPCDecodable for NGauges { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PointsSum { + pub arg0: substreams::scalar::BigInt, + pub arg1: substreams::scalar::BigInt, + } + impl PointsSum { + const METHOD_ID: [u8; 4] = [169u8, 180u8, 140u8, 1u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(128usize), + 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_int() .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 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({ + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + arg1: { 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 GetGaugeWeight { - const NAME: &'static str = "get_gauge_weight"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for GetGaugeWeight { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetTotalWeight {} - impl GetTotalWeight { - const METHOD_ID: [u8; 4] = [105u8, 119u8, 255u8, 146u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.arg0.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()), + ) + }, + 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<(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("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 GetTotalWeight { - const NAME: &'static str = "get_total_weight"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for GetTotalWeight { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetTypeWeight { - pub type_id: substreams::scalar::BigInt, - } - impl GetTypeWeight { - const METHOD_ID: [u8; 4] = [114u8, 253u8, 204u8, 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::Int(128usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - type_id: { - 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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let non_full_signed_bytes = self - .type_id - .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()), - ) - }, - ], - ); - let mut encoded = Vec::with_capacity(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") + .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 - } + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::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 GetTypeWeight { - const NAME: &'static str = "get_type_weight"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 PointsSum { + const NAME: &'static str = "points_sum"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetTypeWeight { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetWeightsSumPerType { - pub type_id: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl GetWeightsSumPerType { - const METHOD_ID: [u8; 4] = [111u8, 33u8, 74u8, 106u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Int(128usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - type_id: { - 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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let non_full_signed_bytes = self - .type_id - .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()), - ) - }, - ], - ); - let mut encoded = Vec::with_capacity(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({ + } + impl substreams_ethereum::rpc::RPCDecodable< + (substreams::scalar::BigInt, substreams::scalar::BigInt), + > for PointsSum { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PointsTotal { + pub arg0: substreams::scalar::BigInt, + } + impl PointsTotal { + const METHOD_ID: [u8; 4] = [17u8, 66u8, 145u8, 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("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 - } + }, + }) + } + 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::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 GetWeightsSumPerType { - const NAME: &'static str = "get_weights_sum_per_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::Function for PointsTotal { + const NAME: &'static str = "points_total"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetWeightsSumPerType { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct LastUserVote { - pub arg0: Vec, - pub arg1: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl LastUserVote { - const METHOD_ID: [u8; 4] = [126u8, 65u8, 143u8, 160u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for PointsTotal { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PointsTypeWeight { + pub arg0: substreams::scalar::BigInt, + pub arg1: substreams::scalar::BigInt, + } + impl PointsTypeWeight { + const METHOD_ID: [u8; 4] = [175u8, 210u8, 187u8, 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::Token::Address(ethabi::Address::from_slice(&self.arg0)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + 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_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 LastUserVote { - const NAME: &'static str = "last_user_vote"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for LastUserVote { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct NGaugeTypes {} - impl NGaugeTypes { - const METHOD_ID: [u8; 4] = [159u8, 186u8, 3u8, 161u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 NGaugeTypes { - const NAME: &'static str = "n_gauge_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 NGaugeTypes { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct NGauges {} - impl NGauges { - const METHOD_ID: [u8; 4] = [233u8, 56u8, 65u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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({ + }, + arg1: { let mut v = [0 as u8; 32]; values .pop() - .expect("one output data should have existed") - .into_int() + .expect(INTERNAL_ERR) + .into_uint() .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 NGauges { - const NAME: &'static str = "n_gauges"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for NGauges { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PointsSum { - pub arg0: substreams::scalar::BigInt, - pub arg1: substreams::scalar::BigInt, + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl PointsSum { - const METHOD_ID: [u8; 4] = [169u8, 180u8, 140u8, 1u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_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( - &[ - { - let non_full_signed_bytes = self.arg0.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()), - ) - }, - 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< - (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) - }, + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ { - let mut v = [0 as u8; 32]; - values - .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 PointsSum { - const NAME: &'static str = "points_sum"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - 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 PointsSum { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PointsTotal { - pub arg0: substreams::scalar::BigInt, - } - impl PointsTotal { - const METHOD_ID: [u8; 4] = [17u8, 66u8, 145u8, 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) + let non_full_signed_bytes = self.arg0.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()), + ) }, - }) - } - 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") - } + 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(), - ), + } + .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 - } + ), + ], + ); + let mut encoded = Vec::with_capacity(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 PointsTotal { - const NAME: &'static str = "points_total"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 PointsTypeWeight { + const NAME: &'static str = "points_type_weight"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for PointsTotal { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PointsTypeWeight { - pub arg0: substreams::scalar::BigInt, - pub arg1: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl PointsTypeWeight { - const METHOD_ID: [u8; 4] = [175u8, 210u8, 187u8, 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::Int(128usize), - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_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( - &[ - { - let non_full_signed_bytes = self.arg0.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()), - ) - }, - 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 { - 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({ + } + impl substreams_ethereum::rpc::RPCDecodable + for PointsTypeWeight { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PointsWeight { + pub arg0: Vec, + pub arg1: substreams::scalar::BigInt, + } + impl PointsWeight { + const METHOD_ID: [u8; 4] = [237u8, 186u8, 82u8, 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::Uint(256usize)], + 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(), + arg1: { 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 PointsTypeWeight { - const NAME: &'static str = "points_type_weight"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for PointsTypeWeight { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PointsWeight { - pub arg0: Vec, - pub arg1: substreams::scalar::BigInt, - } - impl PointsWeight { - const METHOD_ID: [u8; 4] = [237u8, 186u8, 82u8, 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::Uint(256usize)], - 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(), - 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::Address(ethabi::Address::from_slice(&self.arg0)), - 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") - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg0)), + 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(), - ), + } + .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), - 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 PointsWeight { - const NAME: &'static str = "points_weight"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - 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 PointsWeight { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TimeSum { - pub arg0: substreams::scalar::BigInt, - } - impl TimeSum { - const METHOD_ID: [u8; 4] = [90u8, 84u8, 145u8, 88u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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( + ), + ], + ); + let mut encoded = Vec::with_capacity(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::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::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + 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("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 TimeSum { - const NAME: &'static str = "time_sum"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for TimeSum { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TimeTotal {} - impl TimeTotal { - const METHOD_ID: [u8; 4] = [81u8, 56u8, 114u8, 189u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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") + .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 - } + }, + )) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::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 TimeTotal { - const NAME: &'static str = "time_total"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 PointsWeight { + const NAME: &'static str = "points_weight"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for TimeTotal { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct TimeTypeWeight { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl TimeTypeWeight { - const METHOD_ID: [u8; 4] = [81u8, 206u8, 107u8, 89u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - 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({ + } + impl substreams_ethereum::rpc::RPCDecodable< + (substreams::scalar::BigInt, substreams::scalar::BigInt), + > for PointsWeight { + fn output( + data: &[u8], + ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TimeSum { + pub arg0: substreams::scalar::BigInt, + } + impl TimeSum { + const METHOD_ID: [u8; 4] = [90u8, 84u8, 145u8, 88u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for TimeSum { + const NAME: &'static str = "time_sum"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for TimeSum { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TimeTotal {} + impl TimeTotal { + const METHOD_ID: [u8; 4] = [81u8, 56u8, 114u8, 189u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 TimeTypeWeight { - const NAME: &'static str = "time_type_weight"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 TimeTotal { + const NAME: &'static str = "time_total"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for TimeTypeWeight { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct TimeWeight { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl TimeWeight { - const METHOD_ID: [u8; 4] = [164u8, 215u8, 162u8, 80u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable + for TimeTotal { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TimeTypeWeight { + pub arg0: substreams::scalar::BigInt, + } + impl TimeTypeWeight { + const METHOD_ID: [u8; 4] = [81u8, 206u8, 107u8, 89u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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::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 TimeWeight { - const NAME: &'static str = "time_weight"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for TimeWeight { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Token {} - impl Token { - const METHOD_ID: [u8; 4] = [252u8, 12u8, 84u8, 106u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::Function for TimeTypeWeight { + const NAME: &'static str = "time_type_weight"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TimeTypeWeight { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TimeWeight { + pub arg0: Vec, + } + impl TimeWeight { + const METHOD_ID: [u8; 4] = [164u8, 215u8, 162u8, 80u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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::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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for TimeWeight { + const NAME: &'static str = "time_weight"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TimeWeight { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Token {} + impl Token { + const METHOD_ID: [u8; 4] = [252u8, 12u8, 84u8, 106u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Token { - const NAME: &'static str = "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::Function for Token { + const NAME: &'static str = "token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Token { - 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 VoteForGaugeWeights { - pub u_gauge_addr: Vec, - pub u_user_weight: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl VoteForGaugeWeights { - const METHOD_ID: [u8; 4] = [215u8, 19u8, 99u8, 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::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_gauge_addr: values + } + impl substreams_ethereum::rpc::RPCDecodable> for Token { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct VoteForGaugeWeights { + pub u_gauge_addr: Vec, + pub u_user_weight: substreams::scalar::BigInt, + } + impl VoteForGaugeWeights { + const METHOD_ID: [u8; 4] = [215u8, 19u8, 99u8, 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::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_user_weight: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_user_weight: { - let mut v = [0 as u8; 32]; - values - .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.u_gauge_addr), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_user_weight.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .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.u_gauge_addr), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_user_weight.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for VoteForGaugeWeights { - const NAME: &'static str = "vote_for_gauge_weights"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 VoteUserPower { - pub arg0: Vec, + } + impl substreams_ethereum::Function for VoteForGaugeWeights { + const NAME: &'static str = "vote_for_gauge_weights"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl VoteUserPower { - const METHOD_ID: [u8; 4] = [65u8, 30u8, 116u8, 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct VoteUserPower { + pub arg0: Vec, + } + impl VoteUserPower { + const METHOD_ID: [u8; 4] = [65u8, 30u8, 116u8, 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::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::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 } - let 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 + } + } + } + impl substreams_ethereum::Function for VoteUserPower { + const NAME: &'static str = "vote_user_power"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for VoteUserPower { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct VoteUserSlopes { + pub arg0: Vec, + pub arg1: Vec, + } + impl VoteUserSlopes { + const METHOD_ID: [u8; 4] = [15u8, 70u8, 127u8, 152u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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, + ), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + 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_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 { - 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({ + .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("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 match_call(call: &substreams_ethereum::pb::eth::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, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 VoteUserSlopes { + const NAME: &'static str = "vote_user_slopes"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + 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, + ), + > for VoteUserSlopes { + fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct VotingEscrow {} + impl VotingEscrow { + const METHOD_ID: [u8; 4] = [223u8, 224u8, 80u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for VoteUserPower { - const NAME: &'static str = "vote_user_power"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 VotingEscrow { + const NAME: &'static str = "voting_escrow"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for VoteUserPower { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct VoteUserSlopes { - pub arg0: Vec, - pub arg1: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl VoteUserSlopes { - const METHOD_ID: [u8; 4] = [15u8, 70u8, 127u8, 152u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - arg0: values + } + impl substreams_ethereum::rpc::RPCDecodable> for VotingEscrow { + 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 AddType { + pub name: String, + pub type_id: substreams::scalar::BigInt, + } + impl AddType { + const TOPIC_ID: [u8; 32] = [ + 111u8, + 190u8, + 118u8, + 21u8, + 124u8, + 113u8, + 47u8, + 22u8, + 181u8, + 163u8, + 196u8, + 78u8, + 212u8, + 139u8, + 170u8, + 4u8, + 227u8, + 69u8, + 11u8, + 195u8, + 250u8, + 176u8, + 192u8, + 32u8, + 232u8, + 72u8, + 172u8, + 167u8, + 43u8, + 188u8, + 204u8, + 132u8, + ]; + 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::String, ethabi::ParamType::Int(128usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + type_id: { + 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 AddType { + const NAME: &'static str = "AddType"; + 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 ApplyOwnership { + pub admin: Vec, + } + impl ApplyOwnership { + const TOPIC_ID: [u8; 32] = [ + 235u8, + 238u8, + 45u8, + 87u8, + 57u8, + 1u8, + 16u8, + 98u8, + 203u8, + 79u8, + 20u8, + 17u8, + 63u8, + 59u8, + 54u8, + 191u8, + 15u8, + 254u8, + 61u8, + 165u8, + 192u8, + 86u8, + 143u8, + 100u8, + 24u8, + 157u8, + 16u8, + 18u8, + 161u8, + 24u8, + 145u8, + 5u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for ApplyOwnership { + const NAME: &'static str = "ApplyOwnership"; + 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 CommitOwnership { + pub admin: Vec, + } + impl CommitOwnership { + const TOPIC_ID: [u8; 32] = [ + 47u8, + 86u8, + 129u8, + 10u8, + 107u8, + 244u8, + 10u8, + 240u8, + 89u8, + 185u8, + 109u8, + 58u8, + 234u8, + 77u8, + 181u8, + 64u8, + 129u8, + 243u8, + 120u8, + 2u8, + 154u8, + 81u8, + 131u8, + 144u8, + 73u8, + 16u8, + 147u8, + 167u8, + 182u8, + 112u8, + 50u8, + 233u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for CommitOwnership { + const NAME: &'static str = "CommitOwnership"; + 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 NewGauge { + pub addr: Vec, + pub gauge_type: substreams::scalar::BigInt, + pub weight: substreams::scalar::BigInt, + } + impl NewGauge { + const TOPIC_ID: [u8; 32] = [ + 253u8, + 85u8, + 179u8, + 25u8, + 31u8, + 156u8, + 157u8, + 217u8, + 47u8, + 79u8, + 19u8, + 77u8, + 215u8, + 0u8, + 231u8, + 215u8, + 111u8, + 106u8, + 12u8, + 131u8, + 106u8, + 8u8, + 104u8, + 112u8, + 35u8, + 214u8, + 211u8, + 143u8, + 3u8, + 235u8, + 216u8, + 119u8, + ]; + 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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge_type: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + weight: { + 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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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, - ), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - 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) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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, - ), - > { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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) + }, + }) } - impl substreams_ethereum::Function for VoteUserSlopes { - const NAME: &'static str = "vote_user_slopes"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Event for NewGauge { + const NAME: &'static str = "NewGauge"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - > for VoteUserSlopes { - fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct VotingEscrow {} - impl VotingEscrow { - const METHOD_ID: [u8; 4] = [223u8, 224u8, 80u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct NewGaugeWeight { + pub gauge_address: Vec, + pub time: substreams::scalar::BigInt, + pub weight: substreams::scalar::BigInt, + pub total_weight: substreams::scalar::BigInt, + } + impl NewGaugeWeight { + const TOPIC_ID: [u8; 32] = [ + 84u8, + 192u8, + 207u8, + 54u8, + 71u8, + 230u8, + 205u8, + 178u8, + 252u8, + 10u8, + 120u8, + 118u8, + 230u8, + 11u8, + 167u8, + 117u8, + 99u8, + 252u8, + 238u8, + 223u8, + 46u8, + 6u8, + 192u8, + 28u8, + 89u8, + 127u8, + 141u8, + 204u8, + 185u8, + 230u8, + 189u8, + 114u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 128usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + gauge_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + time: { + 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 VotingEscrow { - const NAME: &'static str = "voting_escrow"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable> for VotingEscrow { - 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 AddType { - pub name: String, - pub type_id: substreams::scalar::BigInt, - } - impl AddType { - const TOPIC_ID: [u8; 32] = [ - 111u8, - 190u8, - 118u8, - 21u8, - 124u8, - 113u8, - 47u8, - 22u8, - 181u8, - 163u8, - 196u8, - 78u8, - 212u8, - 139u8, - 170u8, - 4u8, - 227u8, - 69u8, - 11u8, - 195u8, - 250u8, - 176u8, - 192u8, - 32u8, - 232u8, - 72u8, - 172u8, - 167u8, - 43u8, - 188u8, - 204u8, - 132u8, - ]; - 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::String, ethabi::ParamType::Int(128usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - name: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + weight: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - type_id: { - 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 AddType { - const NAME: &'static str = "AddType"; - 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 ApplyOwnership { - pub admin: Vec, - } - impl ApplyOwnership { - const TOPIC_ID: [u8; 32] = [ - 235u8, - 238u8, - 45u8, - 87u8, - 57u8, - 1u8, - 16u8, - 98u8, - 203u8, - 79u8, - 20u8, - 17u8, - 63u8, - 59u8, - 54u8, - 191u8, - 15u8, - 254u8, - 61u8, - 165u8, - 192u8, - 86u8, - 143u8, - 100u8, - 24u8, - 157u8, - 16u8, - 18u8, - 161u8, - 24u8, - 145u8, - 5u8, - ]; - 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 { - admin: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + total_weight: { + 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 ApplyOwnership { - const NAME: &'static str = "ApplyOwnership"; - 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 CommitOwnership { - pub admin: Vec, - } - impl CommitOwnership { - const TOPIC_ID: [u8; 32] = [ - 47u8, - 86u8, - 129u8, - 10u8, - 107u8, - 244u8, - 10u8, - 240u8, - 89u8, - 185u8, - 109u8, - 58u8, - 234u8, - 77u8, - 181u8, - 64u8, - 129u8, - 243u8, - 120u8, - 2u8, - 154u8, - 81u8, - 131u8, - 144u8, - 73u8, - 16u8, - 147u8, - 167u8, - 182u8, - 112u8, - 50u8, - 233u8, - ]; - 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 { - admin: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for NewGaugeWeight { + const NAME: &'static str = "NewGaugeWeight"; + 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 NewTypeWeight { + pub type_id: substreams::scalar::BigInt, + pub time: substreams::scalar::BigInt, + pub weight: substreams::scalar::BigInt, + pub total_weight: substreams::scalar::BigInt, + } + impl NewTypeWeight { + const TOPIC_ID: [u8; 32] = [ + 0u8, + 23u8, + 11u8, + 205u8, + 201u8, + 9u8, + 182u8, + 172u8, + 110u8, + 18u8, + 208u8, + 32u8, + 254u8, + 137u8, + 66u8, + 37u8, + 99u8, + 18u8, + 205u8, + 205u8, + 85u8, + 95u8, + 182u8, + 215u8, + 18u8, + 137u8, + 158u8, + 186u8, + 86u8, + 210u8, + 249u8, + 1u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 128usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + type_id: { + 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 CommitOwnership { - const NAME: &'static str = "CommitOwnership"; - 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 NewGauge { - pub addr: Vec, - pub gauge_type: substreams::scalar::BigInt, - pub weight: substreams::scalar::BigInt, - } - impl NewGauge { - const TOPIC_ID: [u8; 32] = [ - 253u8, - 85u8, - 179u8, - 25u8, - 31u8, - 156u8, - 157u8, - 217u8, - 47u8, - 79u8, - 19u8, - 77u8, - 215u8, - 0u8, - 231u8, - 215u8, - 111u8, - 106u8, - 12u8, - 131u8, - 106u8, - 8u8, - 104u8, - 112u8, - 35u8, - 214u8, - 211u8, - 143u8, - 3u8, - 235u8, - 216u8, - 119u8, - ]; - 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - addr: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + time: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge_type: { - 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) - }, - weight: { - let mut v = [0 as u8; 32]; - values - .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 NewGauge { - const NAME: &'static str = "NewGauge"; - 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 NewGaugeWeight { - pub gauge_address: Vec, - pub time: substreams::scalar::BigInt, - pub weight: substreams::scalar::BigInt, - pub total_weight: substreams::scalar::BigInt, - } - impl NewGaugeWeight { - const TOPIC_ID: [u8; 32] = [ - 84u8, - 192u8, - 207u8, - 54u8, - 71u8, - 230u8, - 205u8, - 178u8, - 252u8, - 10u8, - 120u8, - 118u8, - 230u8, - 11u8, - 167u8, - 117u8, - 99u8, - 252u8, - 238u8, - 223u8, - 46u8, - 6u8, - 192u8, - 28u8, - 89u8, - 127u8, - 141u8, - 204u8, - 185u8, - 230u8, - 189u8, - 114u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 128usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - gauge_address: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + weight: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - 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) - }, - weight: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - total_weight: { - let mut v = [0 as u8; 32]; - values - .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 NewGaugeWeight { - const NAME: &'static str = "NewGaugeWeight"; - 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 NewTypeWeight { - pub type_id: substreams::scalar::BigInt, - pub time: substreams::scalar::BigInt, - pub weight: substreams::scalar::BigInt, - pub total_weight: substreams::scalar::BigInt, - } - impl NewTypeWeight { - const TOPIC_ID: [u8; 32] = [ - 0u8, - 23u8, - 11u8, - 205u8, - 201u8, - 9u8, - 182u8, - 172u8, - 110u8, - 18u8, - 208u8, - 32u8, - 254u8, - 137u8, - 66u8, - 37u8, - 99u8, - 18u8, - 205u8, - 205u8, - 85u8, - 95u8, - 182u8, - 215u8, - 18u8, - 137u8, - 158u8, - 186u8, - 86u8, - 210u8, - 249u8, - 1u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 128usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - type_id: { - 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) - }, - 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) - }, - weight: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - total_weight: { - let mut v = [0 as u8; 32]; - values - .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 NewTypeWeight { - const NAME: &'static str = "NewTypeWeight"; - 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 VoteForGauge { - pub time: substreams::scalar::BigInt, - pub user: Vec, - pub gauge_addr: Vec, - pub weight: substreams::scalar::BigInt, - } - impl VoteForGauge { - const TOPIC_ID: [u8; 32] = [ - 69u8, - 202u8, - 154u8, - 76u8, - 141u8, - 1u8, - 25u8, - 235u8, - 50u8, - 158u8, - 88u8, - 13u8, - 40u8, - 254u8, - 104u8, - 158u8, - 72u8, - 78u8, - 27u8, - 226u8, - 48u8, - 218u8, - 128u8, - 55u8, - 173u8, - 233u8, - 84u8, - 125u8, - 45u8, - 37u8, - 204u8, - 145u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 128usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, - 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 { - 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) - }, - user: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + total_weight: { + let mut v = [0 as u8; 32]; + values + .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 NewTypeWeight { + const NAME: &'static str = "NewTypeWeight"; + 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 VoteForGauge { + pub time: substreams::scalar::BigInt, + pub user: Vec, + pub gauge_addr: Vec, + pub weight: substreams::scalar::BigInt, + } + impl VoteForGauge { + const TOPIC_ID: [u8; 32] = [ + 69u8, + 202u8, + 154u8, + 76u8, + 141u8, + 1u8, + 25u8, + 235u8, + 50u8, + 158u8, + 88u8, + 13u8, + 40u8, + 254u8, + 104u8, + 158u8, + 72u8, + 78u8, + 27u8, + 226u8, + 48u8, + 218u8, + 128u8, + 55u8, + 173u8, + 233u8, + 84u8, + 125u8, + 45u8, + 37u8, + 204u8, + 145u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 128usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + 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 { + time: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge_addr: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + gauge_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + weight: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - weight: { - let mut v = [0 as u8; 32]; - values - .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_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for VoteForGauge { - const NAME: &'static str = "VoteForGauge"; - 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 VoteForGauge { + const NAME: &'static str = "VoteForGauge"; + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/gauges/liquidity_gauge_v1.rs b/src/abi/curve/gauges/liquidity_gauge_v1.rs index 5408d77..573efd2 100644 --- a/src/abi/curve/gauges/liquidity_gauge_v1.rs +++ b/src/abi/curve/gauges/liquidity_gauge_v1.rs @@ -1,2858 +1,2746 @@ - 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 ApprovedToDeposit { - pub arg0: Vec, - pub arg1: Vec, - } - impl ApprovedToDeposit { - const METHOD_ID: [u8; 4] = [225u8, 82u8, 37u8, 54u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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), +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 ApprovedToDeposit { + pub arg0: Vec, + pub arg1: Vec, + } + impl ApprovedToDeposit { + const METHOD_ID: [u8; 4] = [225u8, 82u8, 37u8, 54u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 ApprovedToDeposit { - const NAME: &'static str = "approved_to_deposit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for ApprovedToDeposit { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for ApprovedToDeposit { + const NAME: &'static str = "approved_to_deposit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct BalanceOf { - pub arg0: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl BalanceOf { - const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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::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 - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for BalanceOf { - const NAME: &'static str = "balanceOf"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::rpc::RPCDecodable for ApprovedToDeposit { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable - for BalanceOf { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct BalanceOf { + pub arg0: Vec, + } + impl BalanceOf { + const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + 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::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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimableTokens { - pub addr: Vec, + } + impl substreams_ethereum::Function for BalanceOf { + const NAME: &'static str = "balanceOf"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl ClaimableTokens { - const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::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 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 - } - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for ClaimableTokens { - const NAME: &'static str = "claimable_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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() } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableTokens { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::rpc::RPCDecodable + for BalanceOf { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct Controller {} - impl Controller { - const METHOD_ID: [u8; 4] = [247u8, 124u8, 71u8, 145u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimableTokens { + pub addr: Vec, + } + impl ClaimableTokens { + const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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 Controller { - const NAME: &'static str = "controller"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 ClaimableTokens { + const NAME: &'static str = "claimable_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Controller { - 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 CrvToken {} - impl CrvToken { - const METHOD_ID: [u8; 4] = [118u8, 216u8, 177u8, 23u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimableTokens { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Controller {} + impl Controller { + const METHOD_ID: [u8; 4] = [247u8, 124u8, 71u8, 145u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for CrvToken { - const NAME: &'static str = "crv_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::Function for Controller { + const NAME: &'static str = "controller"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for CrvToken { - 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 Deposit1 { - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Deposit1 { - const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 Controller { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CrvToken {} + impl CrvToken { + const METHOD_ID: [u8; 4] = [118u8, 216u8, 177u8, 23u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Deposit1 { - const NAME: &'static str = "deposit1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 CrvToken { + const NAME: &'static str = "crv_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit2 { - pub u_value: substreams::scalar::BigInt, - pub addr: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl Deposit2 { - const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - 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::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::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, - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for Deposit2 { - const NAME: &'static str = "deposit2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 FutureEpochTime {} - impl FutureEpochTime { - const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + } + impl substreams_ethereum::rpc::RPCDecodable> for CrvToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit1 { + pub u_value: substreams::scalar::BigInt, + } + impl Deposit1 { + const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_value: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for FutureEpochTime { - const NAME: &'static str = "future_epoch_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 FutureEpochTime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Deposit1 { + const NAME: &'static str = "deposit1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct InflationRate {} - impl InflationRate { - const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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({ + 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 Deposit2 { + pub u_value: substreams::scalar::BigInt, + pub addr: Vec, + } + impl Deposit2 { + const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { 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 - } - } - } + }, + 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::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::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 } - impl substreams_ethereum::Function for InflationRate { - const NAME: &'static str = "inflation_rate"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 InflationRate { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Deposit2 { + const NAME: &'static str = "deposit2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpoint {} - impl IntegrateCheckpoint { - const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 - } + 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 FutureEpochTime {} + impl FutureEpochTime { + const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 IntegrateCheckpoint { - const NAME: &'static str = "integrate_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureEpochTime { + const NAME: &'static str = "future_epoch_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpointOf { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl IntegrateCheckpointOf { - const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::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::rpc::RPCDecodable + for FutureEpochTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InflationRate {} + impl InflationRate { + const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + 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 IntegrateCheckpointOf { - const NAME: &'static str = "integrate_checkpoint_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 InflationRate { + const NAME: &'static str = "inflation_rate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateCheckpointOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateFraction { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl IntegrateFraction { - const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::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::rpc::RPCDecodable + for InflationRate { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpoint {} + impl IntegrateCheckpoint { + const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 IntegrateFraction { - const NAME: &'static str = "integrate_fraction"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IntegrateCheckpoint { + const NAME: &'static str = "integrate_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateFraction { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupply { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl IntegrateInvSupply { - const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - 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, + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpointOf { + pub arg0: Vec, + } + impl IntegrateCheckpointOf { + const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IntegrateCheckpointOf { + const NAME: &'static str = "integrate_checkpoint_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpointOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateFraction { + pub arg0: Vec, + } + impl IntegrateFraction { + const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 IntegrateInvSupply { - const NAME: &'static str = "integrate_inv_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IntegrateFraction { + const NAME: &'static str = "integrate_fraction"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupplyOf { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl IntegrateInvSupplyOf { - const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateFraction { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupply { + pub arg0: substreams::scalar::BigInt, + } + impl IntegrateInvSupply { + const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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::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 IntegrateInvSupplyOf { - const NAME: &'static str = "integrate_inv_supply_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IntegrateInvSupply { + const NAME: &'static str = "integrate_inv_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupplyOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Kick { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl Kick { - const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 Kick { - const NAME: &'static str = "kick"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct LpToken {} - impl LpToken { - const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupplyOf { + pub arg0: Vec, + } + impl IntegrateInvSupplyOf { + const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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::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 LpToken { - const NAME: &'static str = "lp_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::Function for IntegrateInvSupplyOf { + const NAME: &'static str = "integrate_inv_supply_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for LpToken { - 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 Minter {} - impl Minter { - const METHOD_ID: [u8; 4] = [7u8, 84u8, 97u8, 114u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupplyOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Kick { + pub addr: Vec, + } + impl Kick { + const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .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 Minter { - const NAME: &'static str = "minter"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Kick { + const NAME: &'static str = "kick"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Minter { - 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 Period {} - impl Period { - const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct LpToken {} + impl LpToken { + const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 LpToken { + const NAME: &'static str = "lp_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 LpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Minter {} + impl Minter { + const METHOD_ID: [u8; 4] = [7u8, 84u8, 97u8, 114u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Period { - const NAME: &'static str = "period"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Minter { + const NAME: &'static str = "minter"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Period { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PeriodTimestamp { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl PeriodTimestamp { - const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + impl substreams_ethereum::rpc::RPCDecodable> for Minter { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Period {} + impl Period { + const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - 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 { - 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({ + } + } + } + impl substreams_ethereum::Function for Period { + const NAME: &'static str = "period"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Period { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PeriodTimestamp { + pub arg0: substreams::scalar::BigInt, + } + impl PeriodTimestamp { + const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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::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 PeriodTimestamp { - const NAME: &'static str = "period_timestamp"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 PeriodTimestamp { + const NAME: &'static str = "period_timestamp"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for PeriodTimestamp { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetApproveDeposit { + pub addr: Vec, + pub can_deposit: bool, + } + impl SetApproveDeposit { + const METHOD_ID: [u8; 4] = [29u8, 39u8, 71u8, 212u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Bool], + 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(), + can_deposit: 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.addr)), + ethabi::Token::Bool(self.can_deposit.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::rpc::RPCDecodable - for PeriodTimestamp { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for SetApproveDeposit { + const NAME: &'static str = "set_approve_deposit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 TotalSupply {} + impl TotalSupply { + const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetApproveDeposit { - pub addr: Vec, - pub can_deposit: bool, + } + impl substreams_ethereum::Function for TotalSupply { + const NAME: &'static str = "totalSupply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl SetApproveDeposit { - const METHOD_ID: [u8; 4] = [29u8, 39u8, 71u8, 212u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct UserCheckpoint { + pub addr: Vec, + } + impl UserCheckpoint { + const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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 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 } - 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 { - addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - can_deposit: 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.addr)), - ethabi::Token::Bool(self.can_deposit.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 UserCheckpoint { + const NAME: &'static str = "user_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct VotingEscrow {} + impl VotingEscrow { + const METHOD_ID: [u8; 4] = [223u8, 224u8, 80u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for SetApproveDeposit { - const NAME: &'static str = "set_approve_deposit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 TotalSupply {} - impl TotalSupply { - const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::Function for VotingEscrow { + const NAME: &'static str = "voting_escrow"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for VotingEscrow { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw { + pub u_value: substreams::scalar::BigInt, + } + impl Withdraw { + const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { + u_value: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for TotalSupply { - const NAME: &'static str = "totalSupply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + pub fn 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 TotalSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Withdraw { + const NAME: &'static str = "withdraw"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct UserCheckpoint { - pub addr: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl UserCheckpoint { - const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 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), + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct WorkingBalances { + pub arg0: Vec, + } + impl WorkingBalances { + const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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::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 UserCheckpoint { - const NAME: &'static str = "user_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 WorkingBalances { + const NAME: &'static str = "working_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct VotingEscrow {} - impl VotingEscrow { - const METHOD_ID: [u8; 4] = [223u8, 224u8, 80u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for VotingEscrow { - const NAME: &'static str = "voting_escrow"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::rpc::RPCDecodable + for WorkingBalances { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable> for VotingEscrow { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct WorkingSupply {} + impl WorkingSupply { + const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw { - pub u_value: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for WorkingSupply { + const NAME: &'static str = "working_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl Withdraw { - const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 Withdraw { - const NAME: &'static str = "withdraw"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 WorkingBalances { - pub arg0: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable + for WorkingSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl WorkingBalances { - const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Deposit { + const TOPIC_ID: [u8; 32] = [ + 225u8, + 255u8, + 252u8, + 196u8, + 146u8, + 61u8, + 4u8, + 181u8, + 89u8, + 244u8, + 210u8, + 154u8, + 139u8, + 252u8, + 108u8, + 218u8, + 4u8, + 235u8, + 91u8, + 13u8, + 60u8, + 70u8, + 7u8, + 81u8, + 194u8, + 64u8, + 44u8, + 92u8, + 92u8, + 201u8, + 16u8, + 156u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: 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::Uint(256usize)], - data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { 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 WorkingBalances { - const NAME: &'static str = "working_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::Event for Deposit { + const NAME: &'static str = "Deposit"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingBalances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingSupply {} - impl WorkingSupply { - const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 UpdateLiquidityLimit { + pub user: Vec, + pub original_balance: substreams::scalar::BigInt, + pub original_supply: substreams::scalar::BigInt, + pub working_balance: substreams::scalar::BigInt, + pub working_supply: substreams::scalar::BigInt, + } + impl UpdateLiquidityLimit { + const TOPIC_ID: [u8; 32] = [ + 126u8, + 205u8, + 132u8, + 52u8, + 63u8, + 118u8, + 162u8, + 61u8, + 34u8, + 39u8, + 41u8, + 14u8, + 2u8, + 136u8, + 218u8, + 50u8, + 81u8, + 176u8, + 69u8, + 84u8, + 22u8, + 152u8, + 229u8, + 117u8, + 165u8, + 81u8, + 90u8, + 244u8, + 240u8, + 65u8, + 151u8, + 163u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + original_balance: { 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 WorkingSupply { - const NAME: &'static str = "working_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingSupply { - 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 Deposit { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Deposit { - const TOPIC_ID: [u8; 32] = [ - 225u8, - 255u8, - 252u8, - 196u8, - 146u8, - 61u8, - 4u8, - 181u8, - 89u8, - 244u8, - 210u8, - 154u8, - 139u8, - 252u8, - 108u8, - 218u8, - 4u8, - 235u8, - 91u8, - 13u8, - 60u8, - 70u8, - 7u8, - 81u8, - 194u8, - 64u8, - 44u8, - 92u8, - 92u8, - 201u8, - 16u8, - 156u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + }, + original_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Deposit { - const NAME: &'static str = "Deposit"; - 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 UpdateLiquidityLimit { - pub user: Vec, - pub original_balance: substreams::scalar::BigInt, - pub original_supply: substreams::scalar::BigInt, - pub working_balance: substreams::scalar::BigInt, - pub working_supply: substreams::scalar::BigInt, - } - impl UpdateLiquidityLimit { - const TOPIC_ID: [u8; 32] = [ - 126u8, - 205u8, - 132u8, - 52u8, - 63u8, - 118u8, - 162u8, - 61u8, - 34u8, - 39u8, - 41u8, - 14u8, - 2u8, - 136u8, - 218u8, - 50u8, - 81u8, - 176u8, - 69u8, - 84u8, - 22u8, - 152u8, - 229u8, - 117u8, - 165u8, - 81u8, - 90u8, - 244u8, - 240u8, - 65u8, - 151u8, - 163u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - user: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_balance: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - original_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - original_supply: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_supply: { - let mut v = [0 as u8; 32]; - values - .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 UpdateLiquidityLimit { - const NAME: &'static str = "UpdateLiquidityLimit"; - 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 Withdraw { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Withdraw { - const TOPIC_ID: [u8; 32] = [ - 136u8, - 78u8, - 218u8, - 217u8, - 206u8, - 111u8, - 162u8, - 68u8, - 13u8, - 138u8, - 84u8, - 204u8, - 18u8, - 52u8, - 144u8, - 235u8, - 150u8, - 210u8, - 118u8, - 132u8, - 121u8, - 212u8, - 159u8, - 249u8, - 199u8, - 54u8, - 97u8, - 37u8, - 169u8, - 66u8, - 67u8, - 100u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_supply: { + let mut v = [0 as u8; 32]; + values + .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 UpdateLiquidityLimit { + const NAME: &'static str = "UpdateLiquidityLimit"; + 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 Withdraw { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Withdraw { + const TOPIC_ID: [u8; 32] = [ + 136u8, + 78u8, + 218u8, + 217u8, + 206u8, + 111u8, + 162u8, + 68u8, + 13u8, + 138u8, + 84u8, + 204u8, + 18u8, + 52u8, + 144u8, + 235u8, + 150u8, + 210u8, + 118u8, + 132u8, + 121u8, + 212u8, + 159u8, + 249u8, + 199u8, + 54u8, + 97u8, + 37u8, + 169u8, + 66u8, + 67u8, + 100u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Withdraw { - const NAME: &'static str = "Withdraw"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - } \ No newline at end of file + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Withdraw { + const NAME: &'static str = "Withdraw"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/gauges/liquidity_gauge_v2.rs b/src/abi/curve/gauges/liquidity_gauge_v2.rs index 21ac7ee..29c4454 100644 --- a/src/abi/curve/gauges/liquidity_gauge_v2.rs +++ b/src/abi/curve/gauges/liquidity_gauge_v2.rs @@ -1,5745 +1,5491 @@ - 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 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 - } + 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::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 Admin { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct Allowance { - pub u_owner: Vec, - pub u_spender: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl Allowance { - const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct Allowance { + pub u_owner: Vec, + pub u_spender: Vec, + } + impl Allowance { + const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } - 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 { - u_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_owner), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + } + impl substreams_ethereum::Function for Allowance { + const NAME: &'static str = "allowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Allowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approve { + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approve { + const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Approve { + const NAME: &'static str = "approve"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Approve { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ApprovedToDeposit { + pub arg0: Vec, + pub arg1: Vec, + } + impl ApprovedToDeposit { + const METHOD_ID: [u8; 4] = [225u8, 82u8, 37u8, 54u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 Allowance { - const NAME: &'static str = "allowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for ApprovedToDeposit { + const NAME: &'static str = "approved_to_deposit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Allowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Approve { - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Approve { - const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + impl substreams_ethereum::rpc::RPCDecodable for ApprovedToDeposit { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BalanceOf { + pub arg0: Vec, + } + impl BalanceOf { + const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + 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::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 } - 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 { - u_spender: values + } + } + } + impl substreams_ethereum::Function for BalanceOf { + const NAME: &'static str = "balanceOf"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for BalanceOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimHistoricRewards1 { + pub u_reward_tokens: [Vec; 8usize], + } + impl ClaimHistoricRewards1 { + const METHOD_ID: [u8; 4] = [185u8, 250u8, 122u8, 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::FixedArray( + Box::new(ethabi::ParamType::Address), + 8usize, + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_reward_tokens: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + .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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_reward_tokens + .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, } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for ClaimHistoricRewards1 { + const NAME: &'static str = "claim_historic_rewards1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimHistoricRewards2 { + pub u_reward_tokens: [Vec; 8usize], + pub u_addr: Vec, + } + impl ClaimHistoricRewards2 { + const METHOD_ID: [u8; 4] = [122u8, 34u8, 239u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 8usize, ), + ethabi::ParamType::Address, ], - ); - let mut encoded = Vec::with_capacity(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), + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_reward_tokens: { + 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), + ] + }, + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_reward_tokens + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) + }, + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_addr)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for Approve { - const NAME: &'static str = "approve"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + pub fn 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 Approve { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for ClaimHistoricRewards2 { + const NAME: &'static str = "claim_historic_rewards2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ApprovedToDeposit { - pub arg0: Vec, - pub arg1: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl ApprovedToDeposit { - const METHOD_ID: [u8; 4] = [225u8, 82u8, 37u8, 54u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimRewards1 {} + impl ClaimRewards1 { + const METHOD_ID: [u8; 4] = [230u8, 241u8, 218u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg0)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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), + } + } + impl substreams_ethereum::Function for ClaimRewards1 { + const NAME: &'static str = "claim_rewards1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards2 { + pub u_addr: Vec, + } + impl ClaimRewards2 { + const METHOD_ID: [u8; 4] = [132u8, 233u8, 189u8, 126u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 ApprovedToDeposit { - const NAME: &'static str = "approved_to_deposit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 ClaimRewards2 { + const NAME: &'static str = "claim_rewards2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for ApprovedToDeposit { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct BalanceOf { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl BalanceOf { - const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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::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 - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimableReward { + pub u_addr: Vec, + pub u_token: Vec, + } + impl ClaimableReward { + const METHOD_ID: [u8; 4] = [51u8, 253u8, 111u8, 116u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 BalanceOf { - const NAME: &'static str = "balanceOf"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for ClaimableReward { + const NAME: &'static str = "claimable_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for BalanceOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimHistoricRewards1 { - pub u_reward_tokens: [Vec; 8usize], + fn encode(&self) -> Vec { + self.encode() } - impl ClaimHistoricRewards1 { - const METHOD_ID: [u8; 4] = [185u8, 250u8, 122u8, 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 8usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_reward_tokens: { - 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), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_reward_tokens - .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::rpc::RPCDecodable + for ClaimableReward { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimableTokens { + pub addr: Vec, + } + impl ClaimableTokens { + const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::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 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 ClaimHistoricRewards1 { - const NAME: &'static str = "claim_historic_rewards1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 ClaimableTokens { + const NAME: &'static str = "claimable_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimableTokens { + fn output(data: &[u8]) -> Result { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimHistoricRewards2 { - pub u_reward_tokens: [Vec; 8usize], - pub u_addr: 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) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl ClaimHistoricRewards2 { - const METHOD_ID: [u8; 4] = [122u8, 34u8, 239u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 Controller {} + impl Controller { + const METHOD_ID: [u8; 4] = [247u8, 124u8, 71u8, 145u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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::FixedArray( - Box::new(ethabi::ParamType::Address), - 8usize, - ), - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_reward_tokens: { - 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), - ] - }, - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_reward_tokens - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 Controller { + const NAME: &'static str = "controller"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Controller { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CrvToken {} + impl CrvToken { + const METHOD_ID: [u8; 4] = [118u8, 216u8, 177u8, 23u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for ClaimHistoricRewards2 { - const NAME: &'static str = "claim_historic_rewards2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards1 {} - impl ClaimRewards1 { - const METHOD_ID: [u8; 4] = [230u8, 241u8, 218u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 CrvToken { + const NAME: &'static str = "crv_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 CrvToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Decimals {} + impl Decimals { + const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(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 ClaimRewards1 { - const NAME: &'static str = "claim_rewards1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Decimals { + const NAME: &'static str = "decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimRewards2 { - pub u_addr: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl ClaimRewards2 { - const METHOD_ID: [u8; 4] = [132u8, 233u8, 189u8, 126u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_addr: values + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Decimals { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DecreaseAllowance { + pub u_spender: Vec, + pub u_subtracted_value: substreams::scalar::BigInt, + } + impl DecreaseAllowance { + const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_subtracted_value: { + 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.u_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, + .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.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_subtracted_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for ClaimRewards2 { - const NAME: &'static str = "claim_rewards2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimableReward { - pub u_addr: Vec, - pub u_token: Vec, - } - impl ClaimableReward { - const METHOD_ID: [u8; 4] = [51u8, 253u8, 111u8, 116u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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 ClaimableReward { - const NAME: &'static str = "claimable_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableReward { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimableTokens { - pub addr: Vec, - } - impl ClaimableTokens { - const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::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 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 ClaimableTokens { - const NAME: &'static str = "claimable_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableTokens { - fn output(data: &[u8]) -> Result { - 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 Controller {} - impl Controller { - const METHOD_ID: [u8; 4] = [247u8, 124u8, 71u8, 145u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Controller { - const NAME: &'static str = "controller"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable> for Controller { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CrvToken {} - impl CrvToken { - const METHOD_ID: [u8; 4] = [118u8, 216u8, 177u8, 23u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for CrvToken { - const NAME: &'static str = "crv_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 CrvToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Decimals {} - impl Decimals { - const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(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 Decimals { - const NAME: &'static str = "decimals"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Decimals { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DecreaseAllowance { - pub u_spender: Vec, - pub u_subtracted_value: substreams::scalar::BigInt, - } - impl DecreaseAllowance { - const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_subtracted_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_subtracted_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for DecreaseAllowance { - const NAME: &'static str = "decreaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit1 { - pub u_value: substreams::scalar::BigInt, - } - impl Deposit1 { - const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 Deposit1 { - const NAME: &'static str = "deposit1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Deposit2 { - pub u_value: substreams::scalar::BigInt, - pub u_addr: Vec, - } - impl Deposit2 { - const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_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::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 Deposit2 { - const NAME: &'static str = "deposit2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 FutureEpochTime {} - impl FutureEpochTime { - const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 FutureEpochTime { - const NAME: &'static str = "future_epoch_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureEpochTime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IncreaseAllowance { - pub u_spender: Vec, - pub u_added_value: substreams::scalar::BigInt, - } - impl IncreaseAllowance { - const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_added_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_added_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for IncreaseAllowance { - const NAME: &'static str = "increaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct InflationRate {} - impl InflationRate { - const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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 InflationRate { - const NAME: &'static str = "inflation_rate"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for InflationRate { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpoint {} - impl IntegrateCheckpoint { - const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 IntegrateCheckpoint { - const NAME: &'static str = "integrate_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpointOf { - pub arg0: Vec, - } - impl IntegrateCheckpointOf { - const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::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 IntegrateCheckpointOf { - const NAME: &'static str = "integrate_checkpoint_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateCheckpointOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateFraction { - pub arg0: Vec, - } - impl IntegrateFraction { - const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::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 DecreaseAllowance { + const NAME: &'static str = "decreaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for IntegrateFraction { - const NAME: &'static str = "integrate_fraction"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateFraction { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupply { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl IntegrateInvSupply { - const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - 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 Deposit1 { + pub u_value: substreams::scalar::BigInt, + } + impl Deposit1 { + const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_value: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for IntegrateInvSupply { - const NAME: &'static str = "integrate_inv_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 IntegrateInvSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Deposit1 { + const NAME: &'static str = "deposit1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupplyOf { - pub arg0: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl IntegrateInvSupplyOf { - const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit2 { + pub u_value: substreams::scalar::BigInt, + pub u_addr: Vec, + } + impl Deposit2 { + const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { 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, - } + }, + u_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::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Deposit2 { + const NAME: &'static str = "deposit2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 IntegrateInvSupplyOf { - const NAME: &'static str = "integrate_inv_supply_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureAdmin { + const NAME: &'static str = "future_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupplyOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsKilled {} - impl IsKilled { - const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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), + 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 FutureEpochTime {} + impl FutureEpochTime { + const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 IsKilled { - const NAME: &'static str = "is_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureEpochTime { + const NAME: &'static str = "future_epoch_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsKilled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Kick { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl Kick { - const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureEpochTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IncreaseAllowance { + pub u_spender: Vec, + pub u_added_value: substreams::scalar::BigInt, + } + impl IncreaseAllowance { + const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_added_value: { + 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.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, + .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.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_added_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Kick { - const NAME: &'static str = "kick"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IncreaseAllowance { + const NAME: &'static str = "increaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct LpToken {} - impl LpToken { - const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InflationRate {} + impl InflationRate { + const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 LpToken { - const NAME: &'static str = "lp_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::Function for InflationRate { + const NAME: &'static str = "inflation_rate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for LpToken { - 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 Minter {} - impl Minter { - const METHOD_ID: [u8; 4] = [7u8, 84u8, 97u8, 114u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for InflationRate { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpoint {} + impl IntegrateCheckpoint { + const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 Minter { - const NAME: &'static str = "minter"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IntegrateCheckpoint { + const NAME: &'static str = "integrate_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Minter { - 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 Name {} - impl Name { - const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpointOf { + pub arg0: Vec, + } + impl IntegrateCheckpointOf { + const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IntegrateCheckpointOf { + const NAME: &'static str = "integrate_checkpoint_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpointOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateFraction { + pub arg0: Vec, + } + impl IntegrateFraction { + const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 Name { - const NAME: &'static str = "name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for IntegrateFraction { + const NAME: &'static str = "integrate_fraction"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Name { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Period {} - impl Period { - const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateFraction { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupply { + pub arg0: substreams::scalar::BigInt, + } + impl IntegrateInvSupply { + const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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_int() + .expect(INTERNAL_ERR) + .into_uint() .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, + 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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IntegrateInvSupply { + const NAME: &'static str = "integrate_inv_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupplyOf { + pub arg0: Vec, + } + impl IntegrateInvSupplyOf { + const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], + 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::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 Period { - const NAME: &'static str = "period"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IntegrateInvSupplyOf { + const NAME: &'static str = "integrate_inv_supply_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Period { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct PeriodTimestamp { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupplyOf { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl PeriodTimestamp { - const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 IsKilled {} + impl IsKilled { + const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - 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 { - 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) - }) + } + } + impl substreams_ethereum::Function for IsKilled { + const NAME: &'static str = "is_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IsKilled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Kick { + pub addr: Vec, + } + impl Kick { + const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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, } - pub fn 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 Kick { + const NAME: &'static str = "kick"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LpToken {} + impl LpToken { + const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 LpToken { + const NAME: &'static str = "lp_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 LpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Minter {} + impl Minter { + const METHOD_ID: [u8; 4] = [7u8, 84u8, 97u8, 114u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for PeriodTimestamp { - const NAME: &'static str = "period_timestamp"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Minter { + const NAME: &'static str = "minter"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for PeriodTimestamp { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardContract {} - impl RewardContract { - const METHOD_ID: [u8; 4] = [191u8, 136u8, 166u8, 255u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn 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::rpc::RPCDecodable> for Minter { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Name {} + impl Name { + const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Name { + const NAME: &'static str = "name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Name { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Period {} + impl Period { + const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 RewardContract { - const NAME: &'static str = "reward_contract"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Period { + const NAME: &'static str = "period"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for RewardContract { - 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 RewardIntegral { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl RewardIntegral { - const METHOD_ID: [u8; 4] = [115u8, 134u8, 31u8, 179u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable for Period { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PeriodTimestamp { + pub arg0: substreams::scalar::BigInt, + } + impl PeriodTimestamp { + const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for PeriodTimestamp { + const NAME: &'static str = "period_timestamp"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for PeriodTimestamp { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardContract {} + impl RewardContract { + const METHOD_ID: [u8; 4] = [191u8, 136u8, 166u8, 255u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for RewardIntegral { - const NAME: &'static str = "reward_integral"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardContract { + const NAME: &'static str = "reward_contract"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::rpc::RPCDecodable - for RewardIntegral { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::rpc::RPCDecodable> for RewardContract { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardIntegral { + pub arg0: Vec, + } + impl RewardIntegral { + const METHOD_ID: [u8; 4] = [115u8, 134u8, 31u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + 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::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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardIntegralFor { - pub arg0: Vec, - pub arg1: Vec, + } + impl substreams_ethereum::Function for RewardIntegral { + const NAME: &'static str = "reward_integral"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RewardIntegral { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl RewardIntegralFor { - const METHOD_ID: [u8; 4] = [240u8, 92u8, 192u8, 88u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 RewardIntegralFor { + pub arg0: Vec, + pub arg1: Vec, + } + impl RewardIntegralFor { + const METHOD_ID: [u8; 4] = [240u8, 92u8, 192u8, 88u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 } - 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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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({ + } + } + impl substreams_ethereum::Function for RewardIntegralFor { + const NAME: &'static str = "reward_integral_for"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RewardIntegralFor { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardTokens { + pub arg0: substreams::scalar::BigInt, + } + impl RewardTokens { + const METHOD_ID: [u8; 4] = [84u8, 196u8, 159u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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 RewardIntegralFor { - const NAME: &'static str = "reward_integral_for"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardTokens { + const NAME: &'static str = "reward_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for RewardIntegralFor { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardTokens { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl RewardTokens { - const METHOD_ID: [u8; 4] = [84u8, 196u8, 159u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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(), + } + impl substreams_ethereum::rpc::RPCDecodable> for RewardTokens { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetApproveDeposit { + pub addr: Vec, + pub can_deposit: bool, + } + impl SetApproveDeposit { + const METHOD_ID: [u8; 4] = [29u8, 39u8, 71u8, 212u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Bool], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .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(), + can_deposit: 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.addr)), + ethabi::Token::Bool(self.can_deposit.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 RewardTokens { - const NAME: &'static str = "reward_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 SetApproveDeposit { + const NAME: &'static str = "set_approve_deposit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for RewardTokens { - 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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetKilled { + pub u_is_killed: bool, + } + impl SetKilled { + const METHOD_ID: [u8; 4] = [144u8, 178u8, 41u8, 151u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_is_killed: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ethabi::Token::Bool(self.u_is_killed.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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetApproveDeposit { - pub addr: Vec, - pub can_deposit: bool, + } + impl substreams_ethereum::Function for SetKilled { + const NAME: &'static str = "set_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetApproveDeposit { - const METHOD_ID: [u8; 4] = [29u8, 39u8, 71u8, 212u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Bool], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - addr: values + 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 SetRewards { + pub u_reward_contract: Vec, + pub u_sigs: [u8; 32usize], + pub u_reward_tokens: [Vec; 8usize], + } + impl SetRewards { + const METHOD_ID: [u8; 4] = [71u8, 210u8, 213u8, 211u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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::FixedBytes(32usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 8usize, + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_reward_contract: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_sigs: { + let mut result = [0u8; 32]; + let v = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - can_deposit: values + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + u_reward_tokens: { + let mut iter = 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.addr)), - ethabi::Token::Bool(self.can_deposit.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, - } - } + .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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_contract), + ), + ethabi::Token::FixedBytes(self.u_sigs.as_ref().to_vec()), + { + let v = self + .u_reward_tokens + .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 } - impl substreams_ethereum::Function for SetApproveDeposit { - const NAME: &'static str = "set_approve_deposit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 SetKilled { - pub u_is_killed: bool, + } + impl substreams_ethereum::Function for SetRewards { + const NAME: &'static str = "set_rewards"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetKilled { - const METHOD_ID: [u8; 4] = [144u8, 178u8, 41u8, 151u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_is_killed: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Bool(self.u_is_killed.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 decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Symbol {} + impl Symbol { + const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for SetKilled { - const NAME: &'static str = "set_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Symbol { + const NAME: &'static str = "symbol"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetRewards { - pub u_reward_contract: Vec, - pub u_sigs: [u8; 32usize], - pub u_reward_tokens: [Vec; 8usize], + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl SetRewards { - const METHOD_ID: [u8; 4] = [71u8, 210u8, 213u8, 211u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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::FixedBytes(32usize), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 8usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_reward_contract: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_sigs: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - u_reward_tokens: { - 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), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_contract), - ), - ethabi::Token::FixedBytes(self.u_sigs.as_ref().to_vec()), - { - let v = self - .u_reward_tokens - .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, - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for SetRewards { - const NAME: &'static str = "set_rewards"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Symbol {} - impl Symbol { - const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + } + impl substreams_ethereum::rpc::RPCDecodable for Symbol { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TotalSupply {} + impl TotalSupply { + const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 Symbol { - const NAME: &'static str = "symbol"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for TotalSupply { + const NAME: &'static str = "totalSupply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Symbol { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct TotalSupply {} - impl TotalSupply { - const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for TotalSupply { - const NAME: &'static str = "totalSupply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Transfer { + const NAME: &'static str = "transfer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for TotalSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Transfer { - const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_to: values + } + impl substreams_ethereum::rpc::RPCDecodable for Transfer { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferFrom { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl TransferFrom { + const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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, + ), + ], + ); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; + } + } + impl substreams_ethereum::Function for TransferFrom { + const NAME: &'static str = "transferFrom"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UserCheckpoint { + pub addr: Vec, + } + impl UserCheckpoint { + const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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 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 } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + } + impl substreams_ethereum::Function for UserCheckpoint { + const NAME: &'static str = "user_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct VotingEscrow {} + impl VotingEscrow { + const METHOD_ID: [u8; 4] = [223u8, 224u8, 80u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Transfer { - const NAME: &'static str = "transfer"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for VotingEscrow { + const NAME: &'static str = "voting_escrow"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Transfer { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferFrom { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl TransferFrom { - const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values + } + impl substreams_ethereum::rpc::RPCDecodable> for VotingEscrow { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw { + pub u_value: substreams::scalar::BigInt, + } + impl Withdraw { + const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { + u_value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .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.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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 - } - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for TransferFrom { - const NAME: &'static str = "transferFrom"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + pub fn 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 TransferFrom { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Withdraw { + const NAME: &'static str = "withdraw"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct UserCheckpoint { - pub addr: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl UserCheckpoint { - const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 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), + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct WorkingBalances { + pub arg0: Vec, + } + impl WorkingBalances { + const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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::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 UserCheckpoint { - const NAME: &'static str = "user_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 WorkingBalances { + const NAME: &'static str = "working_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct VotingEscrow {} - impl VotingEscrow { - const METHOD_ID: [u8; 4] = [223u8, 224u8, 80u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for WorkingBalances { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct WorkingSupply {} + impl WorkingSupply { + const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 VotingEscrow { - const NAME: &'static str = "voting_escrow"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 WorkingSupply { + const NAME: &'static str = "working_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for VotingEscrow { - 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 Withdraw { - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Withdraw { - const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 WorkingSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::Function for Withdraw { - const NAME: &'static str = "withdraw"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ApplyOwnership { + pub admin: Vec, + } + impl ApplyOwnership { + const TOPIC_ID: [u8; 32] = [ + 235u8, + 238u8, + 45u8, + 87u8, + 57u8, + 1u8, + 16u8, + 98u8, + 203u8, + 79u8, + 20u8, + 17u8, + 63u8, + 59u8, + 54u8, + 191u8, + 15u8, + 254u8, + 61u8, + 165u8, + 192u8, + 86u8, + 143u8, + 100u8, + 24u8, + 157u8, + 16u8, + 18u8, + 161u8, + 24u8, + 145u8, + 5u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for ApplyOwnership { + const NAME: &'static str = "ApplyOwnership"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingBalances { - pub arg0: Vec, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl WorkingBalances { - const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approval { + pub u_owner: Vec, + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approval { + const TOPIC_ID: [u8; 32] = [ + 140u8, + 91u8, + 225u8, + 229u8, + 235u8, + 236u8, + 125u8, + 91u8, + 209u8, + 79u8, + 113u8, + 66u8, + 125u8, + 30u8, + 132u8, + 243u8, + 221u8, + 3u8, + 20u8, + 192u8, + 247u8, + 178u8, + 41u8, + 30u8, + 91u8, + 32u8, + 10u8, + 200u8, + 199u8, + 195u8, + 185u8, + 37u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .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::Uint(256usize)], - data.as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_owner' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'u_spender' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 WorkingBalances { - const NAME: &'static str = "working_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::Event for Approval { + const NAME: &'static str = "Approval"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingBalances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingSupply {} - impl WorkingSupply { - const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitOwnership { + pub admin: Vec, + } + impl CommitOwnership { + const TOPIC_ID: [u8; 32] = [ + 47u8, + 86u8, + 129u8, + 10u8, + 107u8, + 244u8, + 10u8, + 240u8, + 89u8, + 185u8, + 109u8, + 58u8, + 234u8, + 77u8, + 181u8, + 64u8, + 129u8, + 243u8, + 120u8, + 2u8, + 154u8, + 81u8, + 131u8, + 144u8, + 73u8, + 16u8, + 147u8, + 167u8, + 182u8, + 112u8, + 50u8, + 233u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for CommitOwnership { + const NAME: &'static str = "CommitOwnership"; + 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 Deposit { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Deposit { + const TOPIC_ID: [u8; 32] = [ + 225u8, + 255u8, + 252u8, + 196u8, + 146u8, + 61u8, + 4u8, + 181u8, + 89u8, + 244u8, + 210u8, + 154u8, + 139u8, + 252u8, + 108u8, + 218u8, + 4u8, + 235u8, + 91u8, + 13u8, + 60u8, + 70u8, + 7u8, + 81u8, + 194u8, + 64u8, + 44u8, + 92u8, + 92u8, + 201u8, + 16u8, + 156u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { 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 WorkingSupply { - const NAME: &'static str = "working_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingSupply { - 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 ApplyOwnership { - pub admin: Vec, - } - impl ApplyOwnership { - const TOPIC_ID: [u8; 32] = [ - 235u8, - 238u8, - 45u8, - 87u8, - 57u8, - 1u8, - 16u8, - 98u8, - 203u8, - 79u8, - 20u8, - 17u8, - 63u8, - 59u8, - 54u8, - 191u8, - 15u8, - 254u8, - 61u8, - 165u8, - 192u8, - 86u8, - 143u8, - 100u8, - 24u8, - 157u8, - 16u8, - 18u8, - 161u8, - 24u8, - 145u8, - 5u8, - ]; - 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( + } + impl substreams_ethereum::Event for Deposit { + const NAME: &'static str = "Deposit"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 242u8, + 82u8, + 173u8, + 27u8, + 226u8, + 200u8, + 155u8, + 105u8, + 194u8, + 176u8, + 104u8, + 252u8, + 55u8, + 141u8, + 170u8, + 149u8, + 43u8, + 167u8, + 241u8, + 99u8, + 196u8, + 161u8, + 22u8, + 40u8, + 245u8, + 90u8, + 77u8, + 245u8, + 35u8, + 179u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for ApplyOwnership { - const NAME: &'static str = "ApplyOwnership"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Approval { - pub u_owner: Vec, - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Approval { - const TOPIC_ID: [u8; 32] = [ - 140u8, - 91u8, - 225u8, - 229u8, - 235u8, - 236u8, - 125u8, - 91u8, - 209u8, - 79u8, - 113u8, - 66u8, - 125u8, - 30u8, - 132u8, - 243u8, - 221u8, - 3u8, - 20u8, - 192u8, - 247u8, - 178u8, - 41u8, - 30u8, - 91u8, - 32u8, - 10u8, - 200u8, - 199u8, - 195u8, - 185u8, - 37u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_owner: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_owner' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_from' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_spender' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Approval { - const NAME: &'static str = "Approval"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitOwnership { - pub admin: Vec, - } - impl CommitOwnership { - const TOPIC_ID: [u8; 32] = [ - 47u8, - 86u8, - 129u8, - 10u8, - 107u8, - 244u8, - 10u8, - 240u8, - 89u8, - 185u8, - 109u8, - 58u8, - 234u8, - 77u8, - 181u8, - 64u8, - 129u8, - 243u8, - 120u8, - 2u8, - 154u8, - 81u8, - 131u8, - 144u8, - 73u8, - 16u8, - 147u8, - 167u8, - 182u8, - 112u8, - 50u8, - 233u8, - ]; - 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( + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values + .map_err(|e| { + format!( + "unable to decode param 'u_to' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + 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 CommitOwnership { - const NAME: &'static str = "CommitOwnership"; - 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 Deposit { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Deposit { - const TOPIC_ID: [u8; 32] = [ - 225u8, - 255u8, - 252u8, - 196u8, - 146u8, - 61u8, - 4u8, - 181u8, - 89u8, - 244u8, - 210u8, - 154u8, - 139u8, - 252u8, - 108u8, - 218u8, - 4u8, - 235u8, - 91u8, - 13u8, - 60u8, - 70u8, - 7u8, - 81u8, - 194u8, - 64u8, - 44u8, - 92u8, - 92u8, - 201u8, - 16u8, - 156u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Transfer { + const NAME: &'static str = "Transfer"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateLiquidityLimit { + pub user: Vec, + pub original_balance: substreams::scalar::BigInt, + pub original_supply: substreams::scalar::BigInt, + pub working_balance: substreams::scalar::BigInt, + pub working_supply: substreams::scalar::BigInt, + } + impl UpdateLiquidityLimit { + const TOPIC_ID: [u8; 32] = [ + 126u8, + 205u8, + 132u8, + 52u8, + 63u8, + 118u8, + 162u8, + 61u8, + 34u8, + 39u8, + 41u8, + 14u8, + 2u8, + 136u8, + 218u8, + 50u8, + 81u8, + 176u8, + 69u8, + 84u8, + 22u8, + 152u8, + 229u8, + 117u8, + 165u8, + 81u8, + 90u8, + 244u8, + 240u8, + 65u8, + 151u8, + 163u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + original_balance: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Deposit { - const NAME: &'static str = "Deposit"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Transfer { - const TOPIC_ID: [u8; 32] = [ - 221u8, - 242u8, - 82u8, - 173u8, - 27u8, - 226u8, - 200u8, - 155u8, - 105u8, - 194u8, - 176u8, - 104u8, - 252u8, - 55u8, - 141u8, - 170u8, - 149u8, - 43u8, - 167u8, - 241u8, - 99u8, - 196u8, - 161u8, - 22u8, - 40u8, - 245u8, - 90u8, - 77u8, - 245u8, - 35u8, - 179u8, - 239u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_from' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + original_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_to' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_balance: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Transfer { - const NAME: &'static str = "Transfer"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateLiquidityLimit { - pub user: Vec, - pub original_balance: substreams::scalar::BigInt, - pub original_supply: substreams::scalar::BigInt, - pub working_balance: substreams::scalar::BigInt, - pub working_supply: substreams::scalar::BigInt, - } - impl UpdateLiquidityLimit { - const TOPIC_ID: [u8; 32] = [ - 126u8, - 205u8, - 132u8, - 52u8, - 63u8, - 118u8, - 162u8, - 61u8, - 34u8, - 39u8, - 41u8, - 14u8, - 2u8, - 136u8, - 218u8, - 50u8, - 81u8, - 176u8, - 69u8, - 84u8, - 22u8, - 152u8, - 229u8, - 117u8, - 165u8, - 81u8, - 90u8, - 244u8, - 240u8, - 65u8, - 151u8, - 163u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - user: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - original_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - original_supply: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_supply: { - let mut v = [0 as u8; 32]; - values - .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 UpdateLiquidityLimit { - const NAME: &'static str = "UpdateLiquidityLimit"; - 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 Withdraw { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Withdraw { - const TOPIC_ID: [u8; 32] = [ - 136u8, - 78u8, - 218u8, - 217u8, - 206u8, - 111u8, - 162u8, - 68u8, - 13u8, - 138u8, - 84u8, - 204u8, - 18u8, - 52u8, - 144u8, - 235u8, - 150u8, - 210u8, - 118u8, - 132u8, - 121u8, - 212u8, - 159u8, - 249u8, - 199u8, - 54u8, - 97u8, - 37u8, - 169u8, - 66u8, - 67u8, - 100u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for UpdateLiquidityLimit { + const NAME: &'static str = "UpdateLiquidityLimit"; + 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 Withdraw { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Withdraw { + const TOPIC_ID: [u8; 32] = [ + 136u8, + 78u8, + 218u8, + 217u8, + 206u8, + 111u8, + 162u8, + 68u8, + 13u8, + 138u8, + 84u8, + 204u8, + 18u8, + 52u8, + 144u8, + 235u8, + 150u8, + 210u8, + 118u8, + 132u8, + 121u8, + 212u8, + 159u8, + 249u8, + 199u8, + 54u8, + 97u8, + 37u8, + 169u8, + 66u8, + 67u8, + 100u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for Withdraw { - const NAME: &'static str = "Withdraw"; - 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 Withdraw { + const NAME: &'static str = "Withdraw"; + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/gauges/liquidity_gauge_v3.rs b/src/abi/curve/gauges/liquidity_gauge_v3.rs index 3b7fc2b..4c681ba 100644 --- a/src/abi/curve/gauges/liquidity_gauge_v3.rs +++ b/src/abi/curve/gauges/liquidity_gauge_v3.rs @@ -1,6135 +1,5859 @@ - 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 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 - } + 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::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 Admin { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct Allowance { - pub u_owner: Vec, - pub u_spender: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl Allowance { - const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct Allowance { + pub u_owner: Vec, + pub u_spender: Vec, + } + impl Allowance { + const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } - 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 { - u_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_owner), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + } + impl substreams_ethereum::Function for Allowance { + const NAME: &'static str = "allowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Allowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approve { + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approve { + const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Allowance { - const NAME: &'static str = "allowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Approve { + const NAME: &'static str = "approve"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Allowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Approve { - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Approve { - const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + impl substreams_ethereum::rpc::RPCDecodable for Approve { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BalanceOf { + pub arg0: Vec, + } + impl BalanceOf { + const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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::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 Approve { - const NAME: &'static str = "approve"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + } + impl substreams_ethereum::Function for BalanceOf { + const NAME: &'static str = "balanceOf"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for BalanceOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimRewards1 {} + impl ClaimRewards1 { + const METHOD_ID: [u8; 4] = [230u8, 241u8, 218u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 Approve { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for ClaimRewards1 { + const NAME: &'static str = "claim_rewards1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards2 { + pub u_addr: Vec, + } + impl ClaimRewards2 { + const METHOD_ID: [u8; 4] = [132u8, 233u8, 189u8, 126u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 BalanceOf { - pub arg0: Vec, + } + impl substreams_ethereum::Function for ClaimRewards2 { + const NAME: &'static str = "claim_rewards2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl BalanceOf { - const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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::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) - }) + 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 ClaimRewards3 { + pub u_addr: Vec, + pub u_receiver: Vec, + } + impl ClaimRewards3 { + const METHOD_ID: [u8; 4] = [159u8, 172u8, 235u8, 27u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, } - pub fn 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 ClaimRewards3 { + const NAME: &'static str = "claim_rewards3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimableReward { + pub u_addr: Vec, + pub u_token: Vec, + } + impl ClaimableReward { + const METHOD_ID: [u8; 4] = [51u8, 253u8, 111u8, 116u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for ClaimableReward { + const NAME: &'static str = "claimable_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimableReward { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimableRewardWrite { + pub u_addr: Vec, + pub u_token: Vec, + } + impl ClaimableRewardWrite { + const METHOD_ID: [u8; 4] = [89u8, 183u8, 228u8, 9u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 BalanceOf { - const NAME: &'static str = "balanceOf"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for ClaimableRewardWrite { + const NAME: &'static str = "claimable_reward_write"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for BalanceOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimRewards1 {} - impl ClaimRewards1 { - const METHOD_ID: [u8; 4] = [230u8, 241u8, 218u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimableRewardWrite { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimableTokens { + pub addr: Vec, + } + impl ClaimableTokens { + const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::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 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 ClaimRewards1 { - const NAME: &'static str = "claim_rewards1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 ClaimableTokens { + const NAME: &'static str = "claimable_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimRewards2 { - pub u_addr: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl ClaimRewards2 { - const METHOD_ID: [u8; 4] = [132u8, 233u8, 189u8, 126u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimableTokens { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimedReward { + pub u_addr: Vec, + pub u_token: Vec, + } + impl ClaimedReward { + const METHOD_ID: [u8; 4] = [231u8, 126u8, 116u8, 55u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 ClaimRewards2 { - const NAME: &'static str = "claim_rewards2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 ClaimedReward { + const NAME: &'static str = "claimed_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimedReward { + fn output(data: &[u8]) -> Result { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimRewards3 { - pub u_addr: Vec, - pub u_receiver: 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) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl ClaimRewards3 { - const METHOD_ID: [u8; 4] = [159u8, 172u8, 235u8, 27u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 Controller {} + impl Controller { + const METHOD_ID: [u8; 4] = [247u8, 124u8, 71u8, 145u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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 Controller { + const NAME: &'static str = "controller"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Controller { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CrvToken {} + impl CrvToken { + const METHOD_ID: [u8; 4] = [118u8, 216u8, 177u8, 23u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for ClaimRewards3 { - const NAME: &'static str = "claim_rewards3"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 CrvToken { + const NAME: &'static str = "crv_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimableReward { - pub u_addr: Vec, - pub u_token: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl ClaimableReward { - const METHOD_ID: [u8; 4] = [51u8, 253u8, 111u8, 116u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for CrvToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Decimals {} + impl Decimals { + const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(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 } - 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 { - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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({ + } + } + impl substreams_ethereum::Function for Decimals { + const NAME: &'static str = "decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Decimals { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DecreaseAllowance { + pub u_spender: Vec, + pub u_subtracted_value: substreams::scalar::BigInt, + } + impl DecreaseAllowance { + const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_subtracted_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_subtracted_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for ClaimableReward { - const NAME: &'static str = "claimable_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableReward { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimableRewardWrite { - pub u_addr: Vec, - pub u_token: Vec, - } - impl ClaimableRewardWrite { - const METHOD_ID: [u8; 4] = [89u8, 183u8, 228u8, 9u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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 ClaimableRewardWrite { - const NAME: &'static str = "claimable_reward_write"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableRewardWrite { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimableTokens { - pub addr: Vec, - } - impl ClaimableTokens { - const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::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 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 ClaimableTokens { - const NAME: &'static str = "claimable_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableTokens { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimedReward { - pub u_addr: Vec, - pub u_token: Vec, - } - impl ClaimedReward { - const METHOD_ID: [u8; 4] = [231u8, 126u8, 116u8, 55u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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 ClaimedReward { - const NAME: &'static str = "claimed_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimedReward { - fn output(data: &[u8]) -> Result { - 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 Controller {} - impl Controller { - const METHOD_ID: [u8; 4] = [247u8, 124u8, 71u8, 145u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Controller { - const NAME: &'static str = "controller"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable> for Controller { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CrvToken {} - impl CrvToken { - const METHOD_ID: [u8; 4] = [118u8, 216u8, 177u8, 23u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for CrvToken { - const NAME: &'static str = "crv_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 CrvToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Decimals {} - impl Decimals { - const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(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 Decimals { - const NAME: &'static str = "decimals"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Decimals { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DecreaseAllowance { - pub u_spender: Vec, - pub u_subtracted_value: substreams::scalar::BigInt, - } - impl DecreaseAllowance { - const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_subtracted_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_subtracted_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for DecreaseAllowance { - const NAME: &'static str = "decreaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit1 { - pub u_value: substreams::scalar::BigInt, - } - impl Deposit1 { - const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 Deposit1 { - const NAME: &'static str = "deposit1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Deposit2 { - pub u_value: substreams::scalar::BigInt, - pub u_addr: Vec, - } - impl Deposit2 { - const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_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::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 Deposit2 { - const NAME: &'static str = "deposit2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Deposit3 { - pub u_value: substreams::scalar::BigInt, - pub u_addr: Vec, - pub u_claim_rewards: bool, - } - impl Deposit3 { - const METHOD_ID: [u8; 4] = [131u8, 223u8, 103u8, 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), - ethabi::ParamType::Address, - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_claim_rewards: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_addr), - ), - ethabi::Token::Bool(self.u_claim_rewards.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 Deposit3 { - const NAME: &'static str = "deposit3"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 FutureEpochTime {} - impl FutureEpochTime { - const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 FutureEpochTime { - const NAME: &'static str = "future_epoch_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureEpochTime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IncreaseAllowance { - pub u_spender: Vec, - pub u_added_value: substreams::scalar::BigInt, - } - impl IncreaseAllowance { - const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_added_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_added_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for IncreaseAllowance { - const NAME: &'static str = "increaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct InflationRate {} - impl InflationRate { - const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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 InflationRate { - const NAME: &'static str = "inflation_rate"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for InflationRate { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpoint {} - impl IntegrateCheckpoint { - const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 IntegrateCheckpoint { - const NAME: &'static str = "integrate_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpointOf { - pub arg0: Vec, - } - impl IntegrateCheckpointOf { - const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::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 IntegrateCheckpointOf { - const NAME: &'static str = "integrate_checkpoint_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateCheckpointOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateFraction { - pub arg0: Vec, - } - impl IntegrateFraction { - const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::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 IntegrateFraction { - const NAME: &'static str = "integrate_fraction"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateFraction { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupply { - pub arg0: substreams::scalar::BigInt, - } - impl IntegrateInvSupply { - const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - 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 IntegrateInvSupply { - const NAME: &'static str = "integrate_inv_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupplyOf { - pub arg0: Vec, - } - impl IntegrateInvSupplyOf { - const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], - 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::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 IntegrateInvSupplyOf { - const NAME: &'static str = "integrate_inv_supply_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupplyOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IsKilled {} - impl IsKilled { - const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 IsKilled { - const NAME: &'static str = "is_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for IsKilled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Kick { - pub addr: Vec, - } - impl Kick { - const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 Kick { - const NAME: &'static str = "kick"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LastClaim {} - impl LastClaim { - const METHOD_ID: [u8; 4] = [52u8, 136u8, 189u8, 25u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 LastClaim { - const NAME: &'static str = "last_claim"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for LastClaim { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct LpToken {} - impl LpToken { - const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for LpToken { - const NAME: &'static str = "lp_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 LpToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Minter {} - impl Minter { - const METHOD_ID: [u8; 4] = [7u8, 84u8, 97u8, 114u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Minter { - const NAME: &'static str = "minter"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 DecreaseAllowance { + const NAME: &'static str = "decreaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Minter { - 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 Name {} - impl Name { - const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit1 { + pub u_value: substreams::scalar::BigInt, + } + impl Deposit1 { + const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_value: { + let mut v = [0 as u8; 32]; 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 - } - } - } + .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.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for Name { - const NAME: &'static str = "name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + pub fn 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 Name { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Deposit1 { + const NAME: &'static str = "deposit1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Period {} - impl Period { - const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + 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 Deposit2 { + pub u_value: substreams::scalar::BigInt, + pub u_addr: Vec, + } + impl Deposit2 { + const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { let mut v = [0 as u8; 32]; values .pop() - .expect("one output data should have existed") - .into_int() + .expect(INTERNAL_ERR) + .into_uint() .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 - } - } - } + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_addr)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for Period { - const NAME: &'static str = "period"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 Period { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Deposit2 { + const NAME: &'static str = "deposit2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PeriodTimestamp { - pub arg0: substreams::scalar::BigInt, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl PeriodTimestamp { - const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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( + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit3 { + pub u_value: substreams::scalar::BigInt, + pub u_addr: Vec, + pub u_claim_rewards: bool, + } + impl Deposit3 { + const METHOD_ID: [u8; 4] = [131u8, 223u8, 103u8, 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::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::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::Bool, ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { 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, - } + }, + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_claim_rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_addr)), + ethabi::Token::Bool(self.u_claim_rewards.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, } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Deposit3 { + const NAME: &'static str = "deposit3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 PeriodTimestamp { - const NAME: &'static str = "period_timestamp"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureAdmin { + const NAME: &'static str = "future_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for PeriodTimestamp { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardContract {} - impl RewardContract { - const METHOD_ID: [u8; 4] = [191u8, 136u8, 166u8, 255u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + 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 FutureEpochTime {} + impl FutureEpochTime { + const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 RewardContract { - const NAME: &'static str = "reward_contract"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureEpochTime { + const NAME: &'static str = "future_epoch_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for RewardContract { - 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 RewardIntegral { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl RewardIntegral { - const METHOD_ID: [u8; 4] = [115u8, 134u8, 31u8, 179u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureEpochTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IncreaseAllowance { + pub u_spender: Vec, + pub u_added_value: substreams::scalar::BigInt, + } + impl IncreaseAllowance { + const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_added_value: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_added_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IncreaseAllowance { + const NAME: &'static str = "increaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InflationRate {} + impl InflationRate { + const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + 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 RewardIntegral { - const NAME: &'static str = "reward_integral"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 InflationRate { + const NAME: &'static str = "inflation_rate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for InflationRate { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpoint {} + impl IntegrateCheckpoint { + const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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::rpc::RPCDecodable - for RewardIntegral { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for IntegrateCheckpoint { + const NAME: &'static str = "integrate_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpointOf { + pub arg0: Vec, + } + impl IntegrateCheckpointOf { + const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardIntegralFor { - pub arg0: Vec, - pub arg1: Vec, + } + impl substreams_ethereum::Function for IntegrateCheckpointOf { + const NAME: &'static str = "integrate_checkpoint_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpointOf { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl RewardIntegralFor { - const METHOD_ID: [u8; 4] = [240u8, 92u8, 192u8, 88u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 IntegrateFraction { + pub arg0: Vec, + } + impl IntegrateFraction { + const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 } - 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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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({ + } + } + impl substreams_ethereum::Function for IntegrateFraction { + const NAME: &'static str = "integrate_fraction"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateFraction { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupply { + pub arg0: substreams::scalar::BigInt, + } + impl IntegrateInvSupply { + const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IntegrateInvSupply { + const NAME: &'static str = "integrate_inv_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupplyOf { + pub arg0: Vec, + } + impl IntegrateInvSupplyOf { + const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], + 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::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 RewardIntegralFor { - const NAME: &'static str = "reward_integral_for"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IntegrateInvSupplyOf { + const NAME: &'static str = "integrate_inv_supply_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for RewardIntegralFor { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardTokens { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl RewardTokens { - const METHOD_ID: [u8; 4] = [84u8, 196u8, 159u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupplyOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsKilled {} + impl IsKilled { + const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - 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(), + } + } + impl substreams_ethereum::Function for IsKilled { + const NAME: &'static str = "is_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IsKilled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Kick { + pub addr: Vec, + } + impl Kick { + const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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, } - pub fn 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 Kick { + const NAME: &'static str = "kick"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LastClaim {} + impl LastClaim { + const METHOD_ID: [u8; 4] = [52u8, 136u8, 189u8, 25u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; + } + } + impl substreams_ethereum::Function for LastClaim { + const NAME: &'static str = "last_claim"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for LastClaim { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct LpToken {} + impl LpToken { + const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 LpToken { + const NAME: &'static str = "lp_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 LpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Minter {} + impl Minter { + const METHOD_ID: [u8; 4] = [7u8, 84u8, 97u8, 114u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for RewardTokens { - const NAME: &'static str = "reward_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Minter { + const NAME: &'static str = "minter"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for RewardTokens { - 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 RewardsReceiver { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl RewardsReceiver { - const METHOD_ID: [u8; 4] = [1u8, 221u8, 171u8, 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(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 Minter { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Name {} + impl Name { + const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for RewardsReceiver { - const NAME: &'static str = "rewards_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::Function for Name { + const NAME: &'static str = "name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for RewardsReceiver { - 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 SetKilled { - pub u_is_killed: bool, + fn encode(&self) -> Vec { + self.encode() } - impl SetKilled { - const METHOD_ID: [u8; 4] = [144u8, 178u8, 41u8, 151u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_is_killed: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Bool(self.u_is_killed.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::rpc::RPCDecodable for Name { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Period {} + impl Period { + const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 SetKilled { - const NAME: &'static str = "set_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Period { + const NAME: &'static str = "period"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetRewards { - pub u_reward_contract: Vec, - pub u_sigs: [u8; 32usize], - pub u_reward_tokens: [Vec; 8usize], + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl SetRewards { - const METHOD_ID: [u8; 4] = [71u8, 210u8, 213u8, 211u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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::FixedBytes(32usize), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Address), - 8usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_reward_contract: values + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Period { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PeriodTimestamp { + pub arg0: substreams::scalar::BigInt, + } + impl PeriodTimestamp { + const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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(), - u_sigs: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - u_reward_tokens: { - 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), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_contract), + .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::FixedBytes(self.u_sigs.as_ref().to_vec()), - { - let v = self - .u_reward_tokens - .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, + ), + ], + ); + let mut encoded = Vec::with_capacity(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 SetRewards { - const NAME: &'static str = "set_rewards"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 PeriodTimestamp { + const NAME: &'static str = "period_timestamp"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetRewardsReceiver { - pub u_receiver: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl SetRewardsReceiver { - const METHOD_ID: [u8; 4] = [189u8, 249u8, 129u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for PeriodTimestamp { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardContract {} + impl RewardContract { + const METHOD_ID: [u8; 4] = [191u8, 136u8, 166u8, 255u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for SetRewardsReceiver { - const NAME: &'static str = "set_rewards_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 Symbol {} - impl Symbol { - const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + } + impl substreams_ethereum::Function for RewardContract { + const NAME: &'static str = "reward_contract"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for RewardContract { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardIntegral { + pub arg0: Vec, + } + impl RewardIntegral { + const METHOD_ID: [u8; 4] = [115u8, 134u8, 31u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for RewardIntegral { + const NAME: &'static str = "reward_integral"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RewardIntegral { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardIntegralFor { + pub arg0: Vec, + pub arg1: Vec, + } + impl RewardIntegralFor { + const METHOD_ID: [u8; 4] = [240u8, 92u8, 192u8, 88u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 Symbol { - const NAME: &'static str = "symbol"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for RewardIntegralFor { + const NAME: &'static str = "reward_integral_for"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Symbol { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct TotalSupply {} - impl TotalSupply { - const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RewardIntegralFor { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardTokens { + pub arg0: substreams::scalar::BigInt, + } + impl RewardTokens { + const METHOD_ID: [u8; 4] = [84u8, 196u8, 159u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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 TotalSupply { - const NAME: &'static str = "totalSupply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for RewardTokens { + const NAME: &'static str = "reward_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for TotalSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Transfer { - const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + impl substreams_ethereum::rpc::RPCDecodable> for RewardTokens { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardsReceiver { + pub arg0: Vec, + } + impl RewardsReceiver { + const METHOD_ID: [u8; 4] = [1u8, 221u8, 171u8, 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Transfer { - const NAME: &'static str = "transfer"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for RewardsReceiver { + const NAME: &'static str = "rewards_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 RewardsReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable for Transfer { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetKilled { + pub u_is_killed: bool, + } + impl SetKilled { + const METHOD_ID: [u8; 4] = [144u8, 178u8, 41u8, 151u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_is_killed: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ethabi::Token::Bool(self.u_is_killed.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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferFrom { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for SetKilled { + const NAME: &'static str = "set_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl TransferFrom { - const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: values + 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 SetRewards { + pub u_reward_contract: Vec, + pub u_sigs: [u8; 32usize], + pub u_reward_tokens: [Vec; 8usize], + } + impl SetRewards { + const METHOD_ID: [u8; 4] = [71u8, 210u8, 213u8, 211u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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::FixedBytes(32usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 8usize, + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_reward_contract: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_sigs: { + let mut result = [0u8; 32]; + let v = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + u_reward_tokens: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + .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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_contract), + ), + ethabi::Token::FixedBytes(self.u_sigs.as_ref().to_vec()), + { + let v = self + .u_reward_tokens + .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, } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + } + impl substreams_ethereum::Function for SetRewards { + const NAME: &'static str = "set_rewards"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetRewardsReceiver { + pub u_receiver: Vec, + } + impl SetRewardsReceiver { + const METHOD_ID: [u8; 4] = [189u8, 249u8, 129u8, 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], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for SetRewardsReceiver { + const NAME: &'static str = "set_rewards_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 Symbol {} + impl Symbol { + const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for TransferFrom { - const NAME: &'static str = "transferFrom"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Symbol { + const NAME: &'static str = "symbol"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct UserCheckpoint { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl UserCheckpoint { - const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 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), + } + impl substreams_ethereum::rpc::RPCDecodable for Symbol { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TotalSupply {} + impl TotalSupply { + const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 UserCheckpoint { - const NAME: &'static str = "user_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 TotalSupply { + const NAME: &'static str = "totalSupply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct VotingEscrow {} - impl VotingEscrow { - const METHOD_ID: [u8; 4] = [223u8, 224u8, 80u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + 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::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for VotingEscrow { - const NAME: &'static str = "voting_escrow"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Transfer { + const NAME: &'static str = "transfer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for VotingEscrow { - 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 Withdraw1 { - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Withdraw1 { - const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable for Transfer { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferFrom { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl TransferFrom { + const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + 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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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, + ), + ], + ); + let mut encoded = Vec::with_capacity(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 Withdraw1 { - const NAME: &'static str = "withdraw1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 TransferFrom { + const NAME: &'static str = "transferFrom"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw2 { - pub u_value: substreams::scalar::BigInt, - pub u_claim_rewards: bool, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl Withdraw2 { - const METHOD_ID: [u8; 4] = [56u8, 208u8, 116u8, 54u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 UserCheckpoint { + pub addr: Vec, + } + impl UserCheckpoint { + const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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 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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize), ethabi::ParamType::Bool], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_claim_rewards: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Bool(self.u_claim_rewards.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 UserCheckpoint { + const NAME: &'static str = "user_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct VotingEscrow {} + impl VotingEscrow { + const METHOD_ID: [u8; 4] = [223u8, 224u8, 80u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Withdraw2 { - const NAME: &'static str = "withdraw2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 VotingEscrow { + const NAME: &'static str = "voting_escrow"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingBalances { - pub arg0: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl WorkingBalances { - const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for VotingEscrow { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw1 { + pub u_value: substreams::scalar::BigInt, + } + impl Withdraw1 { + const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { + u_value: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for WorkingBalances { - const NAME: &'static str = "working_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() + pub fn 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 WorkingBalances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Withdraw1 { + const NAME: &'static str = "withdraw1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingSupply {} - impl WorkingSupply { - const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + 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 Withdraw2 { + pub u_value: substreams::scalar::BigInt, + pub u_claim_rewards: bool, + } + impl Withdraw2 { + const METHOD_ID: [u8; 4] = [56u8, 208u8, 116u8, 54u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Bool], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { 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, - } + }, + u_claim_rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bool(self.u_claim_rewards.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, } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Withdraw2 { + const NAME: &'static str = "withdraw2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 WorkingBalances { + pub arg0: Vec, + } + impl WorkingBalances { + const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 WorkingSupply { - const NAME: &'static str = "working_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingSupply { - 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 ApplyOwnership { - pub admin: Vec, - } - impl ApplyOwnership { - const TOPIC_ID: [u8; 32] = [ - 235u8, - 238u8, - 45u8, - 87u8, - 57u8, - 1u8, - 16u8, - 98u8, - 203u8, - 79u8, - 20u8, - 17u8, - 63u8, - 59u8, - 54u8, - 191u8, - 15u8, - 254u8, - 61u8, - 165u8, - 192u8, - 86u8, - 143u8, - 100u8, - 24u8, - 157u8, - 16u8, - 18u8, - 161u8, - 24u8, - 145u8, - 5u8, - ]; - 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; + } + impl substreams_ethereum::Function for WorkingBalances { + const NAME: &'static str = "working_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 WorkingBalances { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct WorkingSupply {} + impl WorkingSupply { + const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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( + } + } + impl substreams_ethereum::Function for WorkingSupply { + const NAME: &'static str = "working_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for WorkingSupply { + 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 ApplyOwnership { + pub admin: Vec, + } + impl ApplyOwnership { + const TOPIC_ID: [u8; 32] = [ + 235u8, + 238u8, + 45u8, + 87u8, + 57u8, + 1u8, + 16u8, + 98u8, + 203u8, + 79u8, + 20u8, + 17u8, + 63u8, + 59u8, + 54u8, + 191u8, + 15u8, + 254u8, + 61u8, + 165u8, + 192u8, + 86u8, + 143u8, + 100u8, + 24u8, + 157u8, + 16u8, + 18u8, + 161u8, + 24u8, + 145u8, + 5u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for ApplyOwnership { + const NAME: &'static str = "ApplyOwnership"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approval { + pub u_owner: Vec, + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approval { + const TOPIC_ID: [u8; 32] = [ + 140u8, + 91u8, + 225u8, + 229u8, + 235u8, + 236u8, + 125u8, + 91u8, + 209u8, + 79u8, + 113u8, + 66u8, + 125u8, + 30u8, + 132u8, + 243u8, + 221u8, + 3u8, + 20u8, + 192u8, + 247u8, + 178u8, + 41u8, + 30u8, + 91u8, + 32u8, + 10u8, + 200u8, + 199u8, + 195u8, + 185u8, + 37u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for ApplyOwnership { - const NAME: &'static str = "ApplyOwnership"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Approval { - pub u_owner: Vec, - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Approval { - const TOPIC_ID: [u8; 32] = [ - 140u8, - 91u8, - 225u8, - 229u8, - 235u8, - 236u8, - 125u8, - 91u8, - 209u8, - 79u8, - 113u8, - 66u8, - 125u8, - 30u8, - 132u8, - 243u8, - 221u8, - 3u8, - 20u8, - 192u8, - 247u8, - 178u8, - 41u8, - 30u8, - 91u8, - 32u8, - 10u8, - 200u8, - 199u8, - 195u8, - 185u8, - 37u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_owner' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_owner: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_spender' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_owner' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: 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) + }, + }) + } + } + impl substreams_ethereum::Event for Approval { + const NAME: &'static str = "Approval"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitOwnership { + pub admin: Vec, + } + impl CommitOwnership { + const TOPIC_ID: [u8; 32] = [ + 47u8, + 86u8, + 129u8, + 10u8, + 107u8, + 244u8, + 10u8, + 240u8, + 89u8, + 185u8, + 109u8, + 58u8, + 234u8, + 77u8, + 181u8, + 64u8, + 129u8, + 243u8, + 120u8, + 2u8, + 154u8, + 81u8, + 131u8, + 144u8, + 73u8, + 16u8, + 147u8, + 167u8, + 182u8, + 112u8, + 50u8, + 233u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for CommitOwnership { + const NAME: &'static str = "CommitOwnership"; + 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 Deposit { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Deposit { + const TOPIC_ID: [u8; 32] = [ + 225u8, + 255u8, + 252u8, + 196u8, + 146u8, + 61u8, + 4u8, + 181u8, + 89u8, + 244u8, + 210u8, + 154u8, + 139u8, + 252u8, + 108u8, + 218u8, + 4u8, + 235u8, + 91u8, + 13u8, + 60u8, + 70u8, + 7u8, + 81u8, + 194u8, + 64u8, + 44u8, + 92u8, + 92u8, + 201u8, + 16u8, + 156u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_spender' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Approval { - const NAME: &'static str = "Approval"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitOwnership { - pub admin: Vec, - } - impl CommitOwnership { - const TOPIC_ID: [u8; 32] = [ - 47u8, - 86u8, - 129u8, - 10u8, - 107u8, - 244u8, - 10u8, - 240u8, - 89u8, - 185u8, - 109u8, - 58u8, - 234u8, - 77u8, - 181u8, - 64u8, - 129u8, - 243u8, - 120u8, - 2u8, - 154u8, - 81u8, - 131u8, - 144u8, - 73u8, - 16u8, - 147u8, - 167u8, - 182u8, - 112u8, - 50u8, - 233u8, - ]; - 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( + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Deposit { + const NAME: &'static str = "Deposit"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 242u8, + 82u8, + 173u8, + 27u8, + 226u8, + 200u8, + 155u8, + 105u8, + 194u8, + 176u8, + 104u8, + 252u8, + 55u8, + 141u8, + 170u8, + 149u8, + 43u8, + 167u8, + 241u8, + 99u8, + 196u8, + 161u8, + 22u8, + 40u8, + 245u8, + 90u8, + 77u8, + 245u8, + 35u8, + 179u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'u_from' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values + .map_err(|e| { + format!( + "unable to decode param 'u_to' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + 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 CommitOwnership { - const NAME: &'static str = "CommitOwnership"; - 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 Deposit { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Deposit { - const TOPIC_ID: [u8; 32] = [ - 225u8, - 255u8, - 252u8, - 196u8, - 146u8, - 61u8, - 4u8, - 181u8, - 89u8, - 244u8, - 210u8, - 154u8, - 139u8, - 252u8, - 108u8, - 218u8, - 4u8, - 235u8, - 91u8, - 13u8, - 60u8, - 70u8, - 7u8, - 81u8, - 194u8, - 64u8, - 44u8, - 92u8, - 92u8, - 201u8, - 16u8, - 156u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Transfer { + const NAME: &'static str = "Transfer"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateLiquidityLimit { + pub user: Vec, + pub original_balance: substreams::scalar::BigInt, + pub original_supply: substreams::scalar::BigInt, + pub working_balance: substreams::scalar::BigInt, + pub working_supply: substreams::scalar::BigInt, + } + impl UpdateLiquidityLimit { + const TOPIC_ID: [u8; 32] = [ + 126u8, + 205u8, + 132u8, + 52u8, + 63u8, + 118u8, + 162u8, + 61u8, + 34u8, + 39u8, + 41u8, + 14u8, + 2u8, + 136u8, + 218u8, + 50u8, + 81u8, + 176u8, + 69u8, + 84u8, + 22u8, + 152u8, + 229u8, + 117u8, + 165u8, + 81u8, + 90u8, + 244u8, + 240u8, + 65u8, + 151u8, + 163u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + original_balance: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Deposit { - const NAME: &'static str = "Deposit"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Transfer { - const TOPIC_ID: [u8; 32] = [ - 221u8, - 242u8, - 82u8, - 173u8, - 27u8, - 226u8, - 200u8, - 155u8, - 105u8, - 194u8, - 176u8, - 104u8, - 252u8, - 55u8, - 141u8, - 170u8, - 149u8, - 43u8, - 167u8, - 241u8, - 99u8, - 196u8, - 161u8, - 22u8, - 40u8, - 245u8, - 90u8, - 77u8, - 245u8, - 35u8, - 179u8, - 239u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_from' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + original_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_to' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_balance: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Transfer { - const NAME: &'static str = "Transfer"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateLiquidityLimit { - pub user: Vec, - pub original_balance: substreams::scalar::BigInt, - pub original_supply: substreams::scalar::BigInt, - pub working_balance: substreams::scalar::BigInt, - pub working_supply: substreams::scalar::BigInt, - } - impl UpdateLiquidityLimit { - const TOPIC_ID: [u8; 32] = [ - 126u8, - 205u8, - 132u8, - 52u8, - 63u8, - 118u8, - 162u8, - 61u8, - 34u8, - 39u8, - 41u8, - 14u8, - 2u8, - 136u8, - 218u8, - 50u8, - 81u8, - 176u8, - 69u8, - 84u8, - 22u8, - 152u8, - 229u8, - 117u8, - 165u8, - 81u8, - 90u8, - 244u8, - 240u8, - 65u8, - 151u8, - 163u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - user: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - original_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - original_supply: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_supply: { - let mut v = [0 as u8; 32]; - values - .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 UpdateLiquidityLimit { - const NAME: &'static str = "UpdateLiquidityLimit"; - 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 Withdraw { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Withdraw { - const TOPIC_ID: [u8; 32] = [ - 136u8, - 78u8, - 218u8, - 217u8, - 206u8, - 111u8, - 162u8, - 68u8, - 13u8, - 138u8, - 84u8, - 204u8, - 18u8, - 52u8, - 144u8, - 235u8, - 150u8, - 210u8, - 118u8, - 132u8, - 121u8, - 212u8, - 159u8, - 249u8, - 199u8, - 54u8, - 97u8, - 37u8, - 169u8, - 66u8, - 67u8, - 100u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for UpdateLiquidityLimit { + const NAME: &'static str = "UpdateLiquidityLimit"; + 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 Withdraw { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Withdraw { + const TOPIC_ID: [u8; 32] = [ + 136u8, + 78u8, + 218u8, + 217u8, + 206u8, + 111u8, + 162u8, + 68u8, + 13u8, + 138u8, + 84u8, + 204u8, + 18u8, + 52u8, + 144u8, + 235u8, + 150u8, + 210u8, + 118u8, + 132u8, + 121u8, + 212u8, + 159u8, + 249u8, + 199u8, + 54u8, + 97u8, + 37u8, + 169u8, + 66u8, + 67u8, + 100u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for Withdraw { - const NAME: &'static str = "Withdraw"; - 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 Withdraw { + const NAME: &'static str = "Withdraw"; + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/gauges/liquidity_gauge_v4.rs b/src/abi/curve/gauges/liquidity_gauge_v4.rs index a8c9333..3161431 100644 --- a/src/abi/curve/gauges/liquidity_gauge_v4.rs +++ b/src/abi/curve/gauges/liquidity_gauge_v4.rs @@ -1,3543 +1,3412 @@ - 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 AddReward { - pub u_reward_token: Vec, - pub u_distributor: Vec, - } - impl AddReward { - const METHOD_ID: [u8; 4] = [232u8, 222u8, 13u8, 77u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), - ], - ); - 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 AddReward { - const NAME: &'static str = "add_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Allowance { - pub arg0: Vec, - pub arg1: Vec, - } - impl Allowance { - const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut v = [0 as u8; 32]; - values - .pop() - .expect("one output data should have existed") - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Allowance { - const NAME: &'static str = "allowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Allowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Approve { - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Approve { - const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Approve { - const NAME: &'static str = "approve"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for Approve { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BalanceOf { - pub arg0: Vec, - } - impl BalanceOf { - const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut v = [0 as u8; 32]; - values - .pop() - .expect("one output data should have existed") - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for BalanceOf { - const NAME: &'static str = "balanceOf"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for BalanceOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimRewards1 {} - impl ClaimRewards1 { - const METHOD_ID: [u8; 4] = [230u8, 241u8, 218u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 ClaimRewards1 { - const NAME: &'static str = "claim_rewards1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards2 { - pub u_addr: Vec, - } - impl ClaimRewards2 { - const METHOD_ID: [u8; 4] = [132u8, 233u8, 189u8, 126u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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 ClaimRewards2 { - const NAME: &'static str = "claim_rewards2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards3 { - pub u_addr: Vec, - pub u_receiver: Vec, - } - impl ClaimRewards3 { - const METHOD_ID: [u8; 4] = [159u8, 172u8, 235u8, 27u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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 ClaimRewards3 { - const NAME: &'static str = "claim_rewards3"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimableReward { - pub u_user: Vec, - pub u_reward_token: Vec, - } - impl ClaimableReward { - const METHOD_ID: [u8; 4] = [51u8, 253u8, 111u8, 116u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_user: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_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.u_user), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_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 ClaimableReward { - const NAME: &'static str = "claimable_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableReward { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimableTokens { - pub addr: Vec, - } - impl ClaimableTokens { - const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::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 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, - } +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, } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for ClaimableTokens { - const NAME: &'static str = "claimable_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableTokens { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimedReward { - pub u_addr: Vec, - pub u_token: Vec, } - impl ClaimedReward { - const METHOD_ID: [u8; 4] = [231u8, 126u8, 116u8, 55u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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 ClaimedReward { - const NAME: &'static str = "claimed_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimedReward { - fn output(data: &[u8]) -> Result { - 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 Decimals {} - impl Decimals { - const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(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 Decimals { - const NAME: &'static str = "decimals"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::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 substreams_ethereum::rpc::RPCDecodable - for Decimals { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct DecreaseAllowance { - pub u_spender: Vec, - pub u_subtracted_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl DecreaseAllowance { - const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_subtracted_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_subtracted_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddReward { + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl AddReward { + const METHOD_ID: [u8; 4] = [232u8, 222u8, 13u8, 77u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for DecreaseAllowance { - const NAME: &'static str = "decreaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit1 { - pub u_value: substreams::scalar::BigInt, - } - impl Deposit1 { - const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 Deposit1 { - const NAME: &'static str = "deposit1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Deposit2 { - pub u_value: substreams::scalar::BigInt, - pub u_addr: Vec, - } - impl Deposit2 { - const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_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::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 Deposit2 { - const NAME: &'static str = "deposit2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Deposit3 { - pub u_value: substreams::scalar::BigInt, - pub u_addr: Vec, - pub u_claim_rewards: bool, } - impl Deposit3 { - const METHOD_ID: [u8; 4] = [131u8, 223u8, 103u8, 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), - ethabi::ParamType::Address, - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_claim_rewards: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_addr), - ), - ethabi::Token::Bool(self.u_claim_rewards.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 Deposit3 { - const NAME: &'static str = "deposit3"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 DepositRewardToken { - pub u_reward_token: Vec, - pub u_amount: substreams::scalar::BigInt, - } - impl DepositRewardToken { - const METHOD_ID: [u8; 4] = [147u8, 247u8, 170u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 DepositRewardToken { - const NAME: &'static str = "deposit_reward_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() - } - } - #[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, + } + impl substreams_ethereum::Function for AddReward { + const NAME: &'static str = "add_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 Allowance { + pub arg0: Vec, + pub arg1: Vec, + } + impl Allowance { + const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 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::Function for Allowance { + const NAME: &'static str = "allowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { - 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 FutureEpochTime {} - impl FutureEpochTime { - const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Allowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approve { + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approve { + const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Approve { + const NAME: &'static str = "approve"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Approve { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BalanceOf { + pub arg0: Vec, + } + impl BalanceOf { + const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + 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::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 FutureEpochTime { - const NAME: &'static str = "future_epoch_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 BalanceOf { + const NAME: &'static str = "balanceOf"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for BalanceOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimRewards1 {} + impl ClaimRewards1 { + const METHOD_ID: [u8; 4] = [230u8, 241u8, 218u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 FutureEpochTime { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for ClaimRewards1 { + const NAME: &'static str = "claim_rewards1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards2 { + pub u_addr: Vec, + } + impl ClaimRewards2 { + const METHOD_ID: [u8; 4] = [132u8, 233u8, 189u8, 126u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 IncreaseAllowance { - pub u_spender: Vec, - pub u_added_value: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for ClaimRewards2 { + const NAME: &'static str = "claim_rewards2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl IncreaseAllowance { - const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_added_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_added_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + 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 ClaimRewards3 { + pub u_addr: Vec, + pub u_receiver: Vec, + } + impl ClaimRewards3 { + const METHOD_ID: [u8; 4] = [159u8, 172u8, 235u8, 27u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, } - pub fn 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 ClaimRewards3 { + const NAME: &'static str = "claim_rewards3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimableReward { + pub u_user: Vec, + pub u_reward_token: Vec, + } + impl ClaimableReward { + const METHOD_ID: [u8; 4] = [51u8, 253u8, 111u8, 116u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_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.u_user)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for ClaimableReward { + const NAME: &'static str = "claimable_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimableReward { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimableTokens { + pub addr: Vec, + } + impl ClaimableTokens { + const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::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 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 IncreaseAllowance { - const NAME: &'static str = "increaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for ClaimableTokens { + const NAME: &'static str = "claimable_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { - 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 ClaimableTokens { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct InflationRate {} - impl InflationRate { - const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimedReward { + pub u_addr: Vec, + pub u_token: Vec, + } + impl ClaimedReward { + const METHOD_ID: [u8; 4] = [231u8, 126u8, 116u8, 55u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + } + } + impl substreams_ethereum::Function for ClaimedReward { + const NAME: &'static str = "claimed_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimedReward { + fn output(data: &[u8]) -> Result { + 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, } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) + } + } + 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 Decimals {} + impl Decimals { + const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(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 + } } - 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({ + } + } + impl substreams_ethereum::Function for Decimals { + const NAME: &'static str = "decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Decimals { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DecreaseAllowance { + pub u_spender: Vec, + pub u_subtracted_value: substreams::scalar::BigInt, + } + impl DecreaseAllowance { + const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_subtracted_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_subtracted_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for InflationRate { - const NAME: &'static str = "inflation_rate"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 DecreaseAllowance { + const NAME: &'static str = "decreaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for InflationRate { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpoint {} - impl IntegrateCheckpoint { - const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit1 { + pub u_value: substreams::scalar::BigInt, + } + impl Deposit1 { + const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_value: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for IntegrateCheckpoint { - const NAME: &'static str = "integrate_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 IntegrateCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Deposit1 { + const NAME: &'static str = "deposit1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpointOf { - pub arg0: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl IntegrateCheckpointOf { - const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit2 { + pub u_value: substreams::scalar::BigInt, + pub u_addr: Vec, + } + impl Deposit2 { + const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { 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 - } - } - } + }, + u_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::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_addr)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for IntegrateCheckpointOf { - const NAME: &'static str = "integrate_checkpoint_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 IntegrateCheckpointOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Deposit2 { + const NAME: &'static str = "deposit2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateFraction { - pub arg0: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl IntegrateFraction { - const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit3 { + pub u_value: substreams::scalar::BigInt, + pub u_addr: Vec, + pub u_claim_rewards: bool, + } + impl Deposit3 { + const METHOD_ID: [u8; 4] = [131u8, 223u8, 103u8, 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), + ethabi::ParamType::Address, + ethabi::ParamType::Bool, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { 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 - } - } + }, + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_claim_rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_addr)), + ethabi::Token::Bool(self.u_claim_rewards.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 IntegrateFraction { - const NAME: &'static str = "integrate_fraction"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Deposit3 { + const NAME: &'static str = "deposit3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateFraction { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupply { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl IntegrateInvSupply { - const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - 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 DepositRewardToken { + pub u_reward_token: Vec, + pub u_amount: substreams::scalar::BigInt, + } + impl DepositRewardToken { + const METHOD_ID: [u8; 4] = [147u8, 247u8, 170u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_amount: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn 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 DepositRewardToken { + const NAME: &'static str = "deposit_reward_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() + } + } + #[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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 FutureEpochTime {} + impl FutureEpochTime { + const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 IntegrateInvSupply { - const NAME: &'static str = "integrate_inv_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureEpochTime { + const NAME: &'static str = "future_epoch_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupplyOf { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl IntegrateInvSupplyOf { - const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureEpochTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IncreaseAllowance { + pub u_spender: Vec, + pub u_added_value: substreams::scalar::BigInt, + } + impl IncreaseAllowance { + const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_added_value: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_added_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IncreaseAllowance { + const NAME: &'static str = "increaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InflationRate {} + impl InflationRate { + const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + 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 IntegrateInvSupplyOf { - const NAME: &'static str = "integrate_inv_supply_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 InflationRate { + const NAME: &'static str = "inflation_rate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupplyOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsKilled {} - impl IsKilled { - const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for InflationRate { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpoint {} + impl IntegrateCheckpoint { + const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IntegrateCheckpoint { + const NAME: &'static str = "integrate_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpointOf { + pub arg0: Vec, + } + impl IntegrateCheckpointOf { + const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 IsKilled { - const NAME: &'static str = "is_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IntegrateCheckpointOf { + const NAME: &'static str = "integrate_checkpoint_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsKilled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Kick { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl Kick { - const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::rpc::RPCDecodable + for IntegrateCheckpointOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateFraction { + pub arg0: Vec, + } + impl IntegrateFraction { + const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 Kick { - const NAME: &'static str = "kick"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IntegrateFraction { + const NAME: &'static str = "integrate_fraction"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct LpToken {} - impl LpToken { - const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateFraction { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupply { + pub arg0: substreams::scalar::BigInt, + } + impl IntegrateInvSupply { + const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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(), + .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::Uint(256usize)], + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 LpToken { - const NAME: &'static str = "lp_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::Function for IntegrateInvSupply { + const NAME: &'static str = "integrate_inv_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for LpToken { - 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 Name {} - impl Name { - const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupplyOf { + pub arg0: Vec, + } + impl IntegrateInvSupplyOf { + const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IntegrateInvSupplyOf { + const NAME: &'static str = "integrate_inv_supply_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupplyOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsKilled {} + impl IsKilled { + const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 Name { - const NAME: &'static str = "name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for IsKilled { + const NAME: &'static str = "is_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Name { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Period {} - impl Period { - const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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) - }) + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IsKilled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Kick { + pub addr: Vec, + } + impl Kick { + const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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, } - pub fn 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 Kick { + const NAME: &'static str = "kick"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LpToken {} + impl LpToken { + const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 LpToken { + const NAME: &'static str = "lp_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 LpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Name {} + impl Name { + const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Period { - const NAME: &'static str = "period"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Name { + const NAME: &'static str = "name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Period { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PeriodTimestamp { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Name { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl PeriodTimestamp { - const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 Period {} + impl Period { + const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - 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 { - 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({ + } + } + } + impl substreams_ethereum::Function for Period { + const NAME: &'static str = "period"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Period { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PeriodTimestamp { + pub arg0: substreams::scalar::BigInt, + } + impl PeriodTimestamp { + const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for PeriodTimestamp { + const NAME: &'static str = "period_timestamp"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for PeriodTimestamp { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardCount {} + impl RewardCount { + const METHOD_ID: [u8; 4] = [150u8, 60u8, 148u8, 185u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 PeriodTimestamp { - const NAME: &'static str = "period_timestamp"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardCount { + const NAME: &'static str = "reward_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for PeriodTimestamp { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardCount {} - impl RewardCount { - const METHOD_ID: [u8; 4] = [150u8, 60u8, 148u8, 185u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RewardCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardData { + pub arg0: Vec, + } + impl RewardData { + const METHOD_ID: [u8; 4] = [72u8, 233u8, 198u8, 94u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + Vec, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( + 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(), + { 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 RewardCount { - const NAME: &'static str = "reward_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 RewardCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardData { - pub arg0: Vec, - } - impl RewardData { - const METHOD_ID: [u8; 4] = [72u8, 233u8, 198u8, 94u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 + }, + { + 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, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ( - Vec, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( + .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_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_address() + .into_uint() .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) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } + .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, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - > { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + pub fn call( + &self, + address: Vec, + ) -> Option< + ( + Vec, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for RewardData { - const NAME: &'static str = "reward_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::Function for RewardData { + const NAME: &'static str = "reward_data"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable< + 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, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > for RewardData { + fn output( + data: &[u8], + ) -> Result< ( Vec, Vec, @@ -3546,2237 +3415,2145 @@ substreams::scalar::BigInt, substreams::scalar::BigInt, ), - > for RewardData { - fn output( - data: &[u8], - ) -> Result< - ( - Vec, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardIntegralFor { - pub arg0: Vec, - pub arg1: Vec, - } - impl RewardIntegralFor { - const METHOD_ID: [u8; 4] = [240u8, 92u8, 192u8, 88u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardIntegralFor { + pub arg0: Vec, + pub arg1: Vec, + } + impl RewardIntegralFor { + const METHOD_ID: [u8; 4] = [240u8, 92u8, 192u8, 88u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 } - 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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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({ + } + } + impl substreams_ethereum::Function for RewardIntegralFor { + const NAME: &'static str = "reward_integral_for"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RewardIntegralFor { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardTokens { + pub arg0: substreams::scalar::BigInt, + } + impl RewardTokens { + const METHOD_ID: [u8; 4] = [84u8, 196u8, 159u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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 RewardIntegralFor { - const NAME: &'static str = "reward_integral_for"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardTokens { + const NAME: &'static str = "reward_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for RewardIntegralFor { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardTokens { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl RewardTokens { - const METHOD_ID: [u8; 4] = [84u8, 196u8, 159u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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(), + } + impl substreams_ethereum::rpc::RPCDecodable> for RewardTokens { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardsReceiver { + pub arg0: Vec, + } + impl RewardsReceiver { + const METHOD_ID: [u8; 4] = [1u8, 221u8, 171u8, 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for RewardTokens { - const NAME: &'static str = "reward_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardsReceiver { + const NAME: &'static str = "rewards_receiver"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for RewardTokens { - 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 RewardsReceiver { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl RewardsReceiver { - const METHOD_ID: [u8; 4] = [1u8, 221u8, 171u8, 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::rpc::RPCDecodable> for RewardsReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetKilled { + pub u_is_killed: bool, + } + impl SetKilled { + const METHOD_ID: [u8; 4] = [144u8, 178u8, 41u8, 151u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_is_killed: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ethabi::Token::Bool(self.u_is_killed.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 RewardsReceiver { - const NAME: &'static str = "rewards_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::Function for SetKilled { + const NAME: &'static str = "set_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for RewardsReceiver { - 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 SetKilled { - pub u_is_killed: bool, + fn encode(&self) -> Vec { + self.encode() } - impl SetKilled { - const METHOD_ID: [u8; 4] = [144u8, 178u8, 41u8, 151u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_is_killed: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Bool(self.u_is_killed.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, - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetRewardDistributor { + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl SetRewardDistributor { + const METHOD_ID: [u8; 4] = [5u8, 138u8, 58u8, 36u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + 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 SetKilled { - const NAME: &'static str = "set_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 SetRewardDistributor { + const NAME: &'static str = "set_reward_distributor"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetRewardsReceiver { + pub u_receiver: Vec, + } + impl SetRewardsReceiver { + const METHOD_ID: [u8; 4] = [189u8, 249u8, 129u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 SetRewardDistributor { - pub u_reward_token: Vec, - pub u_distributor: Vec, + } + impl substreams_ethereum::Function for SetRewardsReceiver { + const NAME: &'static str = "set_rewards_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 SetRewardDistributor { - const METHOD_ID: [u8; 4] = [5u8, 138u8, 58u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 Symbol {} + impl Symbol { + const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } - 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 { - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), - ], - ); - 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 Symbol { + const NAME: &'static str = "symbol"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Symbol { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TotalSupply {} + impl TotalSupply { + const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for SetRewardDistributor { - const NAME: &'static str = "set_reward_distributor"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 TotalSupply { + const NAME: &'static str = "totalSupply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetRewardsReceiver { - pub u_receiver: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl SetRewardsReceiver { - const METHOD_ID: [u8; 4] = [189u8, 249u8, 129u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_receiver: values + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + 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.u_receiver), + .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.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + ), + ], + ); + let mut encoded = Vec::with_capacity(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 SetRewardsReceiver { - const NAME: &'static str = "set_rewards_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 Symbol {} - impl Symbol { - const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + } + impl substreams_ethereum::Function for Transfer { + const NAME: &'static str = "transfer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for Symbol { - const NAME: &'static str = "symbol"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable for Symbol { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct TotalSupply {} - impl TotalSupply { - const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable for Transfer { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferFrom { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl TransferFrom { + const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for TransferFrom { + const NAME: &'static str = "transferFrom"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UserCheckpoint { + pub addr: Vec, + } + impl UserCheckpoint { + const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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 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 TotalSupply { - const NAME: &'static str = "totalSupply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for UserCheckpoint { + const NAME: &'static str = "user_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for TotalSupply { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl Transfer { - const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_to: values + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw1 { + pub u_value: substreams::scalar::BigInt, + } + impl Withdraw1 { + const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { + u_value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .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.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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 - } - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for Transfer { - const NAME: &'static str = "transfer"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + pub fn 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 Transfer { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Withdraw1 { + const NAME: &'static str = "withdraw1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferFrom { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl TransferFrom { - const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw2 { + pub u_value: substreams::scalar::BigInt, + pub u_claim_rewards: bool, + } + impl Withdraw2 { + const METHOD_ID: [u8; 4] = [56u8, 208u8, 116u8, 54u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Bool], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_claim_rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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 - } - } - } + ), + ethabi::Token::Bool(self.u_claim_rewards.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for TransferFrom { - const NAME: &'static str = "transferFrom"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + pub fn 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 TransferFrom { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Withdraw2 { + const NAME: &'static str = "withdraw2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct UserCheckpoint { - pub addr: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl UserCheckpoint { - const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 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), + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct WorkingBalances { + pub arg0: Vec, + } + impl WorkingBalances { + const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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::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 UserCheckpoint { - const NAME: &'static str = "user_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 WorkingBalances { + const NAME: &'static str = "working_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw1 { - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Withdraw1 { - const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 WorkingBalances { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct WorkingSupply {} + impl WorkingSupply { + const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 Withdraw1 { - const NAME: &'static str = "withdraw1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 WorkingSupply { + const NAME: &'static str = "working_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw2 { - pub u_value: substreams::scalar::BigInt, - pub u_claim_rewards: bool, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl Withdraw2 { - const METHOD_ID: [u8; 4] = [56u8, 208u8, 116u8, 54u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Bool], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_claim_rewards: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Bool(self.u_claim_rewards.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 Withdraw2 { - const NAME: &'static str = "withdraw2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::rpc::RPCDecodable + for WorkingSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingBalances { - pub arg0: Vec, + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct ApplyOwnership { + pub admin: Vec, + } + impl ApplyOwnership { + const TOPIC_ID: [u8; 32] = [ + 235u8, + 238u8, + 45u8, + 87u8, + 57u8, + 1u8, + 16u8, + 98u8, + 203u8, + 79u8, + 20u8, + 17u8, + 63u8, + 59u8, + 54u8, + 191u8, + 15u8, + 254u8, + 61u8, + 165u8, + 192u8, + 86u8, + 143u8, + 100u8, + 24u8, + 157u8, + 16u8, + 18u8, + 161u8, + 24u8, + 145u8, + 5u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl WorkingBalances { - const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( + } + impl substreams_ethereum::Event for ApplyOwnership { + const NAME: &'static str = "ApplyOwnership"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approval { + pub u_owner: Vec, + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approval { + const TOPIC_ID: [u8; 32] = [ + 140u8, + 91u8, + 225u8, + 229u8, + 235u8, + 236u8, + 125u8, + 91u8, + 209u8, + 79u8, + 113u8, + 66u8, + 125u8, + 30u8, + 132u8, + 243u8, + 221u8, + 3u8, + 20u8, + 192u8, + 247u8, + 178u8, + 41u8, + 30u8, + 91u8, + 32u8, + 10u8, + 200u8, + 199u8, + 195u8, + 185u8, + 37u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .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::Uint(256usize)], - data.as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_owner' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'u_spender' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 WorkingBalances { - const NAME: &'static str = "working_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::Event for Approval { + const NAME: &'static str = "Approval"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingBalances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingSupply {} - impl WorkingSupply { - const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitOwnership { + pub admin: Vec, + } + impl CommitOwnership { + const TOPIC_ID: [u8; 32] = [ + 47u8, + 86u8, + 129u8, + 10u8, + 107u8, + 244u8, + 10u8, + 240u8, + 89u8, + 185u8, + 109u8, + 58u8, + 234u8, + 77u8, + 181u8, + 64u8, + 129u8, + 243u8, + 120u8, + 2u8, + 154u8, + 81u8, + 131u8, + 144u8, + 73u8, + 16u8, + 147u8, + 167u8, + 182u8, + 112u8, + 50u8, + 233u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for CommitOwnership { + const NAME: &'static str = "CommitOwnership"; + 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 Deposit { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Deposit { + const TOPIC_ID: [u8; 32] = [ + 225u8, + 255u8, + 252u8, + 196u8, + 146u8, + 61u8, + 4u8, + 181u8, + 89u8, + 244u8, + 210u8, + 154u8, + 139u8, + 252u8, + 108u8, + 218u8, + 4u8, + 235u8, + 91u8, + 13u8, + 60u8, + 70u8, + 7u8, + 81u8, + 194u8, + 64u8, + 44u8, + 92u8, + 92u8, + 201u8, + 16u8, + 156u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { 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 WorkingSupply { - const NAME: &'static str = "working_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingSupply { - 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 ApplyOwnership { - pub admin: Vec, - } - impl ApplyOwnership { - const TOPIC_ID: [u8; 32] = [ - 235u8, - 238u8, - 45u8, - 87u8, - 57u8, - 1u8, - 16u8, - 98u8, - 203u8, - 79u8, - 20u8, - 17u8, - 63u8, - 59u8, - 54u8, - 191u8, - 15u8, - 254u8, - 61u8, - 165u8, - 192u8, - 86u8, - 143u8, - 100u8, - 24u8, - 157u8, - 16u8, - 18u8, - 161u8, - 24u8, - 145u8, - 5u8, - ]; - 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( + } + impl substreams_ethereum::Event for Deposit { + const NAME: &'static str = "Deposit"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 242u8, + 82u8, + 173u8, + 27u8, + 226u8, + 200u8, + 155u8, + 105u8, + 194u8, + 176u8, + 104u8, + 252u8, + 55u8, + 141u8, + 170u8, + 149u8, + 43u8, + 167u8, + 241u8, + 99u8, + 196u8, + 161u8, + 22u8, + 40u8, + 245u8, + 90u8, + 77u8, + 245u8, + 35u8, + 179u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for ApplyOwnership { - const NAME: &'static str = "ApplyOwnership"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Approval { - pub u_owner: Vec, - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Approval { - const TOPIC_ID: [u8; 32] = [ - 140u8, - 91u8, - 225u8, - 229u8, - 235u8, - 236u8, - 125u8, - 91u8, - 209u8, - 79u8, - 113u8, - 66u8, - 125u8, - 30u8, - 132u8, - 243u8, - 221u8, - 3u8, - 20u8, - 192u8, - 247u8, - 178u8, - 41u8, - 30u8, - 91u8, - 32u8, - 10u8, - 200u8, - 199u8, - 195u8, - 185u8, - 37u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_owner: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_owner' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_from' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_spender' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Approval { - const NAME: &'static str = "Approval"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitOwnership { - pub admin: Vec, - } - impl CommitOwnership { - const TOPIC_ID: [u8; 32] = [ - 47u8, - 86u8, - 129u8, - 10u8, - 107u8, - 244u8, - 10u8, - 240u8, - 89u8, - 185u8, - 109u8, - 58u8, - 234u8, - 77u8, - 181u8, - 64u8, - 129u8, - 243u8, - 120u8, - 2u8, - 154u8, - 81u8, - 131u8, - 144u8, - 73u8, - 16u8, - 147u8, - 167u8, - 182u8, - 112u8, - 50u8, - 233u8, - ]; - 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( + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values + .map_err(|e| { + format!( + "unable to decode param 'u_to' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + 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 CommitOwnership { - const NAME: &'static str = "CommitOwnership"; - 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 Deposit { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Deposit { - const TOPIC_ID: [u8; 32] = [ - 225u8, - 255u8, - 252u8, - 196u8, - 146u8, - 61u8, - 4u8, - 181u8, - 89u8, - 244u8, - 210u8, - 154u8, - 139u8, - 252u8, - 108u8, - 218u8, - 4u8, - 235u8, - 91u8, - 13u8, - 60u8, - 70u8, - 7u8, - 81u8, - 194u8, - 64u8, - 44u8, - 92u8, - 92u8, - 201u8, - 16u8, - 156u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Transfer { + const NAME: &'static str = "Transfer"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateLiquidityLimit { + pub user: Vec, + pub original_balance: substreams::scalar::BigInt, + pub original_supply: substreams::scalar::BigInt, + pub working_balance: substreams::scalar::BigInt, + pub working_supply: substreams::scalar::BigInt, + } + impl UpdateLiquidityLimit { + const TOPIC_ID: [u8; 32] = [ + 126u8, + 205u8, + 132u8, + 52u8, + 63u8, + 118u8, + 162u8, + 61u8, + 34u8, + 39u8, + 41u8, + 14u8, + 2u8, + 136u8, + 218u8, + 50u8, + 81u8, + 176u8, + 69u8, + 84u8, + 22u8, + 152u8, + 229u8, + 117u8, + 165u8, + 81u8, + 90u8, + 244u8, + 240u8, + 65u8, + 151u8, + 163u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + original_balance: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Deposit { - const NAME: &'static str = "Deposit"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Transfer { - const TOPIC_ID: [u8; 32] = [ - 221u8, - 242u8, - 82u8, - 173u8, - 27u8, - 226u8, - 200u8, - 155u8, - 105u8, - 194u8, - 176u8, - 104u8, - 252u8, - 55u8, - 141u8, - 170u8, - 149u8, - 43u8, - 167u8, - 241u8, - 99u8, - 196u8, - 161u8, - 22u8, - 40u8, - 245u8, - 90u8, - 77u8, - 245u8, - 35u8, - 179u8, - 239u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_from' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + original_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_to' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_balance: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Transfer { - const NAME: &'static str = "Transfer"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateLiquidityLimit { - pub user: Vec, - pub original_balance: substreams::scalar::BigInt, - pub original_supply: substreams::scalar::BigInt, - pub working_balance: substreams::scalar::BigInt, - pub working_supply: substreams::scalar::BigInt, - } - impl UpdateLiquidityLimit { - const TOPIC_ID: [u8; 32] = [ - 126u8, - 205u8, - 132u8, - 52u8, - 63u8, - 118u8, - 162u8, - 61u8, - 34u8, - 39u8, - 41u8, - 14u8, - 2u8, - 136u8, - 218u8, - 50u8, - 81u8, - 176u8, - 69u8, - 84u8, - 22u8, - 152u8, - 229u8, - 117u8, - 165u8, - 81u8, - 90u8, - 244u8, - 240u8, - 65u8, - 151u8, - 163u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - user: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - original_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - original_supply: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_supply: { - let mut v = [0 as u8; 32]; - values - .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 UpdateLiquidityLimit { - const NAME: &'static str = "UpdateLiquidityLimit"; - 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 Withdraw { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Withdraw { - const TOPIC_ID: [u8; 32] = [ - 136u8, - 78u8, - 218u8, - 217u8, - 206u8, - 111u8, - 162u8, - 68u8, - 13u8, - 138u8, - 84u8, - 204u8, - 18u8, - 52u8, - 144u8, - 235u8, - 150u8, - 210u8, - 118u8, - 132u8, - 121u8, - 212u8, - 159u8, - 249u8, - 199u8, - 54u8, - 97u8, - 37u8, - 169u8, - 66u8, - 67u8, - 100u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for UpdateLiquidityLimit { + const NAME: &'static str = "UpdateLiquidityLimit"; + 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 Withdraw { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Withdraw { + const TOPIC_ID: [u8; 32] = [ + 136u8, + 78u8, + 218u8, + 217u8, + 206u8, + 111u8, + 162u8, + 68u8, + 13u8, + 138u8, + 84u8, + 204u8, + 18u8, + 52u8, + 144u8, + 235u8, + 150u8, + 210u8, + 118u8, + 132u8, + 121u8, + 212u8, + 159u8, + 249u8, + 199u8, + 54u8, + 97u8, + 37u8, + 169u8, + 66u8, + 67u8, + 100u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Withdraw { - const NAME: &'static str = "Withdraw"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - } \ No newline at end of file + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Withdraw { + const NAME: &'static str = "Withdraw"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/gauges/liquidity_gauge_v5.rs b/src/abi/curve/gauges/liquidity_gauge_v5.rs index 214a0ea..cbea259 100644 --- a/src/abi/curve/gauges/liquidity_gauge_v5.rs +++ b/src/abi/curve/gauges/liquidity_gauge_v5.rs @@ -1,6300 +1,6050 @@ - 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 DomainSeparator {} - impl DomainSeparator { - const METHOD_ID: [u8; 4] = [54u8, 68u8, 229u8, 21u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result<[u8; 32usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::FixedBytes(32usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut result = [0u8; 32]; - let v = values - .pop() - .expect("one output data should have existed") - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } +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 DomainSeparator {} + impl DomainSeparator { + const METHOD_ID: [u8; 4] = [54u8, 68u8, 229u8, 21u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for DomainSeparator { - const NAME: &'static str = "DOMAIN_SEPARATOR"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for DomainSeparator { + const NAME: &'static str = "DOMAIN_SEPARATOR"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for DomainSeparator { - fn output(data: &[u8]) -> Result<[u8; 32usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[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, - } - } + 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) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + } + impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for DomainSeparator { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct AddReward { - pub u_reward_token: Vec, - pub u_distributor: 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 AddReward { - const METHOD_ID: [u8; 4] = [232u8, 222u8, 13u8, 77u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), - ], - ); - 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 AddReward { - const NAME: &'static str = "add_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddReward { + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl AddReward { + const METHOD_ID: [u8; 4] = [232u8, 222u8, 13u8, 77u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for AddReward { + const NAME: &'static str = "add_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::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 Admin { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct Allowance { - pub arg0: Vec, - pub arg1: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for Admin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl Allowance { - const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct Allowance { + pub arg0: Vec, + pub arg1: Vec, + } + impl Allowance { + const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 } - 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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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({ + } + } + impl substreams_ethereum::Function for Allowance { + const NAME: &'static str = "allowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Allowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approve { + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approve { + const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Approve { + const NAME: &'static str = "approve"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Approve { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BalanceOf { + pub arg0: Vec, + } + impl BalanceOf { + const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + 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::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Allowance { - const NAME: &'static str = "allowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) + } + impl substreams_ethereum::Function for BalanceOf { + const NAME: &'static str = "balanceOf"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for BalanceOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimRewards1 {} + impl ClaimRewards1 { + const METHOD_ID: [u8; 4] = [230u8, 241u8, 218u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - self.encode() + } + } + impl substreams_ethereum::Function for ClaimRewards1 { + const NAME: &'static str = "claim_rewards1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards2 { + pub u_addr: Vec, + } + impl ClaimRewards2 { + const METHOD_ID: [u8; 4] = [132u8, 233u8, 189u8, 126u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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::rpc::RPCDecodable - for Allowance { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for ClaimRewards2 { + const NAME: &'static str = "claim_rewards2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards3 { + pub u_addr: Vec, + pub u_receiver: Vec, + } + impl ClaimRewards3 { + const METHOD_ID: [u8; 4] = [159u8, 172u8, 235u8, 27u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 Approve { - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for ClaimRewards3 { + const NAME: &'static str = "claim_rewards3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl Approve { - const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimableReward { + pub u_user: Vec, + pub u_reward_token: Vec, + } + impl ClaimableReward { + const METHOD_ID: [u8; 4] = [51u8, 253u8, 111u8, 116u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_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.u_user)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_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 } - 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 { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + } + impl substreams_ethereum::Function for ClaimableReward { + const NAME: &'static str = "claimable_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimableReward { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimableTokens { + pub addr: Vec, + } + impl ClaimableTokens { + const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for ClaimableTokens { + const NAME: &'static str = "claimable_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimableTokens { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimedReward { + pub u_addr: Vec, + pub u_token: Vec, + } + impl ClaimedReward { + const METHOD_ID: [u8; 4] = [231u8, 126u8, 116u8, 55u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 Approve { - const NAME: &'static str = "approve"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for ClaimedReward { + const NAME: &'static str = "claimed_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::rpc::RPCDecodable for Approve { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimedReward { + fn output(data: &[u8]) -> Result { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct BalanceOf { - pub arg0: 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) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl BalanceOf { - const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct Decimals {} + impl Decimals { + const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(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 } - let 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + } + } + impl substreams_ethereum::Function for Decimals { + const NAME: &'static str = "decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Decimals { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DecreaseAllowance { + pub u_spender: Vec, + pub u_subtracted_value: substreams::scalar::BigInt, + } + impl DecreaseAllowance { + const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_subtracted_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_subtracted_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for BalanceOf { - const NAME: &'static str = "balanceOf"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for DecreaseAllowance { + const NAME: &'static str = "decreaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for BalanceOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimRewards1 {} - impl ClaimRewards1 { - const METHOD_ID: [u8; 4] = [230u8, 241u8, 218u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 ClaimRewards1 { - const NAME: &'static str = "claim_rewards1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards2 { - pub u_addr: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl ClaimRewards2 { - const METHOD_ID: [u8; 4] = [132u8, 233u8, 189u8, 126u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_addr: values + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit1 { + pub u_value: substreams::scalar::BigInt, + } + impl Deposit1 { + const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_value: { + 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.u_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, - } - } + .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.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for ClaimRewards2 { - const NAME: &'static str = "claim_rewards2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 ClaimRewards3 { - pub u_addr: Vec, - pub u_receiver: Vec, + } + impl substreams_ethereum::Function for Deposit1 { + const NAME: &'static str = "deposit1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl ClaimRewards3 { - const METHOD_ID: [u8; 4] = [159u8, 172u8, 235u8, 27u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_receiver: values + 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 Deposit2 { + pub u_value: substreams::scalar::BigInt, + pub u_addr: Vec, + } + impl Deposit2 { + const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { + 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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_receiver), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_addr)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for ClaimRewards3 { - const NAME: &'static str = "claim_rewards3"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 ClaimableReward { - pub u_user: Vec, - pub u_reward_token: Vec, + } + impl substreams_ethereum::Function for Deposit2 { + const NAME: &'static str = "deposit2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl ClaimableReward { - const METHOD_ID: [u8; 4] = [51u8, 253u8, 111u8, 116u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_user: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + 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 Deposit3 { + pub u_value: substreams::scalar::BigInt, + pub u_addr: Vec, + pub u_claim_rewards: bool, + } + impl Deposit3 { + const METHOD_ID: [u8; 4] = [131u8, 223u8, 103u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_user), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::Bool, ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { 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 - } - } + }, + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_claim_rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_addr)), + ethabi::Token::Bool(self.u_claim_rewards.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 ClaimableReward { - const NAME: &'static str = "claimable_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Deposit3 { + const NAME: &'static str = "deposit3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableReward { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimableTokens { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl ClaimableTokens { - const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::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 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 DepositRewardToken { + pub u_reward_token: Vec, + pub u_amount: substreams::scalar::BigInt, + } + impl DepositRewardToken { + const METHOD_ID: [u8; 4] = [147u8, 247u8, 170u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_amount: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for DepositRewardToken { + const NAME: &'static str = "deposit_reward_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() + } + } + #[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 ClaimableTokens { - const NAME: &'static str = "claimable_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureAdmin { + const NAME: &'static str = "future_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableTokens { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimedReward { - pub u_addr: Vec, - pub u_token: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl ClaimedReward { - const METHOD_ID: [u8; 4] = [231u8, 126u8, 116u8, 55u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 FutureEpochTime {} + impl FutureEpochTime { + const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - 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 { - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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({ + } + } + impl substreams_ethereum::Function for FutureEpochTime { + const NAME: &'static str = "future_epoch_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureEpochTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IncreaseAllowance { + pub u_spender: Vec, + pub u_added_value: substreams::scalar::BigInt, + } + impl IncreaseAllowance { + const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_added_value: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_added_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IncreaseAllowance { + const NAME: &'static str = "increaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InflationRate {} + impl InflationRate { + const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + 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 ClaimedReward { - const NAME: &'static str = "claimed_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 InflationRate { + const NAME: &'static str = "inflation_rate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for InflationRate { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimedReward { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpoint {} + impl IntegrateCheckpoint { + const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitTransferOwnership { - pub addr: Vec, + } + impl substreams_ethereum::Function for IntegrateCheckpoint { + const NAME: &'static str = "integrate_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) } - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpointOf { + pub arg0: Vec, + } + impl IntegrateCheckpointOf { + const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 } - let 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 IntegrateCheckpointOf { + const NAME: &'static str = "integrate_checkpoint_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpointOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateFraction { + pub arg0: Vec, + } + impl IntegrateFraction { + const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 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 Decimals {} - impl Decimals { - const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::Function for IntegrateFraction { + const NAME: &'static str = "integrate_fraction"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateFraction { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupply { + pub arg0: substreams::scalar::BigInt, + } + impl IntegrateInvSupply { + const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IntegrateInvSupply { + const NAME: &'static str = "integrate_inv_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupplyOf { + pub arg0: Vec, + } + impl IntegrateInvSupplyOf { + const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], + 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::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 Decimals { - const NAME: &'static str = "decimals"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for IntegrateInvSupplyOf { + const NAME: &'static str = "integrate_inv_supply_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Decimals { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct DecreaseAllowance { - pub u_spender: Vec, - pub u_subtracted_value: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupplyOf { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl DecreaseAllowance { - const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsKilled {} + impl IsKilled { + const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - 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 { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_subtracted_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_subtracted_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + } + impl substreams_ethereum::Function for IsKilled { + const NAME: &'static str = "is_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IsKilled { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Kick { + pub addr: Vec, + } + impl Kick { + const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .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 DecreaseAllowance { - const NAME: &'static str = "decreaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Kick { + const NAME: &'static str = "kick"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit1 { - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Deposit1 { - const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 LpToken {} + impl LpToken { + const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Deposit1 { - const NAME: &'static str = "deposit1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 LpToken { + const NAME: &'static str = "lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit2 { - pub u_value: substreams::scalar::BigInt, - pub u_addr: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl Deposit2 { - const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_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::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for LpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Name {} + impl Name { + const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Deposit2 { - const NAME: &'static str = "deposit2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Name { + const NAME: &'static str = "name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit3 { - pub u_value: substreams::scalar::BigInt, - pub u_addr: Vec, - pub u_claim_rewards: bool, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl Deposit3 { - const METHOD_ID: [u8; 4] = [131u8, 223u8, 103u8, 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), - ethabi::ParamType::Address, - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_claim_rewards: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_addr), - ), - ethabi::Token::Bool(self.u_claim_rewards.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::rpc::RPCDecodable for Name { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Nonces { + pub arg0: Vec, + } + impl Nonces { + const METHOD_ID: [u8; 4] = [126u8, 206u8, 190u8, 0u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + 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::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 Deposit3 { - const NAME: &'static str = "deposit3"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Nonces { + const NAME: &'static str = "nonces"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct DepositRewardToken { - pub u_reward_token: Vec, - pub u_amount: substreams::scalar::BigInt, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl DepositRewardToken { - const METHOD_ID: [u8; 4] = [147u8, 247u8, 170u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 DepositRewardToken { - const NAME: &'static str = "deposit_reward_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 Nonces { + fn output(data: &[u8]) -> Result { + 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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct Period {} + impl Period { + const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::Function for Period { + const NAME: &'static str = "period"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { - 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 FutureEpochTime {} - impl FutureEpochTime { - const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Period { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PeriodTimestamp { + pub arg0: substreams::scalar::BigInt, + } + impl PeriodTimestamp { + const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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::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 FutureEpochTime { - const NAME: &'static str = "future_epoch_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 PeriodTimestamp { + const NAME: &'static str = "period_timestamp"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureEpochTime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IncreaseAllowance { - pub u_spender: Vec, - pub u_added_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl IncreaseAllowance { - const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_added_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for PeriodTimestamp { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Permit { + pub u_owner: Vec, + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + pub u_deadline: substreams::scalar::BigInt, + pub u_v: substreams::scalar::BigInt, + pub u_r: [u8; 32usize], + pub u_s: [u8; 32usize], + } + impl Permit { + const METHOD_ID: [u8; 4] = [213u8, 5u8, 172u8, 207u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_added_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(8usize), + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::FixedBytes(32usize), ], - ); - let mut encoded = Vec::with_capacity(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), + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for IncreaseAllowance { - const NAME: &'static str = "increaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct InflationRate {} - impl InflationRate { - const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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({ + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 InflationRate { - const NAME: &'static str = "inflation_rate"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for InflationRate { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpoint {} - impl IntegrateCheckpoint { - const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + u_deadline: { 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 IntegrateCheckpoint { - const NAME: &'static str = "integrate_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpointOf { - pub arg0: Vec, - } - impl IntegrateCheckpointOf { - const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + }, + u_v: { 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, + }, + u_r: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + u_s: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_deadline.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_v.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::FixedBytes(self.u_r.as_ref().to_vec()), + ethabi::Token::FixedBytes(self.u_s.as_ref().to_vec()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Permit { + const NAME: &'static str = "permit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Permit { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardCount {} + impl RewardCount { + const METHOD_ID: [u8; 4] = [150u8, 60u8, 148u8, 185u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 IntegrateCheckpointOf { - const NAME: &'static str = "integrate_checkpoint_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardCount { + const NAME: &'static str = "reward_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateCheckpointOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateFraction { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl IntegrateFraction { - const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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) + } + impl substreams_ethereum::rpc::RPCDecodable + for RewardCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardData { + pub arg0: Vec, + } + impl RewardData { + const METHOD_ID: [u8; 4] = [72u8, 233u8, 198u8, 94u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + Vec, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::Address, ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize) + ], + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + 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(), - }) - } - 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::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() + tuple_elements[1usize] + .clone() + .into_address() .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 IntegrateFraction { - const NAME: &'static str = "integrate_fraction"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateFraction { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupply { - pub arg0: substreams::scalar::BigInt, - } - impl IntegrateInvSupply { - const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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: { + .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) + }, + { let mut v = [0 as u8; 32]; - values - .pop() + tuple_elements[3usize] + .clone() + .into_uint() .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut 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) }, - }) - } - 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::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) - }) + { + 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) + }, + ) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn match_call(call: &substreams_ethereum::pb::eth::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, + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for RewardData { + const NAME: &'static str = "reward_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, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > for RewardData { + fn output( + data: &[u8], + ) -> Result< + ( + Vec, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardIntegralFor { + pub arg0: Vec, + pub arg1: Vec, + } + impl RewardIntegralFor { + const METHOD_ID: [u8; 4] = [240u8, 92u8, 192u8, 88u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 IntegrateInvSupply { - const NAME: &'static str = "integrate_inv_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardIntegralFor { + const NAME: &'static str = "reward_integral_for"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupplyOf { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl IntegrateInvSupplyOf { - const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable + for RewardIntegralFor { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardTokens { + pub arg0: substreams::scalar::BigInt, + } + impl RewardTokens { + const METHOD_ID: [u8; 4] = [84u8, 196u8, 159u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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 IntegrateInvSupplyOf { - const NAME: &'static str = "integrate_inv_supply_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardTokens { + const NAME: &'static str = "reward_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupplyOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsKilled {} - impl IsKilled { - const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for RewardTokens { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardsReceiver { + pub arg0: Vec, + } + impl RewardsReceiver { + const METHOD_ID: [u8; 4] = [1u8, 221u8, 171u8, 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for IsKilled { - const NAME: &'static str = "is_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardsReceiver { + const NAME: &'static str = "rewards_receiver"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsKilled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Kick { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl Kick { - const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::rpc::RPCDecodable> for RewardsReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl substreams_ethereum::Function for Kick { - const NAME: &'static str = "kick"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetKilled { + pub u_is_killed: bool, + } + impl SetKilled { + const METHOD_ID: [u8; 4] = [144u8, 178u8, 41u8, 151u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_is_killed: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ethabi::Token::Bool(self.u_is_killed.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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct LpToken {} - impl LpToken { - const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::Function for SetKilled { + const NAME: &'static str = "set_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetRewardDistributor { + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl SetRewardDistributor { + const METHOD_ID: [u8; 4] = [5u8, 138u8, 58u8, 36u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + 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 LpToken { - const NAME: &'static str = "lp_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::Function for SetRewardDistributor { + const NAME: &'static str = "set_reward_distributor"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for LpToken { - 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 Name {} - impl Name { - const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetRewardsReceiver { + pub u_receiver: Vec, + } + impl SetRewardsReceiver { + const METHOD_ID: [u8; 4] = [189u8, 249u8, 129u8, 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], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, } - pub fn 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 SetRewardsReceiver { + const NAME: &'static str = "set_rewards_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 Symbol {} + impl Symbol { + const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Symbol { + const NAME: &'static str = "symbol"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Symbol { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TotalSupply {} + impl TotalSupply { + const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Name { - const NAME: &'static str = "name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for TotalSupply { + const NAME: &'static str = "totalSupply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Name { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Nonces { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl Nonces { - const METHOD_ID: [u8; 4] = [126u8, 206u8, 190u8, 0u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Nonces { - const NAME: &'static str = "nonces"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Transfer { + const NAME: &'static str = "transfer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Nonces { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Period {} - impl Period { - const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Transfer { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferFrom { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl TransferFrom { + const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { let mut v = [0 as u8; 32]; values .pop() - .expect("one output data should have existed") - .into_int() + .expect(INTERNAL_ERR) + .into_uint() .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, + 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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for TransferFrom { + const NAME: &'static str = "transferFrom"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UserCheckpoint { + pub addr: Vec, + } + impl UserCheckpoint { + const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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 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 Period { - const NAME: &'static str = "period"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 UserCheckpoint { + const NAME: &'static str = "user_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Period { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct PeriodTimestamp { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl PeriodTimestamp { - const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 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 } - 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 { - 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({ + } + } + 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) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw1 { + pub u_value: substreams::scalar::BigInt, + } + impl Withdraw1 { + const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { + u_value: { 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 PeriodTimestamp { - const NAME: &'static str = "period_timestamp"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for PeriodTimestamp { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Permit { - pub u_owner: Vec, - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, - pub u_deadline: substreams::scalar::BigInt, - pub u_v: substreams::scalar::BigInt, - pub u_r: [u8; 32usize], - pub u_s: [u8; 32usize], - } - impl Permit { - const METHOD_ID: [u8; 4] = [213u8, 5u8, 172u8, 207u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(8usize), - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_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) - }, - u_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) - }, - u_r: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - u_s: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_owner), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_deadline.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_v.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::FixedBytes(self.u_r.as_ref().to_vec()), - ethabi::Token::FixedBytes(self.u_s.as_ref().to_vec()), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 - } - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for Permit { - const NAME: &'static str = "permit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + pub fn 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 Permit { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Withdraw1 { + const NAME: &'static str = "withdraw1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardCount {} - impl RewardCount { - const METHOD_ID: [u8; 4] = [150u8, 60u8, 148u8, 185u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + 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 Withdraw2 { + pub u_value: substreams::scalar::BigInt, + pub u_claim_rewards: bool, + } + impl Withdraw2 { + const METHOD_ID: [u8; 4] = [56u8, 208u8, 116u8, 54u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Bool], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { 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, - } + }, + u_claim_rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bool(self.u_claim_rewards.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, } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Withdraw2 { + const NAME: &'static str = "withdraw2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 WorkingBalances { + pub arg0: Vec, + } + impl WorkingBalances { + const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 RewardCount { - const NAME: &'static str = "reward_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 WorkingBalances { + const NAME: &'static str = "working_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for RewardCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardData { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl RewardData { - const METHOD_ID: [u8; 4] = [72u8, 233u8, 198u8, 94u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ( - Vec, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Tuple( - vec![ - ethabi::ParamType::Address, ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize) - ], - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - 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_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) - }, - { - let mut v = [0 as u8; 32]; - tuple_elements[3usize] - .clone() - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut 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) - }, - { - 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) - }, - ) - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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, - 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 RewardData { - const NAME: &'static str = "reward_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, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - > for RewardData { - fn output( - data: &[u8], - ) -> Result< - ( - Vec, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardIntegralFor { - pub arg0: Vec, - pub arg1: Vec, - } - impl RewardIntegralFor { - const METHOD_ID: [u8; 4] = [240u8, 92u8, 192u8, 88u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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 RewardIntegralFor { - const NAME: &'static str = "reward_integral_for"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for RewardIntegralFor { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardTokens { - pub arg0: substreams::scalar::BigInt, - } - impl RewardTokens { - const METHOD_ID: [u8; 4] = [84u8, 196u8, 159u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 RewardTokens { - const NAME: &'static str = "reward_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable> for RewardTokens { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardsReceiver { - pub arg0: Vec, - } - impl RewardsReceiver { - const METHOD_ID: [u8; 4] = [1u8, 221u8, 171u8, 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for RewardsReceiver { - const NAME: &'static str = "rewards_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 RewardsReceiver { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetKilled { - pub u_is_killed: bool, - } - impl SetKilled { - const METHOD_ID: [u8; 4] = [144u8, 178u8, 41u8, 151u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_is_killed: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Bool(self.u_is_killed.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 SetKilled { - const NAME: &'static str = "set_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetRewardDistributor { - pub u_reward_token: Vec, - pub u_distributor: Vec, - } - impl SetRewardDistributor { - const METHOD_ID: [u8; 4] = [5u8, 138u8, 58u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), - ], - ); - 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 SetRewardDistributor { - const NAME: &'static str = "set_reward_distributor"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetRewardsReceiver { - pub u_receiver: Vec, - } - impl SetRewardsReceiver { - const METHOD_ID: [u8; 4] = [189u8, 249u8, 129u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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 SetRewardsReceiver { - const NAME: &'static str = "set_rewards_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 Symbol {} - impl Symbol { - const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Symbol { - const NAME: &'static str = "symbol"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for Symbol { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TotalSupply {} - impl TotalSupply { - const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut v = [0 as u8; 32]; - values - .pop() - .expect("one output data should have existed") - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for TotalSupply { - const NAME: &'static str = "totalSupply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for TotalSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Transfer { - const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Transfer { - const NAME: &'static str = "transfer"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for Transfer { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferFrom { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl TransferFrom { - const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for TransferFrom { - const NAME: &'static str = "transferFrom"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UserCheckpoint { - pub addr: Vec, - } - impl UserCheckpoint { - const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 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 UserCheckpoint { - const NAME: &'static str = "user_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::rpc::RPCDecodable + for WorkingBalances { + 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), + } + #[derive(Debug, Clone, PartialEq)] + pub struct WorkingSupply {} + impl WorkingSupply { + const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw1 { - pub u_value: substreams::scalar::BigInt, - } - impl Withdraw1 { - const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 Withdraw1 { - const NAME: &'static str = "withdraw1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + .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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw2 { - pub u_value: substreams::scalar::BigInt, - pub u_claim_rewards: bool, + } + impl substreams_ethereum::Function for WorkingSupply { + const NAME: &'static str = "working_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl Withdraw2 { - const METHOD_ID: [u8; 4] = [56u8, 208u8, 116u8, 54u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Bool], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_claim_rewards: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Bool(self.u_claim_rewards.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 decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for Withdraw2 { - const NAME: &'static str = "withdraw2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for WorkingSupply { + 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 ApplyOwnership { + pub admin: Vec, + } + impl ApplyOwnership { + const TOPIC_ID: [u8; 32] = [ + 235u8, + 238u8, + 45u8, + 87u8, + 57u8, + 1u8, + 16u8, + 98u8, + 203u8, + 79u8, + 20u8, + 17u8, + 63u8, + 59u8, + 54u8, + 191u8, + 15u8, + 254u8, + 61u8, + 165u8, + 192u8, + 86u8, + 143u8, + 100u8, + 24u8, + 157u8, + 16u8, + 18u8, + 161u8, + 24u8, + 145u8, + 5u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for ApplyOwnership { + const NAME: &'static str = "ApplyOwnership"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingBalances { - pub arg0: Vec, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl WorkingBalances { - const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approval { + pub u_owner: Vec, + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approval { + const TOPIC_ID: [u8; 32] = [ + 140u8, + 91u8, + 225u8, + 229u8, + 235u8, + 236u8, + 125u8, + 91u8, + 209u8, + 79u8, + 113u8, + 66u8, + 125u8, + 30u8, + 132u8, + 243u8, + 221u8, + 3u8, + 20u8, + 192u8, + 247u8, + 178u8, + 41u8, + 30u8, + 91u8, + 32u8, + 10u8, + 200u8, + 199u8, + 195u8, + 185u8, + 37u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .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::Uint(256usize)], - data.as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_owner' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'u_spender' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 WorkingBalances { - const NAME: &'static str = "working_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::Event for Approval { + const NAME: &'static str = "Approval"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingBalances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingSupply {} - impl WorkingSupply { - const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitOwnership { + pub admin: Vec, + } + impl CommitOwnership { + const TOPIC_ID: [u8; 32] = [ + 47u8, + 86u8, + 129u8, + 10u8, + 107u8, + 244u8, + 10u8, + 240u8, + 89u8, + 185u8, + 109u8, + 58u8, + 234u8, + 77u8, + 181u8, + 64u8, + 129u8, + 243u8, + 120u8, + 2u8, + 154u8, + 81u8, + 131u8, + 144u8, + 73u8, + 16u8, + 147u8, + 167u8, + 182u8, + 112u8, + 50u8, + 233u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for CommitOwnership { + const NAME: &'static str = "CommitOwnership"; + 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 Deposit { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Deposit { + const TOPIC_ID: [u8; 32] = [ + 225u8, + 255u8, + 252u8, + 196u8, + 146u8, + 61u8, + 4u8, + 181u8, + 89u8, + 244u8, + 210u8, + 154u8, + 139u8, + 252u8, + 108u8, + 218u8, + 4u8, + 235u8, + 91u8, + 13u8, + 60u8, + 70u8, + 7u8, + 81u8, + 194u8, + 64u8, + 44u8, + 92u8, + 92u8, + 201u8, + 16u8, + 156u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { 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 WorkingSupply { - const NAME: &'static str = "working_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingSupply { - 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 ApplyOwnership { - pub admin: Vec, - } - impl ApplyOwnership { - const TOPIC_ID: [u8; 32] = [ - 235u8, - 238u8, - 45u8, - 87u8, - 57u8, - 1u8, - 16u8, - 98u8, - 203u8, - 79u8, - 20u8, - 17u8, - 63u8, - 59u8, - 54u8, - 191u8, - 15u8, - 254u8, - 61u8, - 165u8, - 192u8, - 86u8, - 143u8, - 100u8, - 24u8, - 157u8, - 16u8, - 18u8, - 161u8, - 24u8, - 145u8, - 5u8, - ]; - 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( + } + impl substreams_ethereum::Event for Deposit { + const NAME: &'static str = "Deposit"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 242u8, + 82u8, + 173u8, + 27u8, + 226u8, + 200u8, + 155u8, + 105u8, + 194u8, + 176u8, + 104u8, + 252u8, + 55u8, + 141u8, + 170u8, + 149u8, + 43u8, + 167u8, + 241u8, + 99u8, + 196u8, + 161u8, + 22u8, + 40u8, + 245u8, + 90u8, + 77u8, + 245u8, + 35u8, + 179u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for ApplyOwnership { - const NAME: &'static str = "ApplyOwnership"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Approval { - pub u_owner: Vec, - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Approval { - const TOPIC_ID: [u8; 32] = [ - 140u8, - 91u8, - 225u8, - 229u8, - 235u8, - 236u8, - 125u8, - 91u8, - 209u8, - 79u8, - 113u8, - 66u8, - 125u8, - 30u8, - 132u8, - 243u8, - 221u8, - 3u8, - 20u8, - 192u8, - 247u8, - 178u8, - 41u8, - 30u8, - 91u8, - 32u8, - 10u8, - 200u8, - 199u8, - 195u8, - 185u8, - 37u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_owner: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_owner' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_from' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_spender' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Approval { - const NAME: &'static str = "Approval"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitOwnership { - pub admin: Vec, - } - impl CommitOwnership { - const TOPIC_ID: [u8; 32] = [ - 47u8, - 86u8, - 129u8, - 10u8, - 107u8, - 244u8, - 10u8, - 240u8, - 89u8, - 185u8, - 109u8, - 58u8, - 234u8, - 77u8, - 181u8, - 64u8, - 129u8, - 243u8, - 120u8, - 2u8, - 154u8, - 81u8, - 131u8, - 144u8, - 73u8, - 16u8, - 147u8, - 167u8, - 182u8, - 112u8, - 50u8, - 233u8, - ]; - 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( + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values + .map_err(|e| { + format!( + "unable to decode param 'u_to' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + 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 CommitOwnership { - const NAME: &'static str = "CommitOwnership"; - 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 Deposit { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Deposit { - const TOPIC_ID: [u8; 32] = [ - 225u8, - 255u8, - 252u8, - 196u8, - 146u8, - 61u8, - 4u8, - 181u8, - 89u8, - 244u8, - 210u8, - 154u8, - 139u8, - 252u8, - 108u8, - 218u8, - 4u8, - 235u8, - 91u8, - 13u8, - 60u8, - 70u8, - 7u8, - 81u8, - 194u8, - 64u8, - 44u8, - 92u8, - 92u8, - 201u8, - 16u8, - 156u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Transfer { + const NAME: &'static str = "Transfer"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateLiquidityLimit { + pub user: Vec, + pub original_balance: substreams::scalar::BigInt, + pub original_supply: substreams::scalar::BigInt, + pub working_balance: substreams::scalar::BigInt, + pub working_supply: substreams::scalar::BigInt, + } + impl UpdateLiquidityLimit { + const TOPIC_ID: [u8; 32] = [ + 126u8, + 205u8, + 132u8, + 52u8, + 63u8, + 118u8, + 162u8, + 61u8, + 34u8, + 39u8, + 41u8, + 14u8, + 2u8, + 136u8, + 218u8, + 50u8, + 81u8, + 176u8, + 69u8, + 84u8, + 22u8, + 152u8, + 229u8, + 117u8, + 165u8, + 81u8, + 90u8, + 244u8, + 240u8, + 65u8, + 151u8, + 163u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + original_balance: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Deposit { - const NAME: &'static str = "Deposit"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Transfer { - const TOPIC_ID: [u8; 32] = [ - 221u8, - 242u8, - 82u8, - 173u8, - 27u8, - 226u8, - 200u8, - 155u8, - 105u8, - 194u8, - 176u8, - 104u8, - 252u8, - 55u8, - 141u8, - 170u8, - 149u8, - 43u8, - 167u8, - 241u8, - 99u8, - 196u8, - 161u8, - 22u8, - 40u8, - 245u8, - 90u8, - 77u8, - 245u8, - 35u8, - 179u8, - 239u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_from' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + original_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_to' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_balance: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Transfer { - const NAME: &'static str = "Transfer"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateLiquidityLimit { - pub user: Vec, - pub original_balance: substreams::scalar::BigInt, - pub original_supply: substreams::scalar::BigInt, - pub working_balance: substreams::scalar::BigInt, - pub working_supply: substreams::scalar::BigInt, - } - impl UpdateLiquidityLimit { - const TOPIC_ID: [u8; 32] = [ - 126u8, - 205u8, - 132u8, - 52u8, - 63u8, - 118u8, - 162u8, - 61u8, - 34u8, - 39u8, - 41u8, - 14u8, - 2u8, - 136u8, - 218u8, - 50u8, - 81u8, - 176u8, - 69u8, - 84u8, - 22u8, - 152u8, - 229u8, - 117u8, - 165u8, - 81u8, - 90u8, - 244u8, - 240u8, - 65u8, - 151u8, - 163u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - user: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - original_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - original_supply: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_supply: { - let mut v = [0 as u8; 32]; - values - .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 UpdateLiquidityLimit { - const NAME: &'static str = "UpdateLiquidityLimit"; - 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 Withdraw { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Withdraw { - const TOPIC_ID: [u8; 32] = [ - 136u8, - 78u8, - 218u8, - 217u8, - 206u8, - 111u8, - 162u8, - 68u8, - 13u8, - 138u8, - 84u8, - 204u8, - 18u8, - 52u8, - 144u8, - 235u8, - 150u8, - 210u8, - 118u8, - 132u8, - 121u8, - 212u8, - 159u8, - 249u8, - 199u8, - 54u8, - 97u8, - 37u8, - 169u8, - 66u8, - 67u8, - 100u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for UpdateLiquidityLimit { + const NAME: &'static str = "UpdateLiquidityLimit"; + 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 Withdraw { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Withdraw { + const TOPIC_ID: [u8; 32] = [ + 136u8, + 78u8, + 218u8, + 217u8, + 206u8, + 111u8, + 162u8, + 68u8, + 13u8, + 138u8, + 84u8, + 204u8, + 18u8, + 52u8, + 144u8, + 235u8, + 150u8, + 210u8, + 118u8, + 132u8, + 121u8, + 212u8, + 159u8, + 249u8, + 199u8, + 54u8, + 97u8, + 37u8, + 169u8, + 66u8, + 67u8, + 100u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for Withdraw { - const NAME: &'static str = "Withdraw"; - 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 Withdraw { + const NAME: &'static str = "Withdraw"; + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/gauges/liquidity_gauge_v6.rs b/src/abi/curve/gauges/liquidity_gauge_v6.rs index f05bc19..4883c0d 100644 --- a/src/abi/curve/gauges/liquidity_gauge_v6.rs +++ b/src/abi/curve/gauges/liquidity_gauge_v6.rs @@ -1,3991 +1,3840 @@ - 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 DomainSeparator {} - impl DomainSeparator { - const METHOD_ID: [u8; 4] = [54u8, 68u8, 229u8, 21u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result<[u8; 32usize], String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::FixedBytes(32usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut result = [0u8; 32]; - let v = values - .pop() - .expect("one output data should have existed") - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } +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 DomainSeparator {} + impl DomainSeparator { + const METHOD_ID: [u8; 4] = [54u8, 68u8, 229u8, 21u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for DomainSeparator { - const NAME: &'static str = "DOMAIN_SEPARATOR"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for DomainSeparator { + const NAME: &'static str = "DOMAIN_SEPARATOR"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for DomainSeparator { - fn output(data: &[u8]) -> Result<[u8; 32usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AddReward { - pub u_reward_token: Vec, - pub u_distributor: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl AddReward { - const METHOD_ID: [u8; 4] = [232u8, 222u8, 13u8, 77u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), - ], - ); - 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<[u8; 32usize]> for DomainSeparator { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) } - impl substreams_ethereum::Function for AddReward { - const NAME: &'static str = "add_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 AddReward { + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl AddReward { + const METHOD_ID: [u8; 4] = [232u8, 222u8, 13u8, 77u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + 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 Allowance { - pub arg0: Vec, - pub arg1: Vec, + } + impl substreams_ethereum::Function for AddReward { + const NAME: &'static str = "add_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl Allowance { - const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Allowance { + pub arg0: Vec, + pub arg1: Vec, + } + impl Allowance { + const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 } - 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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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({ + } + } + impl substreams_ethereum::Function for Allowance { + const NAME: &'static str = "allowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Allowance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approve { + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approve { + const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Approve { + const NAME: &'static str = "approve"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Approve { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BalanceOf { + pub arg0: Vec, + } + impl BalanceOf { + const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + 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::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Allowance { - const NAME: &'static str = "allowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) + } + impl substreams_ethereum::Function for BalanceOf { + const NAME: &'static str = "balanceOf"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for BalanceOf { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimRewards1 {} + impl ClaimRewards1 { + const METHOD_ID: [u8; 4] = [230u8, 241u8, 218u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - self.encode() + } + } + impl substreams_ethereum::Function for ClaimRewards1 { + const NAME: &'static str = "claim_rewards1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards2 { + pub u_addr: Vec, + } + impl ClaimRewards2 { + const METHOD_ID: [u8; 4] = [132u8, 233u8, 189u8, 126u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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::rpc::RPCDecodable - for Allowance { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for ClaimRewards2 { + const NAME: &'static str = "claim_rewards2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards3 { + pub u_addr: Vec, + pub u_receiver: Vec, + } + impl ClaimRewards3 { + const METHOD_ID: [u8; 4] = [159u8, 172u8, 235u8, 27u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 Approve { - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for ClaimRewards3 { + const NAME: &'static str = "claim_rewards3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl Approve { - const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimableReward { + pub u_user: Vec, + pub u_reward_token: Vec, + } + impl ClaimableReward { + const METHOD_ID: [u8; 4] = [51u8, 253u8, 111u8, 116u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_user: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_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.u_user)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_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 } - 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 { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + } + impl substreams_ethereum::Function for ClaimableReward { + const NAME: &'static str = "claimable_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimableReward { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimableTokens { + pub addr: Vec, + } + impl ClaimableTokens { + const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for ClaimableTokens { + const NAME: &'static str = "claimable_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimableTokens { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimedReward { + pub u_addr: Vec, + pub u_token: Vec, + } + impl ClaimedReward { + const METHOD_ID: [u8; 4] = [231u8, 126u8, 116u8, 55u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_addr)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 Approve { - const NAME: &'static str = "approve"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for ClaimedReward { + const NAME: &'static str = "claimed_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Approve { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct BalanceOf { - pub arg0: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable + for ClaimedReward { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl BalanceOf { - const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct Decimals {} + impl Decimals { + const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(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 } - let 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + } + } + impl substreams_ethereum::Function for Decimals { + const NAME: &'static str = "decimals"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Decimals { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DecreaseAllowance { + pub u_spender: Vec, + pub u_subtracted_value: substreams::scalar::BigInt, + } + impl DecreaseAllowance { + const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_subtracted_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_subtracted_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for BalanceOf { - const NAME: &'static str = "balanceOf"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for BalanceOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for DecreaseAllowance { + const NAME: &'static str = "decreaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimRewards1 {} - impl ClaimRewards1 { - const METHOD_ID: [u8; 4] = [230u8, 241u8, 218u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 ClaimRewards1 { - const NAME: &'static str = "claim_rewards1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ClaimRewards2 { - pub u_addr: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl ClaimRewards2 { - const METHOD_ID: [u8; 4] = [132u8, 233u8, 189u8, 126u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_addr: values + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit1 { + pub u_value: substreams::scalar::BigInt, + } + impl Deposit1 { + const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_value: { + 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.u_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, - } - } + .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.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for ClaimRewards2 { - const NAME: &'static str = "claim_rewards2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 ClaimRewards3 { - pub u_addr: Vec, - pub u_receiver: Vec, + } + impl substreams_ethereum::Function for Deposit1 { + const NAME: &'static str = "deposit1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl ClaimRewards3 { - const METHOD_ID: [u8; 4] = [159u8, 172u8, 235u8, 27u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_addr: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Deposit2 { + pub u_value: substreams::scalar::BigInt, + pub u_addr: Vec, + } + impl Deposit2 { + const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_receiver), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_addr)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for ClaimRewards3 { - const NAME: &'static str = "claim_rewards3"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 ClaimableReward { - pub u_user: Vec, - pub u_reward_token: Vec, + } + impl substreams_ethereum::Function for Deposit2 { + const NAME: &'static str = "deposit2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl ClaimableReward { - const METHOD_ID: [u8; 4] = [51u8, 253u8, 111u8, 116u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_user: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + 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 Deposit3 { + pub u_value: substreams::scalar::BigInt, + pub u_addr: Vec, + pub u_claim_rewards: bool, + } + impl Deposit3 { + const METHOD_ID: [u8; 4] = [131u8, 223u8, 103u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_user), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::Bool, ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { 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 - } - } + }, + u_addr: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_claim_rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_addr)), + ethabi::Token::Bool(self.u_claim_rewards.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 ClaimableReward { - const NAME: &'static str = "claimable_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Deposit3 { + const NAME: &'static str = "deposit3"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimableReward { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimableTokens { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl ClaimableTokens { - const METHOD_ID: [u8; 4] = [51u8, 19u8, 69u8, 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::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 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 DepositRewardToken1 { + pub u_reward_token: Vec, + pub u_amount: substreams::scalar::BigInt, + } + impl DepositRewardToken1 { + const METHOD_ID: [u8; 4] = [147u8, 247u8, 170u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_amount: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for ClaimableTokens { - const NAME: &'static str = "claimable_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 ClaimableTokens { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for DepositRewardToken1 { + const NAME: &'static str = "deposit_reward_token1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimedReward { - pub u_addr: Vec, - pub u_token: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl ClaimedReward { - const METHOD_ID: [u8; 4] = [231u8, 126u8, 116u8, 55u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_token: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DepositRewardToken2 { + pub u_reward_token: Vec, + pub u_amount: substreams::scalar::BigInt, + pub u_epoch: substreams::scalar::BigInt, + } + impl DepositRewardToken2 { + const METHOD_ID: [u8; 4] = [51u8, 181u8, 10u8, 237u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_amount: { + 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.u_addr), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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({ + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_epoch: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_epoch.clone().to_bytes_be() { + (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, } - pub fn 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 DepositRewardToken2 { + const NAME: &'static str = "deposit_reward_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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Factory {} + impl Factory { + const METHOD_ID: [u8; 4] = [196u8, 90u8, 1u8, 85u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 Factory { + const NAME: &'static str = "factory"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Factory { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureEpochTime {} + impl FutureEpochTime { + const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 ClaimedReward { - const NAME: &'static str = "claimed_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureEpochTime { + const NAME: &'static str = "future_epoch_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for ClaimedReward { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Decimals {} - impl Decimals { - const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureEpochTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IncreaseAllowance { + pub u_spender: Vec, + pub u_added_value: substreams::scalar::BigInt, + } + impl IncreaseAllowance { + const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_added_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_added_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Decimals { - const NAME: &'static str = "decimals"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for IncreaseAllowance { + const NAME: &'static str = "increaseAllowance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Decimals { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct DecreaseAllowance { - pub u_spender: Vec, - pub u_subtracted_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl DecreaseAllowance { - const METHOD_ID: [u8; 4] = [164u8, 87u8, 194u8, 215u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct InflationRate {} + impl InflationRate { + const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + 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 } - 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 { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_subtracted_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_subtracted_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + } + impl substreams_ethereum::Function for InflationRate { + const NAME: &'static str = "inflation_rate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for InflationRate { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpoint {} + impl IntegrateCheckpoint { + const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for IntegrateCheckpoint { + const NAME: &'static str = "integrate_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpoint { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateCheckpointOf { + pub arg0: Vec, + } + impl IntegrateCheckpointOf { + const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 DecreaseAllowance { - const NAME: &'static str = "decreaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for IntegrateCheckpointOf { + const NAME: &'static str = "integrate_checkpoint_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for DecreaseAllowance { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit1 { - pub u_value: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateCheckpointOf { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl Deposit1 { - const METHOD_ID: [u8; 4] = [182u8, 181u8, 95u8, 37u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 IntegrateFraction { + pub arg0: Vec, + } + impl IntegrateFraction { + const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 } - 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + } + } + impl substreams_ethereum::Function for IntegrateFraction { + const NAME: &'static str = "integrate_fraction"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateFraction { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupply { + pub arg0: substreams::scalar::BigInt, + } + impl IntegrateInvSupply { + const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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(), - ), + } + .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, + ), + ], + ); + let mut encoded = Vec::with_capacity(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 Deposit1 { - const NAME: &'static str = "deposit1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IntegrateInvSupply { + const NAME: &'static str = "integrate_inv_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Deposit2 { - pub u_value: substreams::scalar::BigInt, - pub u_addr: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl Deposit2 { - const METHOD_ID: [u8; 4] = [110u8, 85u8, 63u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_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::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 Deposit2 { - const NAME: &'static str = "deposit2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Deposit3 { - pub u_value: substreams::scalar::BigInt, - pub u_addr: Vec, - pub u_claim_rewards: bool, - } - impl Deposit3 { - const METHOD_ID: [u8; 4] = [131u8, 223u8, 103u8, 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), - ethabi::ParamType::Address, - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_addr: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_claim_rewards: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_addr), - ), - ethabi::Token::Bool(self.u_claim_rewards.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 Deposit3 { - const NAME: &'static str = "deposit3"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 DepositRewardToken1 { - pub u_reward_token: Vec, - pub u_amount: substreams::scalar::BigInt, - } - impl DepositRewardToken1 { - const METHOD_ID: [u8; 4] = [147u8, 247u8, 170u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 DepositRewardToken1 { - const NAME: &'static str = "deposit_reward_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DepositRewardToken2 { - pub u_reward_token: Vec, - pub u_amount: substreams::scalar::BigInt, - pub u_epoch: substreams::scalar::BigInt, - } - impl DepositRewardToken2 { - const METHOD_ID: [u8; 4] = [51u8, 181u8, 10u8, 237u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_epoch: { - let mut v = [0 as u8; 32]; - values - .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.u_reward_token), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_epoch.clone().to_bytes_be() { - (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 DepositRewardToken2 { - const NAME: &'static str = "deposit_reward_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 IntegrateInvSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct Factory {} - impl Factory { - const METHOD_ID: [u8; 4] = [196u8, 90u8, 1u8, 85u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct IntegrateInvSupplyOf { + pub arg0: Vec, + } + impl IntegrateInvSupplyOf { + const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Factory { - const NAME: &'static str = "factory"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable> for Factory { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureEpochTime {} - impl FutureEpochTime { - const METHOD_ID: [u8; 4] = [190u8, 93u8, 27u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 FutureEpochTime { - const NAME: &'static str = "future_epoch_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureEpochTime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IncreaseAllowance { - pub u_spender: Vec, - pub u_added_value: substreams::scalar::BigInt, - } - impl IncreaseAllowance { - const METHOD_ID: [u8; 4] = [57u8, 80u8, 147u8, 81u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_spender: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_added_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_added_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + .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::Uint(256usize)], + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for IncreaseAllowance { - const NAME: &'static str = "increaseAllowance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for IncreaseAllowance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct InflationRate {} - impl InflationRate { - const METHOD_ID: [u8; 4] = [24u8, 6u8, 146u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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 - } + .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 InflationRate { - const NAME: &'static str = "inflation_rate"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for InflationRate { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpoint {} - impl IntegrateCheckpoint { - const METHOD_ID: [u8; 4] = [211u8, 31u8, 63u8, 109u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 IntegrateCheckpoint { - const NAME: &'static str = "integrate_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateCheckpointOf { - pub arg0: Vec, - } - impl IntegrateCheckpointOf { - const METHOD_ID: [u8; 4] = [155u8, 211u8, 36u8, 242u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::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 IntegrateCheckpointOf { - const NAME: &'static str = "integrate_checkpoint_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateCheckpointOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateFraction { - pub arg0: Vec, - } - impl IntegrateFraction { - const METHOD_ID: [u8; 4] = [9u8, 64u8, 7u8, 7u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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::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 IntegrateInvSupplyOf { + const NAME: &'static str = "integrate_inv_supply_of"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for IntegrateFraction { - const NAME: &'static str = "integrate_fraction"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateFraction { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupply { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable + for IntegrateInvSupplyOf { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl IntegrateInvSupply { - const METHOD_ID: [u8; 4] = [254u8, 200u8, 238u8, 12u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - 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 - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsKilled {} + impl IsKilled { + const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 IntegrateInvSupply { - const NAME: &'static str = "integrate_inv_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IsKilled { + const NAME: &'static str = "is_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IntegrateInvSupplyOf { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl IntegrateInvSupplyOf { - const METHOD_ID: [u8; 4] = [222u8, 38u8, 59u8, 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], - 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::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 IntegrateInvSupplyOf { - const NAME: &'static str = "integrate_inv_supply_of"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for IntegrateInvSupplyOf { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::rpc::RPCDecodable for IsKilled { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsKilled {} - impl IsKilled { - const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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), + } + #[derive(Debug, Clone, PartialEq)] + pub struct Kick { + pub addr: Vec, + } + impl Kick { + const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .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 IsKilled { - const NAME: &'static str = "is_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Kick { + const NAME: &'static str = "kick"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsKilled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Kick { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl Kick { - const METHOD_ID: [u8; 4] = [150u8, 197u8, 81u8, 117u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 LpToken {} + impl LpToken { + const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Kick { - const NAME: &'static str = "kick"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LpToken {} - impl LpToken { - const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + } + impl substreams_ethereum::Function for LpToken { + const NAME: &'static str = "lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for LpToken { - const NAME: &'static str = "lp_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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable> for LpToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[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, + } + impl substreams_ethereum::rpc::RPCDecodable> for LpToken { + fn output(data: &[u8]) -> Result, String> { + 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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 Name {} + impl Name { + const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for 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::Function for Name { + const NAME: &'static str = "name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Manager { - 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 Name {} - impl Name { - const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Name { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Nonces { + pub arg0: Vec, + } + impl Nonces { + const METHOD_ID: [u8; 4] = [126u8, 206u8, 190u8, 0u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Nonces { + const NAME: &'static str = "nonces"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Nonces { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Period {} + impl Period { + const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 Name { - const NAME: &'static str = "name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Period { + const NAME: &'static str = "period"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Name { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Nonces { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl Nonces { - const METHOD_ID: [u8; 4] = [126u8, 206u8, 190u8, 0u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + impl substreams_ethereum::rpc::RPCDecodable for Period { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PeriodTimestamp { + pub arg0: substreams::scalar::BigInt, + } + impl PeriodTimestamp { + const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Nonces { - const NAME: &'static str = "nonces"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for PeriodTimestamp { + const NAME: &'static str = "period_timestamp"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Nonces { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Period {} - impl Period { - const METHOD_ID: [u8; 4] = [239u8, 120u8, 212u8, 253u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for PeriodTimestamp { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Permit { + pub u_owner: Vec, + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + pub u_deadline: substreams::scalar::BigInt, + pub u_v: substreams::scalar::BigInt, + pub u_r: [u8; 32usize], + pub u_s: [u8; 32usize], + } + impl Permit { + const METHOD_ID: [u8; 4] = [213u8, 5u8, 172u8, 207u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(8usize), + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::FixedBytes(32usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { let mut v = [0 as u8; 32]; values .pop() - .expect("one output data should have existed") - .into_int() + .expect(INTERNAL_ERR) + .into_uint() .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 Period { - const NAME: &'static str = "period"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Period { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PeriodTimestamp { - pub arg0: substreams::scalar::BigInt, - } - impl PeriodTimestamp { - const METHOD_ID: [u8; 4] = [117u8, 152u8, 16u8, 140u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - 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({ + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_deadline: { 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 PeriodTimestamp { - const NAME: &'static str = "period_timestamp"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for PeriodTimestamp { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Permit { - pub u_owner: Vec, - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, - pub u_deadline: substreams::scalar::BigInt, - pub u_v: substreams::scalar::BigInt, - pub u_r: [u8; 32usize], - pub u_s: [u8; 32usize], - } - impl Permit { - const METHOD_ID: [u8; 4] = [213u8, 5u8, 172u8, 207u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(8usize), - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_owner: values + }, + u_v: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_r: { + let mut result = [0u8; 32]; + let v = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + u_s: { + let mut result = [0u8; 32]; + let v = values + .pop() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_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) - }, - u_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) - }, - u_r: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - u_s: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_owner), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_spender), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_spender)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_v.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_v.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::FixedBytes(self.u_r.as_ref().to_vec()), - ethabi::Token::FixedBytes(self.u_s.as_ref().to_vec()), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 - } + ), + ethabi::Token::FixedBytes(self.u_r.as_ref().to_vec()), + ethabi::Token::FixedBytes(self.u_s.as_ref().to_vec()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn 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 Permit { - const NAME: &'static str = "permit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Permit { + const NAME: &'static str = "permit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Permit { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardCount {} - impl RewardCount { - const METHOD_ID: [u8; 4] = [150u8, 60u8, 148u8, 185u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 - } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Permit { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardCount {} + impl RewardCount { + const METHOD_ID: [u8; 4] = [150u8, 60u8, 148u8, 185u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 RewardCount { - const NAME: &'static str = "reward_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 RewardCount { + const NAME: &'static str = "reward_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for RewardCount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardData { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl RewardData { - const METHOD_ID: [u8; 4] = [72u8, 233u8, 198u8, 94u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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() + } + impl substreams_ethereum::rpc::RPCDecodable + for RewardCount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardData { + pub arg0: Vec, + } + impl RewardData { + const METHOD_ID: [u8; 4] = [72u8, 233u8, 198u8, 94u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + ( + Vec, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Tuple( + vec![ + ethabi::ParamType::Address, ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize) + ], + ), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + 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_address() .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, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ( - Vec, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Tuple( - vec![ - ethabi::ParamType::Address, ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize) - ], - ), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let tuple_elements = values - .pop() - .expect("one output data should have existed") - .into_tuple() - .expect(INTERNAL_ERR); - ( - tuple_elements[0usize] + { + 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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - 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[4usize] .clone() - .into_address() + .into_uint() .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) - }, - { - let mut v = [0 as u8; 32]; - tuple_elements[3usize] - .clone() - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut 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) - }, - { - 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) - }, - ) - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + 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) + }, + ) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::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, - 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 - } + } + pub fn call( + &self, + address: Vec, + ) -> Option< + ( + Vec, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for RewardData { - const NAME: &'static str = "reward_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::Function for RewardData { + const NAME: &'static str = "reward_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< + } + impl substreams_ethereum::rpc::RPCDecodable< + ( + Vec, + Vec, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > for RewardData { + fn output( + data: &[u8], + ) -> Result< ( Vec, Vec, @@ -3994,2565 +3843,2460 @@ substreams::scalar::BigInt, substreams::scalar::BigInt, ), - > for RewardData { - fn output( - data: &[u8], - ) -> Result< - ( - Vec, - Vec, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardIntegralFor { - pub arg0: Vec, - pub arg1: Vec, - } - impl RewardIntegralFor { - const METHOD_ID: [u8; 4] = [240u8, 92u8, 192u8, 88u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + String, + > { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardIntegralFor { + pub arg0: Vec, + pub arg1: Vec, + } + impl RewardIntegralFor { + const METHOD_ID: [u8; 4] = [240u8, 92u8, 192u8, 88u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + arg0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + arg1: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), + ], + ); + let mut encoded = Vec::with_capacity(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 } - 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 { - arg0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - arg1: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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)), - ethabi::Token::Address(ethabi::Address::from_slice(&self.arg1)), - ], - ); - let mut encoded = Vec::with_capacity(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({ + } + } + impl substreams_ethereum::Function for RewardIntegralFor { + const NAME: &'static str = "reward_integral_for"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RewardIntegralFor { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardTokens { + pub arg0: substreams::scalar::BigInt, + } + impl RewardTokens { + const METHOD_ID: [u8; 4] = [84u8, 196u8, 159u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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 RewardIntegralFor { - const NAME: &'static str = "reward_integral_for"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardTokens { + const NAME: &'static str = "reward_tokens"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for RewardIntegralFor { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RewardTokens { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl RewardTokens { - const METHOD_ID: [u8; 4] = [84u8, 196u8, 159u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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(), + } + impl substreams_ethereum::rpc::RPCDecodable> for RewardTokens { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RewardsReceiver { + pub arg0: Vec, + } + impl RewardsReceiver { + const METHOD_ID: [u8; 4] = [1u8, 221u8, 171u8, 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for RewardTokens { - const NAME: &'static str = "reward_tokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RewardsReceiver { + const NAME: &'static str = "rewards_receiver"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for RewardTokens { - 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 RewardsReceiver { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl RewardsReceiver { - const METHOD_ID: [u8; 4] = [1u8, 221u8, 171u8, 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::rpc::RPCDecodable> for RewardsReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Salt {} + impl Salt { + const METHOD_ID: [u8; 4] = [191u8, 160u8, 177u8, 51u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 RewardsReceiver { - const NAME: &'static str = "rewards_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::Function for Salt { + const NAME: &'static str = "salt"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for RewardsReceiver { - 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 Salt {} - impl Salt { - const METHOD_ID: [u8; 4] = [191u8, 160u8, 177u8, 51u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for Salt { - const NAME: &'static str = "salt"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - 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 Salt { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for Salt { - fn output(data: &[u8]) -> Result<[u8; 32usize], String> { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeManager { + pub u_gauge_manager: Vec, + } + impl SetGaugeManager { + const METHOD_ID: [u8; 4] = [170u8, 206u8, 29u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge_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.u_gauge_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetGaugeManager { - pub u_gauge_manager: Vec, + } + impl substreams_ethereum::Function for SetGaugeManager { + const NAME: &'static str = "set_gauge_manager"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetGaugeManager { - const METHOD_ID: [u8; 4] = [170u8, 206u8, 29u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_gauge_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.u_gauge_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, - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for SetGaugeManager { - const NAME: &'static str = "set_gauge_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() + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetKilled { + pub u_is_killed: bool, + } + impl SetKilled { + const METHOD_ID: [u8; 4] = [144u8, 178u8, 41u8, 151u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + u_is_killed: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[ethabi::Token::Bool(self.u_is_killed.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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetKilled { - pub u_is_killed: bool, + } + impl substreams_ethereum::Function for SetKilled { + const NAME: &'static str = "set_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetKilled { - const METHOD_ID: [u8; 4] = [144u8, 178u8, 41u8, 151u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_is_killed: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Bool(self.u_is_killed.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 decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for SetKilled { - const NAME: &'static str = "set_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetRewardDistributor { + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl SetRewardDistributor { + const METHOD_ID: [u8; 4] = [5u8, 138u8, 58u8, 36u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + 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 SetRewardDistributor { - pub u_reward_token: Vec, - pub u_distributor: Vec, + } + impl substreams_ethereum::Function for SetRewardDistributor { + const NAME: &'static str = "set_reward_distributor"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetRewardDistributor { - const METHOD_ID: [u8; 4] = [5u8, 138u8, 58u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), - ], - ); - 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 SetRewardDistributor { - const NAME: &'static str = "set_reward_distributor"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetRewardsReceiver { + pub u_receiver: Vec, + } + impl SetRewardsReceiver { + const METHOD_ID: [u8; 4] = [189u8, 249u8, 129u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 SetRewardsReceiver { - pub u_receiver: Vec, + } + impl substreams_ethereum::Function for SetRewardsReceiver { + const NAME: &'static str = "set_rewards_receiver"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetRewardsReceiver { - const METHOD_ID: [u8; 4] = [189u8, 249u8, 129u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Symbol {} + impl Symbol { + const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_string() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for SetRewardsReceiver { - const NAME: &'static str = "set_rewards_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 Symbol {} - impl Symbol { - const METHOD_ID: [u8; 4] = [149u8, 216u8, 155u8, 65u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::String], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_string() - .expect(INTERNAL_ERR), + } + impl substreams_ethereum::Function for Symbol { + const NAME: &'static str = "symbol"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Symbol { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TotalSupply {} + impl TotalSupply { + const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 Symbol { - const NAME: &'static str = "symbol"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for TotalSupply { + const NAME: &'static str = "totalSupply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Symbol { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct TotalSupply {} - impl TotalSupply { - const METHOD_ID: [u8; 4] = [24u8, 22u8, 13u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TotalSupply { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for TotalSupply { - const NAME: &'static str = "totalSupply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Transfer { + const NAME: &'static str = "transfer"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for TotalSupply { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Transfer { - const METHOD_ID: [u8; 4] = [169u8, 5u8, 156u8, 187u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_to: values + } + impl substreams_ethereum::rpc::RPCDecodable for Transfer { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferFrom { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl TransferFrom { + const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + .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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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 - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_bool() + .expect(INTERNAL_ERR), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Transfer { - const NAME: &'static str = "transfer"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for TransferFrom { + const NAME: &'static str = "transferFrom"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for Transfer { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferFrom { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl TransferFrom { - const METHOD_ID: [u8; 4] = [35u8, 184u8, 114u8, 221u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_to)), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Bool], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_bool() - .expect(INTERNAL_ERR), + } + impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UserCheckpoint { + pub addr: Vec, + } + impl UserCheckpoint { + const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for UserCheckpoint { + const NAME: &'static str = "user_checkpoint"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for UserCheckpoint { + 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 TransferFrom { - const NAME: &'static str = "transferFrom"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Function for Version { + const NAME: &'static str = "version"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for TransferFrom { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct UserCheckpoint { - pub addr: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl UserCheckpoint { - const METHOD_ID: [u8; 4] = [75u8, 130u8, 0u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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 + } + impl substreams_ethereum::rpc::RPCDecodable for Version { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Withdraw1 { + pub u_value: substreams::scalar::BigInt, + } + impl Withdraw1 { + const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { + u_value: { + 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.addr))], - ); - let mut encoded = Vec::with_capacity(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 - } - } - } + .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.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for UserCheckpoint { - const NAME: &'static str = "user_checkpoint"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 UserCheckpoint { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Withdraw1 { + const NAME: &'static str = "withdraw1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[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( + 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 Withdraw2 { + pub u_value: substreams::scalar::BigInt, + pub u_claim_rewards: bool, + } + impl Withdraw2 { + const METHOD_ID: [u8; 4] = [56u8, 208u8, 116u8, 54u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Bool], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_value: { + let mut v = [0 as u8; 32]; 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 - } - } - } + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_claim_rewards: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_value.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bool(self.u_claim_rewards.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - 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() + pub fn 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 Version { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Withdraw2 { + const NAME: &'static str = "withdraw2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw1 { - pub u_value: substreams::scalar::BigInt, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl Withdraw1 { - const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 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 { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct WorkingBalances { + pub arg0: Vec, + } + impl WorkingBalances { + const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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::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 Withdraw1 { - const NAME: &'static str = "withdraw1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 WorkingBalances { + const NAME: &'static str = "working_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw2 { - pub u_value: substreams::scalar::BigInt, - pub u_claim_rewards: bool, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl Withdraw2 { - const METHOD_ID: [u8; 4] = [56u8, 208u8, 116u8, 54u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Bool], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_claim_rewards: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_value.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Bool(self.u_claim_rewards.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::rpc::RPCDecodable + for WorkingBalances { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct WorkingSupply {} + impl WorkingSupply { + const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 Withdraw2 { - const NAME: &'static str = "withdraw2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 WorkingSupply { + const NAME: &'static str = "working_supply"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingBalances { - pub arg0: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl WorkingBalances { - const METHOD_ID: [u8; 4] = [19u8, 236u8, 177u8, 202u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for WorkingSupply { + 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 ApplyOwnership { + pub admin: Vec, + } + impl ApplyOwnership { + const TOPIC_ID: [u8; 32] = [ + 235u8, + 238u8, + 45u8, + 87u8, + 57u8, + 1u8, + 16u8, + 98u8, + 203u8, + 79u8, + 20u8, + 17u8, + 63u8, + 59u8, + 54u8, + 191u8, + 15u8, + 254u8, + 61u8, + 165u8, + 192u8, + 86u8, + 143u8, + 100u8, + 24u8, + 157u8, + 16u8, + 18u8, + 161u8, + 24u8, + 145u8, + 5u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for ApplyOwnership { + const NAME: &'static str = "ApplyOwnership"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Approval { + pub u_owner: Vec, + pub u_spender: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Approval { + const TOPIC_ID: [u8; 32] = [ + 140u8, + 91u8, + 225u8, + 229u8, + 235u8, + 236u8, + 125u8, + 91u8, + 209u8, + 79u8, + 113u8, + 66u8, + 125u8, + 30u8, + 132u8, + 243u8, + 221u8, + 3u8, + 20u8, + 192u8, + 247u8, + 178u8, + 41u8, + 30u8, + 91u8, + 32u8, + 10u8, + 200u8, + 199u8, + 195u8, + 185u8, + 37u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_owner: ethabi::decode( &[ethabi::ParamType::Address], - maybe_data.unwrap(), + log.topics[1usize].as_ref(), ) - .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::Uint(256usize)], - data.as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_owner' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_spender: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'u_spender' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { 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 WorkingBalances { - const NAME: &'static str = "working_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::Event for Approval { + const NAME: &'static str = "Approval"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingBalances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct WorkingSupply {} - impl WorkingSupply { - const METHOD_ID: [u8; 4] = [23u8, 226u8, 128u8, 137u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitOwnership { + pub admin: Vec, + } + impl CommitOwnership { + const TOPIC_ID: [u8; 32] = [ + 47u8, + 86u8, + 129u8, + 10u8, + 107u8, + 244u8, + 10u8, + 240u8, + 89u8, + 185u8, + 109u8, + 58u8, + 234u8, + 77u8, + 181u8, + 64u8, + 129u8, + 243u8, + 120u8, + 2u8, + 154u8, + 81u8, + 131u8, + 144u8, + 73u8, + 16u8, + 147u8, + 167u8, + 182u8, + 112u8, + 50u8, + 233u8, + ]; + 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 { + admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for CommitOwnership { + const NAME: &'static str = "CommitOwnership"; + 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 Deposit { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Deposit { + const TOPIC_ID: [u8; 32] = [ + 225u8, + 255u8, + 252u8, + 196u8, + 146u8, + 61u8, + 4u8, + 181u8, + 89u8, + 244u8, + 210u8, + 154u8, + 139u8, + 252u8, + 108u8, + 218u8, + 4u8, + 235u8, + 91u8, + 13u8, + 60u8, + 70u8, + 7u8, + 81u8, + 194u8, + 64u8, + 44u8, + 92u8, + 92u8, + 201u8, + 16u8, + 156u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { 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 WorkingSupply { - const NAME: &'static str = "working_supply"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for WorkingSupply { - 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 ApplyOwnership { - pub admin: Vec, - } - impl ApplyOwnership { - const TOPIC_ID: [u8; 32] = [ - 235u8, - 238u8, - 45u8, - 87u8, - 57u8, - 1u8, - 16u8, - 98u8, - 203u8, - 79u8, - 20u8, - 17u8, - 63u8, - 59u8, - 54u8, - 191u8, - 15u8, - 254u8, - 61u8, - 165u8, - 192u8, - 86u8, - 143u8, - 100u8, - 24u8, - 157u8, - 16u8, - 18u8, - 161u8, - 24u8, - 145u8, - 5u8, - ]; - 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( + } + impl substreams_ethereum::Event for Deposit { + const NAME: &'static str = "Deposit"; + 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 SetGaugeManager { + pub u_gauge_manager: Vec, + } + impl SetGaugeManager { + const TOPIC_ID: [u8; 32] = [ + 232u8, + 60u8, + 128u8, + 160u8, + 52u8, + 145u8, + 80u8, + 153u8, + 28u8, + 176u8, + 155u8, + 76u8, + 148u8, + 1u8, + 73u8, + 172u8, + 76u8, + 55u8, + 203u8, + 3u8, + 103u8, + 59u8, + 108u8, + 12u8, + 102u8, + 155u8, + 77u8, + 162u8, + 120u8, + 101u8, + 194u8, + 139u8, + ]; + 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 { + u_gauge_manager: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for SetGaugeManager { + const NAME: &'static str = "SetGaugeManager"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub u_from: Vec, + pub u_to: Vec, + pub u_value: substreams::scalar::BigInt, + } + impl Transfer { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 242u8, + 82u8, + 173u8, + 27u8, + 226u8, + 200u8, + 155u8, + 105u8, + 194u8, + 176u8, + 104u8, + 252u8, + 55u8, + 141u8, + 170u8, + 149u8, + 43u8, + 167u8, + 241u8, + 99u8, + 196u8, + 161u8, + 22u8, + 40u8, + 245u8, + 90u8, + 77u8, + 245u8, + 35u8, + 179u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + u_from: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for ApplyOwnership { - const NAME: &'static str = "ApplyOwnership"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Approval { - pub u_owner: Vec, - pub u_spender: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Approval { - const TOPIC_ID: [u8; 32] = [ - 140u8, - 91u8, - 225u8, - 229u8, - 235u8, - 236u8, - 125u8, - 91u8, - 209u8, - 79u8, - 113u8, - 66u8, - 125u8, - 30u8, - 132u8, - 243u8, - 221u8, - 3u8, - 20u8, - 192u8, - 247u8, - 178u8, - 41u8, - 30u8, - 91u8, - 32u8, - 10u8, - 200u8, - 199u8, - 195u8, - 185u8, - 37u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_owner: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_owner' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_spender: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_from' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_spender' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Approval { - const NAME: &'static str = "Approval"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitOwnership { - pub admin: Vec, - } - impl CommitOwnership { - const TOPIC_ID: [u8; 32] = [ - 47u8, - 86u8, - 129u8, - 10u8, - 107u8, - 244u8, - 10u8, - 240u8, - 89u8, - 185u8, - 109u8, - 58u8, - 234u8, - 77u8, - 181u8, - 64u8, - 129u8, - 243u8, - 120u8, - 2u8, - 154u8, - 81u8, - 131u8, - 144u8, - 73u8, - 16u8, - 147u8, - 167u8, - 182u8, - 112u8, - 50u8, - 233u8, - ]; - 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( + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_to: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), + log.topics[2usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for CommitOwnership { - const NAME: &'static str = "CommitOwnership"; - 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 Deposit { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Deposit { - const TOPIC_ID: [u8; 32] = [ - 225u8, - 255u8, - 252u8, - 196u8, - 146u8, - 61u8, - 4u8, - 181u8, - 89u8, - 244u8, - 210u8, - 154u8, - 139u8, - 252u8, - 108u8, - 218u8, - 4u8, - 235u8, - 91u8, - 13u8, - 60u8, - 70u8, - 7u8, - 81u8, - 194u8, - 64u8, - 44u8, - 92u8, - 92u8, - 201u8, - 16u8, - 156u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'u_to' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Deposit { - const NAME: &'static str = "Deposit"; - 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 SetGaugeManager { - pub u_gauge_manager: Vec, - } - impl SetGaugeManager { - const TOPIC_ID: [u8; 32] = [ - 232u8, - 60u8, - 128u8, - 160u8, - 52u8, - 145u8, - 80u8, - 153u8, - 28u8, - 176u8, - 155u8, - 76u8, - 148u8, - 1u8, - 73u8, - 172u8, - 76u8, - 55u8, - 203u8, - 3u8, - 103u8, - 59u8, - 108u8, - 12u8, - 102u8, - 155u8, - 77u8, - 162u8, - 120u8, - 101u8, - 194u8, - 139u8, - ]; - 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( + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Transfer { + const NAME: &'static str = "Transfer"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateLiquidityLimit { + pub user: Vec, + pub original_balance: substreams::scalar::BigInt, + pub original_supply: substreams::scalar::BigInt, + pub working_balance: substreams::scalar::BigInt, + pub working_supply: substreams::scalar::BigInt, + } + impl UpdateLiquidityLimit { + const TOPIC_ID: [u8; 32] = [ + 126u8, + 205u8, + 132u8, + 52u8, + 63u8, + 118u8, + 162u8, + 61u8, + 34u8, + 39u8, + 41u8, + 14u8, + 2u8, + 136u8, + 218u8, + 50u8, + 81u8, + 176u8, + 69u8, + 84u8, + 22u8, + 152u8, + 229u8, + 117u8, + 165u8, + 81u8, + 90u8, + 244u8, + 240u8, + 65u8, + 151u8, + 163u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + user: ethabi::decode( &[ethabi::ParamType::Address], - log.data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_gauge_manager: values + .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(), + original_balance: { + 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 SetGaugeManager { - const NAME: &'static str = "SetGaugeManager"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Transfer { - pub u_from: Vec, - pub u_to: Vec, - pub u_value: substreams::scalar::BigInt, - } - impl Transfer { - const TOPIC_ID: [u8; 32] = [ - 221u8, - 242u8, - 82u8, - 173u8, - 27u8, - 226u8, - 200u8, - 155u8, - 105u8, - 194u8, - 176u8, - 104u8, - 252u8, - 55u8, - 141u8, - 170u8, - 149u8, - 43u8, - 167u8, - 241u8, - 99u8, - 196u8, - 161u8, - 22u8, - 40u8, - 245u8, - 90u8, - 77u8, - 245u8, - 35u8, - 179u8, - 239u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - u_from: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_from' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + original_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'u_to' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_balance: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for Transfer { - const NAME: &'static str = "Transfer"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UpdateLiquidityLimit { - pub user: Vec, - pub original_balance: substreams::scalar::BigInt, - pub original_supply: substreams::scalar::BigInt, - pub working_balance: substreams::scalar::BigInt, - pub working_supply: substreams::scalar::BigInt, - } - impl UpdateLiquidityLimit { - const TOPIC_ID: [u8; 32] = [ - 126u8, - 205u8, - 132u8, - 52u8, - 63u8, - 118u8, - 162u8, - 61u8, - 34u8, - 39u8, - 41u8, - 14u8, - 2u8, - 136u8, - 218u8, - 50u8, - 81u8, - 176u8, - 69u8, - 84u8, - 22u8, - 152u8, - 229u8, - 117u8, - 165u8, - 81u8, - 90u8, - 244u8, - 240u8, - 65u8, - 151u8, - 163u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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 - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + working_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - original_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - original_supply: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_balance: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - working_supply: { - let mut v = [0 as u8; 32]; - values - .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 UpdateLiquidityLimit { - const NAME: &'static str = "UpdateLiquidityLimit"; - 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 Withdraw { - pub provider: Vec, - pub value: substreams::scalar::BigInt, - } - impl Withdraw { - const TOPIC_ID: [u8; 32] = [ - 136u8, - 78u8, - 218u8, - 217u8, - 206u8, - 111u8, - 162u8, - 68u8, - 13u8, - 138u8, - 84u8, - 204u8, - 18u8, - 52u8, - 144u8, - 235u8, - 150u8, - 210u8, - 118u8, - 132u8, - 121u8, - 212u8, - 159u8, - 249u8, - 199u8, - 54u8, - 97u8, - 37u8, - 169u8, - 66u8, - 67u8, - 100u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for UpdateLiquidityLimit { + const NAME: &'static str = "UpdateLiquidityLimit"; + 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 Withdraw { + pub provider: Vec, + pub value: substreams::scalar::BigInt, + } + impl Withdraw { + const TOPIC_ID: [u8; 32] = [ + 136u8, + 78u8, + 218u8, + 217u8, + 206u8, + 111u8, + 162u8, + 68u8, + 13u8, + 138u8, + 84u8, + 204u8, + 18u8, + 52u8, + 144u8, + 235u8, + 150u8, + 210u8, + 118u8, + 132u8, + 121u8, + 212u8, + 159u8, + 249u8, + 199u8, + 54u8, + 97u8, + 37u8, + 169u8, + 66u8, + 67u8, + 100u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + value: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - value: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for Withdraw { - const NAME: &'static str = "Withdraw"; - 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 Withdraw { + const NAME: &'static str = "Withdraw"; + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/ownership_proxies/factory_owner.rs b/src/abi/curve/ownership_proxies/factory_owner.rs index 14f06b7..070dc15 100644 --- a/src/abi/curve/ownership_proxies/factory_owner.rs +++ b/src/abi/curve/ownership_proxies/factory_owner.rs @@ -1,2222 +1,2119 @@ - 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 { - pub u_target: Vec, - } - impl AcceptTransferOwnership { - const METHOD_ID: [u8; 4] = [168u8, 242u8, 44u8, 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 { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) +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 { + pub u_target: Vec, + } + impl AcceptTransferOwnership { + const METHOD_ID: [u8; 4] = [168u8, 242u8, 44u8, 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 { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_target))], + ); + 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 encode(&self) -> Vec { - let data = ethabi::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) + } + 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 u_target: Vec, + pub u_base_pool: Vec, + pub u_fee_receiver: Vec, + pub u_asset_type: substreams::scalar::BigInt, + pub u_implementations: [Vec; 10usize], + } + impl AddBasePool { + const METHOD_ID: [u8; 4] = [34u8, 174u8, 132u8, 163u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_target), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), ], - ); - 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 u_target: Vec, - pub u_base_pool: Vec, - pub u_fee_receiver: Vec, - pub u_asset_type: substreams::scalar::BigInt, - pub u_implementations: [Vec; 10usize], - } - impl AddBasePool { - const METHOD_ID: [u8; 4] = [34u8, 174u8, 132u8, 163u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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), - 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 { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_base_pool: values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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(), - u_fee_receiver: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementations: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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), - ] + .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.u_target)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_fee_receiver), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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 + .u_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, } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 AddReward { + pub u_gauge: Vec, + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl AddReward { + const METHOD_ID: [u8; 4] = [77u8, 202u8, 125u8, 240u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_target), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_fee_receiver), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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 - .u_implementations - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + 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() - } + } + impl substreams_ethereum::Function for AddReward { + const NAME: &'static str = "add_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AddReward { - pub u_gauge: Vec, - pub u_reward_token: Vec, - pub u_distributor: Vec, - } - impl AddReward { - const METHOD_ID: [u8; 4] = [77u8, 202u8, 125u8, 240u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + 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 ApplySetAdmins {} + impl ApplySetAdmins { + const METHOD_ID: [u8; 4] = [97u8, 137u8, 57u8, 33u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for ApplySetAdmins { + const NAME: &'static str = "apply_set_admins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 CommitSetAdmins { + pub u_o_admin: Vec, + pub u_p_admin: Vec, + pub u_e_admin: Vec, + } + impl CommitSetAdmins { + const METHOD_ID: [u8; 4] = [140u8, 177u8, 108u8, 138u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_o_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_p_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_e_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.u_o_admin)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_p_admin)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_e_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 AddReward { - const NAME: &'static str = "add_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 CommitSetAdmins { + const NAME: &'static str = "commit_set_admins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ApplySetAdmins {} - impl ApplySetAdmins { - const METHOD_ID: [u8; 4] = [97u8, 137u8, 57u8, 33u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + 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 u_target: Vec, + pub u_new_admin: Vec, + } + impl CommitTransferOwnership { + const METHOD_ID: [u8; 4] = [62u8, 161u8, 198u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_new_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.u_target)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_new_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, } - pub fn 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 EmergencyAdmin {} + impl EmergencyAdmin { + const METHOD_ID: [u8; 4] = [104u8, 12u8, 119u8, 131u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for ApplySetAdmins { - const NAME: &'static str = "apply_set_admins"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 EmergencyAdmin { + const NAME: &'static str = "emergency_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 EmergencyAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitSetAdmins { - pub u_o_admin: Vec, - pub u_p_admin: Vec, - pub u_e_admin: Vec, - } - impl CommitSetAdmins { - const METHOD_ID: [u8; 4] = [140u8, 177u8, 108u8, 138u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 FutureEmergencyAdmin {} + impl FutureEmergencyAdmin { + const METHOD_ID: [u8; 4] = [88u8, 102u8, 80u8, 122u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_o_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_p_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_e_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.u_o_admin), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_p_admin), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_e_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 FutureEmergencyAdmin { + const NAME: &'static str = "future_emergency_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 FutureEmergencyAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureOwnershipAdmin {} + impl FutureOwnershipAdmin { + const METHOD_ID: [u8; 4] = [60u8, 47u8, 203u8, 244u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for CommitSetAdmins { - const NAME: &'static str = "commit_set_admins"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + } + impl substreams_ethereum::Function for FutureOwnershipAdmin { + const NAME: &'static str = "future_ownership_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 FutureOwnershipAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureParameterAdmin {} + impl FutureParameterAdmin { + const METHOD_ID: [u8; 4] = [130u8, 75u8, 80u8, 133u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) + } + } + impl substreams_ethereum::Function for FutureParameterAdmin { + const NAME: &'static str = "future_parameter_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 FutureParameterAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeManager {} + impl GaugeManager { + const METHOD_ID: [u8; 4] = [234u8, 125u8, 123u8, 34u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } } - fn encode(&self) -> Vec { - self.encode() + } + } + impl substreams_ethereum::Function for GaugeManager { + const NAME: &'static str = "gauge_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 GaugeManager { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OwnershipAdmin {} + impl OwnershipAdmin { + const METHOD_ID: [u8; 4] = [71u8, 200u8, 113u8, 95u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 CommitTransferOwnership { - pub u_target: Vec, - pub u_new_admin: Vec, - } - impl CommitTransferOwnership { - const METHOD_ID: [u8; 4] = [62u8, 161u8, 198u8, 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()); + } + impl substreams_ethereum::Function for OwnershipAdmin { + const NAME: &'static str = "ownership_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 OwnershipAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ParameterAdmin {} + impl ParameterAdmin { + const METHOD_ID: [u8; 4] = [165u8, 176u8, 183u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_target: values + } + } + } + impl substreams_ethereum::Function for ParameterAdmin { + const NAME: &'static str = "parameter_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 ParameterAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RampA { + pub u_pool: Vec, + pub u_future_a: substreams::scalar::BigInt, + pub u_future_time: substreams::scalar::BigInt, + } + impl RampA { + const METHOD_ID: [u8; 4] = [157u8, 74u8, 67u8, 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), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_future_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_admin: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_future_time: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_target), + .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.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_future_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::Address( - ethabi::Address::from_slice(&self.u_new_admin), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_future_time.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - 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() + pub fn 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 EmergencyAdmin {} - impl EmergencyAdmin { - const METHOD_ID: [u8; 4] = [104u8, 12u8, 119u8, 131u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::Function for RampA { + const NAME: &'static str = "ramp_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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFactoryManager { + pub u_target: Vec, + pub u_manager: Vec, + } + impl SetFactoryManager { + const METHOD_ID: [u8; 4] = [217u8, 31u8, 24u8, 248u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_target)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + impl substreams_ethereum::Function for SetFactoryManager { + const NAME: &'static str = "set_factory_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 SetFeeReceiver { + pub u_target: Vec, + pub u_base_pool: Vec, + pub u_fee_receiver: Vec, + } + impl SetFeeReceiver { + const METHOD_ID: [u8; 4] = [168u8, 223u8, 233u8, 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::Address, + ethabi::ParamType::Address, ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_target)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_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 EmergencyAdmin { - const NAME: &'static str = "emergency_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::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 substreams_ethereum::rpc::RPCDecodable> for EmergencyAdmin { - 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 FutureEmergencyAdmin {} - impl FutureEmergencyAdmin { - const METHOD_ID: [u8; 4] = [88u8, 102u8, 80u8, 122u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeImplementation { + pub u_target: Vec, + pub u_gauge_implementation: Vec, + } + impl SetGaugeImplementation { + const METHOD_ID: [u8; 4] = [56u8, 203u8, 235u8, 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, ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_target)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_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 FutureEmergencyAdmin { - const NAME: &'static str = "future_emergency_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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for FutureEmergencyAdmin { - 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 FutureOwnershipAdmin {} - impl FutureOwnershipAdmin { - const METHOD_ID: [u8; 4] = [60u8, 47u8, 203u8, 244u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeManager { + pub u_manager: Vec, + } + impl SetGaugeManager { + const METHOD_ID: [u8; 4] = [170u8, 206u8, 29u8, 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::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 FutureOwnershipAdmin { - const NAME: &'static str = "future_ownership_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::Function for SetGaugeManager { + const NAME: &'static str = "set_gauge_manager"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FutureOwnershipAdmin { - 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 FutureParameterAdmin {} - impl FutureParameterAdmin { - const METHOD_ID: [u8; 4] = [130u8, 75u8, 80u8, 133u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for FutureParameterAdmin { - const NAME: &'static str = "future_parameter_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 FutureParameterAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeManager {} - impl GaugeManager { - const METHOD_ID: [u8; 4] = [234u8, 125u8, 123u8, 34u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetKilled { + pub u_gauge: Vec, + pub u_is_killed: bool, + } + impl SetKilled { + const METHOD_ID: [u8; 4] = [67u8, 68u8, 206u8, 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, ethabi::ParamType::Bool], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for GaugeManager { - const NAME: &'static str = "gauge_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 GaugeManager { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_is_killed: 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.u_gauge)), + ethabi::Token::Bool(self.u_is_killed.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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct OwnershipAdmin {} - impl OwnershipAdmin { - const METHOD_ID: [u8; 4] = [71u8, 200u8, 113u8, 95u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + } + impl substreams_ethereum::Function for SetKilled { + const NAME: &'static str = "set_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for OwnershipAdmin { - const NAME: &'static str = "ownership_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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable> for OwnershipAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct ParameterAdmin {} - impl ParameterAdmin { - const METHOD_ID: [u8; 4] = [165u8, 176u8, 183u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetMetapoolImplementations { + pub u_target: Vec, + pub u_base_pool: Vec, + pub u_implementations: [Vec; 10usize], + } + impl SetMetapoolImplementations { + const METHOD_ID: [u8; 4] = [179u8, 4u8, 67u8, 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::Address, + 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 { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_implementations: { + let mut iter = values .pop() - .expect("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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_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.u_target)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + { + let v = self + .u_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 } - impl substreams_ethereum::Function for ParameterAdmin { - const NAME: &'static str = "parameter_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() + pub fn 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 ParameterAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct RampA { - pub u_pool: Vec, - pub u_future_a: substreams::scalar::BigInt, - pub u_future_time: substreams::scalar::BigInt, - } - impl RampA { - const METHOD_ID: [u8; 4] = [157u8, 74u8, 67u8, 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), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_future_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) - }, - u_future_time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_future_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.u_future_time.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for RampA { - const NAME: &'static str = "ramp_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() - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct SetFactoryManager { - pub u_target: Vec, - pub u_manager: Vec, - } - impl SetFactoryManager { - const METHOD_ID: [u8; 4] = [217u8, 31u8, 24u8, 248u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_manager: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetPlainImplementations { + pub u_target: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_implementations: [Vec; 10usize], + } + impl SetPlainImplementations { + const METHOD_ID: [u8; 4] = [247u8, 222u8, 27u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_target), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_manager), + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), ], - ); - 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 SetFactoryManager { - const NAME: &'static str = "set_factory_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 SetFeeReceiver { - pub u_target: Vec, - pub u_base_pool: Vec, - pub u_fee_receiver: Vec, - } - impl SetFeeReceiver { - const METHOD_ID: [u8; 4] = [168u8, 223u8, 233u8, 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::Address, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_base_pool: values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_fee_receiver: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementations: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_target), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_fee_receiver), + .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.u_target)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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, - } - } + ), + { + let v = self + .u_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 } - 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() + pub fn 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 SetGaugeImplementation { - pub u_target: Vec, - pub u_gauge_implementation: Vec, - } - impl SetGaugeImplementation { - const METHOD_ID: [u8; 4] = [56u8, 203u8, 235u8, 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, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_target), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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 SetPlainImplementations { + const NAME: &'static str = "set_plain_implementations"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetGaugeManager { - pub u_manager: Vec, - } - impl SetGaugeManager { - const METHOD_ID: [u8; 4] = [170u8, 206u8, 29u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_manager: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetRewardDistributor { + pub u_gauge: Vec, + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl SetRewardDistributor { + const METHOD_ID: [u8; 4] = [200u8, 23u8, 80u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_manager), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + 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 SetGaugeManager { - const NAME: &'static str = "set_gauge_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::Function for SetRewardDistributor { + const NAME: &'static str = "set_reward_distributor"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetKilled { - pub u_gauge: Vec, - pub u_is_killed: bool, - } - impl SetKilled { - const METHOD_ID: [u8; 4] = [67u8, 68u8, 206u8, 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, ethabi::ParamType::Bool], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_is_killed: 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.u_gauge), - ), - ethabi::Token::Bool(self.u_is_killed.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 decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for SetKilled { - const NAME: &'static str = "set_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetMetapoolImplementations { - pub u_target: Vec, - pub u_base_pool: Vec, - pub u_implementations: [Vec; 10usize], - } - impl SetMetapoolImplementations { - const METHOD_ID: [u8; 4] = [179u8, 4u8, 67u8, 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::Address, - 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 { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_target), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - { - let v = self - .u_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, - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct StopRampA { + pub u_pool: Vec, + } + impl StopRampA { + const METHOD_ID: [u8; 4] = [83u8, 247u8, 155u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_pool))], + ); + 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() - } + } + impl substreams_ethereum::Function for StopRampA { + const NAME: &'static str = "stop_ramp_A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetPlainImplementations { - pub u_target: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_implementations: [Vec; 10usize], - } - impl SetPlainImplementations { - const METHOD_ID: [u8; 4] = [247u8, 222u8, 27u8, 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), - 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 { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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.u_target), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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 - .u_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, - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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() - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct SetRewardDistributor { - pub u_gauge: Vec, - pub u_reward_token: Vec, - pub u_distributor: Vec, - } - impl SetRewardDistributor { - const METHOD_ID: [u8; 4] = [200u8, 23u8, 80u8, 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::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct ApplyAdmins { + pub ownership_admin: Vec, + pub parameter_admin: Vec, + pub emergency_admin: Vec, + } + impl ApplyAdmins { + const TOPIC_ID: [u8; 32] = [ + 214u8, + 26u8, + 22u8, + 145u8, + 46u8, + 251u8, + 154u8, + 28u8, + 91u8, + 213u8, + 54u8, + 29u8, + 255u8, + 35u8, + 139u8, + 149u8, + 244u8, + 82u8, + 103u8, + 45u8, + 237u8, + 117u8, + 26u8, + 66u8, + 92u8, + 17u8, + 219u8, + 94u8, + 79u8, + 88u8, + 129u8, + 118u8, + ]; + 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::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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 SetRewardDistributor { - const NAME: &'static str = "set_reward_distributor"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + ownership_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + parameter_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + emergency_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - #[derive(Debug, Clone, PartialEq)] - pub struct StopRampA { - pub u_pool: Vec, - } - impl StopRampA { - const METHOD_ID: [u8; 4] = [83u8, 247u8, 155u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_pool))], - ); - 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 ApplyAdmins { + const NAME: &'static str = "ApplyAdmins"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::Function for StopRampA { - const NAME: &'static str = "stop_ramp_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() - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct ApplyAdmins { - pub ownership_admin: Vec, - pub parameter_admin: Vec, - pub emergency_admin: Vec, - } - impl ApplyAdmins { - const TOPIC_ID: [u8; 32] = [ - 214u8, - 26u8, - 22u8, - 145u8, - 46u8, - 251u8, - 154u8, - 28u8, - 91u8, - 213u8, - 54u8, - 29u8, - 255u8, - 35u8, - 139u8, - 149u8, - 244u8, - 82u8, - 103u8, - 45u8, - 237u8, - 117u8, - 26u8, - 66u8, - 92u8, - 17u8, - 219u8, - 94u8, - 79u8, - 88u8, - 129u8, - 118u8, - ]; - 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 { - ownership_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - parameter_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - emergency_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for ApplyAdmins { - const NAME: &'static str = "ApplyAdmins"; - 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 CommitAdmins { + pub ownership_admin: Vec, + pub parameter_admin: Vec, + pub emergency_admin: Vec, + } + impl CommitAdmins { + const TOPIC_ID: [u8; 32] = [ + 120u8, + 87u8, + 33u8, + 49u8, + 253u8, + 139u8, + 154u8, + 46u8, + 52u8, + 92u8, + 72u8, + 166u8, + 175u8, + 191u8, + 85u8, + 188u8, + 18u8, + 25u8, + 227u8, + 147u8, + 85u8, + 63u8, + 234u8, + 198u8, + 148u8, + 248u8, + 152u8, + 137u8, + 144u8, + 61u8, + 39u8, + 4u8, + ]; + 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 { + ownership_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + parameter_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + emergency_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitAdmins { - pub ownership_admin: Vec, - pub parameter_admin: Vec, - pub emergency_admin: Vec, - } - impl CommitAdmins { - const TOPIC_ID: [u8; 32] = [ - 120u8, - 87u8, - 33u8, - 49u8, - 253u8, - 139u8, - 154u8, - 46u8, - 52u8, - 92u8, - 72u8, - 166u8, - 175u8, - 191u8, - 85u8, - 188u8, - 18u8, - 25u8, - 227u8, - 147u8, - 85u8, - 63u8, - 234u8, - 198u8, - 148u8, - 248u8, - 152u8, - 137u8, - 144u8, - 61u8, - 39u8, - 4u8, - ]; - 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 { - ownership_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - parameter_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - emergency_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + } + impl substreams_ethereum::Event for CommitAdmins { + const NAME: &'static str = "CommitAdmins"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::Event for CommitAdmins { - const NAME: &'static str = "CommitAdmins"; - 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) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/abi/curve/ownership_proxies/gauge_manager.rs b/src/abi/curve/ownership_proxies/gauge_manager.rs index 5d6e481..3bb305a 100644 --- a/src/abi/curve/ownership_proxies/gauge_manager.rs +++ b/src/abi/curve/ownership_proxies/gauge_manager.rs @@ -1,1124 +1,1066 @@ - 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 AddReward { - pub u_gauge: Vec, - pub u_reward_token: Vec, - pub u_distributor: Vec, - } - impl AddReward { - const METHOD_ID: [u8; 4] = [77u8, 202u8, 125u8, 240u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 AddReward { + pub u_gauge: Vec, + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl AddReward { + const METHOD_ID: [u8; 4] = [77u8, 202u8, 125u8, 240u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for AddReward { - const NAME: &'static str = "add_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge1 { - pub u_pool: Vec, - } - impl DeployGauge1 { - 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 { - u_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.u_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 match_call(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(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + } + impl substreams_ethereum::Function for AddReward { + const NAME: &'static str = "add_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 DeployGauge1 { + pub u_pool: Vec, + } + impl DeployGauge1 { + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for DeployGauge1 { - const NAME: &'static str = "deploy_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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 DeployGauge2 { - pub u_pool: Vec, - pub u_gauge_manager: Vec, - } - impl DeployGauge2 { - const METHOD_ID: [u8; 4] = [151u8, 249u8, 230u8, 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()); + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_gauge_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.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge_manager), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + } + impl substreams_ethereum::Function for DeployGauge1 { + const NAME: &'static str = "deploy_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 DeployGauge1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployGauge2 { + pub u_pool: Vec, + pub u_gauge_manager: Vec, + } + impl DeployGauge2 { + const METHOD_ID: [u8; 4] = [151u8, 249u8, 230u8, 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::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_gauge_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.u_pool)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_gauge_manager), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 DeployGauge2 { - const NAME: &'static str = "deploy_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::Function for DeployGauge2 { + const NAME: &'static str = "deploy_gauge2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge2 { - 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 Factory {} - impl Factory { - const METHOD_ID: [u8; 4] = [196u8, 90u8, 1u8, 85u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Factory {} + impl Factory { + const METHOD_ID: [u8; 4] = [196u8, 90u8, 1u8, 85u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(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; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + } + impl substreams_ethereum::Function for Factory { + const NAME: &'static str = "factory"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Factory { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeManager { + pub arg0: Vec, + } + impl GaugeManager { + const METHOD_ID: [u8; 4] = [11u8, 188u8, 54u8, 206u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 Factory { - const NAME: &'static str = "factory"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GaugeManager { + const NAME: &'static str = "gauge_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 GaugeManager { + fn output(data: &[u8]) -> Result, String> { + 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 } - impl substreams_ethereum::rpc::RPCDecodable> for Factory { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 GaugeManager { - pub arg0: Vec, - } - impl GaugeManager { - const METHOD_ID: [u8; 4] = [11u8, 188u8, 54u8, 206u8]; - pub fn decode( - call: &substreams_ethereum::pb::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::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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn 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 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 OwnerProxy {} + impl OwnerProxy { + const METHOD_ID: [u8; 4] = [203u8, 2u8, 62u8, 109u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 GaugeManager { - const NAME: &'static str = "gauge_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::Function for OwnerProxy { + const NAME: &'static str = "owner_proxy"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeManager { - 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 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(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for OwnerProxy { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeManager { + pub u_gauge: Vec, + pub u_gauge_manager: Vec, + } + impl SetGaugeManager { + const METHOD_ID: [u8; 4] = [193u8, 240u8, 79u8, 118u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_gauge_manager: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - 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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_gauge_manager), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for Manager { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn 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 OwnerProxy {} - impl OwnerProxy { - const METHOD_ID: [u8; 4] = [203u8, 2u8, 62u8, 109u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::Function for SetGaugeManager { + const NAME: &'static str = "set_gauge_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 SetManager { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_manager: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for OwnerProxy { - const NAME: &'static str = "owner_proxy"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address(ethabi::Address::from_slice(&self.u_manager))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for OwnerProxy { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn 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 SetGaugeManager { - pub u_gauge: Vec, - pub u_gauge_manager: Vec, - } - impl SetGaugeManager { - const METHOD_ID: [u8; 4] = [193u8, 240u8, 79u8, 118u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_gauge_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.u_gauge), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge_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) } - impl substreams_ethereum::Function for SetGaugeManager { - const NAME: &'static str = "set_gauge_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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetManager { - pub u_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 { - u_manager: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetRewardDistributor { + pub u_gauge: Vec, + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl SetRewardDistributor { + const METHOD_ID: [u8; 4] = [200u8, 23u8, 80u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_manager), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - 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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - #[derive(Debug, Clone, PartialEq)] - pub struct SetRewardDistributor { - pub u_gauge: Vec, - pub u_reward_token: Vec, - pub u_distributor: Vec, - } - impl SetRewardDistributor { - const METHOD_ID: [u8; 4] = [200u8, 23u8, 80u8, 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::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), - ], - ); - 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 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 SetRewardDistributor { - const NAME: &'static str = "set_reward_distributor"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 SetRewardDistributor { + const NAME: &'static str = "set_reward_distributor"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetGaugeManager { - pub u_gauge: Vec, - pub u_gauge_manager: Vec, - } - impl SetGaugeManager { - const TOPIC_ID: [u8; 32] = [ - 112u8, - 209u8, - 222u8, - 126u8, - 57u8, - 177u8, - 61u8, - 109u8, - 251u8, - 51u8, - 79u8, - 36u8, - 71u8, - 186u8, - 212u8, - 31u8, - 251u8, - 98u8, - 189u8, - 181u8, - 106u8, - 34u8, - 88u8, - 4u8, - 168u8, - 224u8, - 226u8, - 221u8, - 165u8, - 198u8, - 111u8, - 153u8, - ]; - 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 { - u_gauge: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeManager { + pub u_gauge: Vec, + pub u_gauge_manager: Vec, + } + impl SetGaugeManager { + const TOPIC_ID: [u8; 32] = [ + 112u8, + 209u8, + 222u8, + 126u8, + 57u8, + 177u8, + 61u8, + 109u8, + 251u8, + 51u8, + 79u8, + 36u8, + 71u8, + 186u8, + 212u8, + 31u8, + 251u8, + 98u8, + 189u8, + 181u8, + 106u8, + 34u8, + 88u8, + 4u8, + 168u8, + 224u8, + 226u8, + 221u8, + 165u8, + 198u8, + 111u8, + 153u8, + ]; + 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 { + u_gauge: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'u_gauge' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_gauge' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_gauge_manager: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_gauge_manager: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'u_gauge_manager' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_gauge_manager' 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 SetGaugeManager { - const NAME: &'static str = "SetGaugeManager"; - 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 SetGaugeManager { + const NAME: &'static str = "SetGaugeManager"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetManager { - pub u_manager: Vec, - } - impl SetManager { - const TOPIC_ID: [u8; 32] = [ - 84u8, - 166u8, - 56u8, - 90u8, - 160u8, - 41u8, - 43u8, - 4u8, - 225u8, - 239u8, - 133u8, - 19u8, - 37u8, - 60u8, - 23u8, - 209u8, - 134u8, - 63u8, - 124u8, - 223u8, - 200u8, - 112u8, - 41u8, - 215u8, - 127u8, - 213u8, - 92u8, - 196u8, - 194u8, - 231u8, - 23u8, - 226u8, - ]; - 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 { - u_manager: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetManager { + pub u_manager: Vec, + } + impl SetManager { + const TOPIC_ID: [u8; 32] = [ + 84u8, + 166u8, + 56u8, + 90u8, + 160u8, + 41u8, + 43u8, + 4u8, + 225u8, + 239u8, + 133u8, + 19u8, + 37u8, + 60u8, + 23u8, + 209u8, + 134u8, + 63u8, + 124u8, + 223u8, + 200u8, + 112u8, + 41u8, + 215u8, + 127u8, + 213u8, + 92u8, + 196u8, + 194u8, + 231u8, + 23u8, + 226u8, + ]; + 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 { + u_manager: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'u_manager' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_manager' 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 SetManager { - const NAME: &'static str = "SetManager"; - 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 SetManager { + const NAME: &'static str = "SetManager"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/abi/curve/ownership_proxies/gauge_manager_old.rs b/src/abi/curve/ownership_proxies/gauge_manager_old.rs index 5d6e481..3bb305a 100644 --- a/src/abi/curve/ownership_proxies/gauge_manager_old.rs +++ b/src/abi/curve/ownership_proxies/gauge_manager_old.rs @@ -1,1124 +1,1066 @@ - 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 AddReward { - pub u_gauge: Vec, - pub u_reward_token: Vec, - pub u_distributor: Vec, - } - impl AddReward { - const METHOD_ID: [u8; 4] = [77u8, 202u8, 125u8, 240u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::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 AddReward { + pub u_gauge: Vec, + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl AddReward { + const METHOD_ID: [u8; 4] = [77u8, 202u8, 125u8, 240u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for AddReward { - const NAME: &'static str = "add_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge1 { - pub u_pool: Vec, - } - impl DeployGauge1 { - 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 { - u_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.u_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 match_call(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(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + } + impl substreams_ethereum::Function for AddReward { + const NAME: &'static str = "add_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 DeployGauge1 { + pub u_pool: Vec, + } + impl DeployGauge1 { + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for DeployGauge1 { - const NAME: &'static str = "deploy_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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 DeployGauge2 { - pub u_pool: Vec, - pub u_gauge_manager: Vec, - } - impl DeployGauge2 { - const METHOD_ID: [u8; 4] = [151u8, 249u8, 230u8, 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()); + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_gauge_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.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge_manager), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + } + impl substreams_ethereum::Function for DeployGauge1 { + const NAME: &'static str = "deploy_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 DeployGauge1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployGauge2 { + pub u_pool: Vec, + pub u_gauge_manager: Vec, + } + impl DeployGauge2 { + const METHOD_ID: [u8; 4] = [151u8, 249u8, 230u8, 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::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_gauge_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.u_pool)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_gauge_manager), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 DeployGauge2 { - const NAME: &'static str = "deploy_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::Function for DeployGauge2 { + const NAME: &'static str = "deploy_gauge2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge2 { - 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 Factory {} - impl Factory { - const METHOD_ID: [u8; 4] = [196u8, 90u8, 1u8, 85u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Factory {} + impl Factory { + const METHOD_ID: [u8; 4] = [196u8, 90u8, 1u8, 85u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(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; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + } + impl substreams_ethereum::Function for Factory { + const NAME: &'static str = "factory"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Factory { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeManager { + pub arg0: Vec, + } + impl GaugeManager { + const METHOD_ID: [u8; 4] = [11u8, 188u8, 54u8, 206u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 Factory { - const NAME: &'static str = "factory"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GaugeManager { + const NAME: &'static str = "gauge_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 GaugeManager { + fn output(data: &[u8]) -> Result, String> { + 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 } - impl substreams_ethereum::rpc::RPCDecodable> for Factory { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 GaugeManager { - pub arg0: Vec, - } - impl GaugeManager { - const METHOD_ID: [u8; 4] = [11u8, 188u8, 54u8, 206u8]; - pub fn decode( - call: &substreams_ethereum::pb::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::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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn 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 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 OwnerProxy {} + impl OwnerProxy { + const METHOD_ID: [u8; 4] = [203u8, 2u8, 62u8, 109u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 GaugeManager { - const NAME: &'static str = "gauge_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::Function for OwnerProxy { + const NAME: &'static str = "owner_proxy"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeManager { - 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 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(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for OwnerProxy { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeManager { + pub u_gauge: Vec, + pub u_gauge_manager: Vec, + } + impl SetGaugeManager { + const METHOD_ID: [u8; 4] = [193u8, 240u8, 79u8, 118u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_gauge_manager: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - 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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_gauge_manager), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for Manager { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn 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 OwnerProxy {} - impl OwnerProxy { - const METHOD_ID: [u8; 4] = [203u8, 2u8, 62u8, 109u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::Function for SetGaugeManager { + const NAME: &'static str = "set_gauge_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 SetManager { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_manager: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for OwnerProxy { - const NAME: &'static str = "owner_proxy"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address(ethabi::Address::from_slice(&self.u_manager))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for OwnerProxy { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn 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 SetGaugeManager { - pub u_gauge: Vec, - pub u_gauge_manager: Vec, - } - impl SetGaugeManager { - const METHOD_ID: [u8; 4] = [193u8, 240u8, 79u8, 118u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_gauge_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.u_gauge), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge_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) } - impl substreams_ethereum::Function for SetGaugeManager { - const NAME: &'static str = "set_gauge_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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetManager { - pub u_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 { - u_manager: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetRewardDistributor { + pub u_gauge: Vec, + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl SetRewardDistributor { + const METHOD_ID: [u8; 4] = [200u8, 23u8, 80u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_manager), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - 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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - #[derive(Debug, Clone, PartialEq)] - pub struct SetRewardDistributor { - pub u_gauge: Vec, - pub u_reward_token: Vec, - pub u_distributor: Vec, - } - impl SetRewardDistributor { - const METHOD_ID: [u8; 4] = [200u8, 23u8, 80u8, 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::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), - ], - ); - 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 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 SetRewardDistributor { - const NAME: &'static str = "set_reward_distributor"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 SetRewardDistributor { + const NAME: &'static str = "set_reward_distributor"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetGaugeManager { - pub u_gauge: Vec, - pub u_gauge_manager: Vec, - } - impl SetGaugeManager { - const TOPIC_ID: [u8; 32] = [ - 112u8, - 209u8, - 222u8, - 126u8, - 57u8, - 177u8, - 61u8, - 109u8, - 251u8, - 51u8, - 79u8, - 36u8, - 71u8, - 186u8, - 212u8, - 31u8, - 251u8, - 98u8, - 189u8, - 181u8, - 106u8, - 34u8, - 88u8, - 4u8, - 168u8, - 224u8, - 226u8, - 221u8, - 165u8, - 198u8, - 111u8, - 153u8, - ]; - 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 { - u_gauge: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeManager { + pub u_gauge: Vec, + pub u_gauge_manager: Vec, + } + impl SetGaugeManager { + const TOPIC_ID: [u8; 32] = [ + 112u8, + 209u8, + 222u8, + 126u8, + 57u8, + 177u8, + 61u8, + 109u8, + 251u8, + 51u8, + 79u8, + 36u8, + 71u8, + 186u8, + 212u8, + 31u8, + 251u8, + 98u8, + 189u8, + 181u8, + 106u8, + 34u8, + 88u8, + 4u8, + 168u8, + 224u8, + 226u8, + 221u8, + 165u8, + 198u8, + 111u8, + 153u8, + ]; + 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 { + u_gauge: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'u_gauge' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_gauge' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_gauge_manager: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_gauge_manager: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'u_gauge_manager' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_gauge_manager' 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 SetGaugeManager { - const NAME: &'static str = "SetGaugeManager"; - 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 SetGaugeManager { + const NAME: &'static str = "SetGaugeManager"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetManager { - pub u_manager: Vec, - } - impl SetManager { - const TOPIC_ID: [u8; 32] = [ - 84u8, - 166u8, - 56u8, - 90u8, - 160u8, - 41u8, - 43u8, - 4u8, - 225u8, - 239u8, - 133u8, - 19u8, - 37u8, - 60u8, - 23u8, - 209u8, - 134u8, - 63u8, - 124u8, - 223u8, - 200u8, - 112u8, - 41u8, - 215u8, - 127u8, - 213u8, - 92u8, - 196u8, - 194u8, - 231u8, - 23u8, - 226u8, - ]; - 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 { - u_manager: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetManager { + pub u_manager: Vec, + } + impl SetManager { + const TOPIC_ID: [u8; 32] = [ + 84u8, + 166u8, + 56u8, + 90u8, + 160u8, + 41u8, + 43u8, + 4u8, + 225u8, + 239u8, + 133u8, + 19u8, + 37u8, + 60u8, + 23u8, + 209u8, + 134u8, + 63u8, + 124u8, + 223u8, + 200u8, + 112u8, + 41u8, + 215u8, + 127u8, + 213u8, + 92u8, + 196u8, + 194u8, + 231u8, + 23u8, + 226u8, + ]; + 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 { + u_manager: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'u_manager' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'u_manager' 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 SetManager { - const NAME: &'static str = "SetManager"; - 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 SetManager { + const NAME: &'static str = "SetManager"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/abi/curve/ownership_proxies/stableswap_owner.rs b/src/abi/curve/ownership_proxies/stableswap_owner.rs index d6375b5..f679552 100644 --- a/src/abi/curve/ownership_proxies/stableswap_owner.rs +++ b/src/abi/curve/ownership_proxies/stableswap_owner.rs @@ -1,3924 +1,3741 @@ - 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 Factory {} - impl Factory { - const METHOD_ID: [u8; 4] = [45u8, 211u8, 16u8, 0u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn 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 Factory {} + impl Factory { + const METHOD_ID: [u8; 4] = [45u8, 211u8, 16u8, 0u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 Factory { + const NAME: &'static str = "FACTORY"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Factory { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OldManagerProxy {} + impl OldManagerProxy { + const METHOD_ID: [u8; 4] = [216u8, 50u8, 56u8, 10u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for Factory { - const NAME: &'static str = "FACTORY"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable> for Factory { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct OldManagerProxy {} - impl OldManagerProxy { - const METHOD_ID: [u8; 4] = [216u8, 50u8, 56u8, 10u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::Function for OldManagerProxy { + const NAME: &'static str = "OLD_MANAGER_PROXY"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for OldManagerProxy { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AcceptTransferOwnership { + pub u_target: Vec, + } + impl AcceptTransferOwnership { + const METHOD_ID: [u8; 4] = [168u8, 242u8, 44u8, 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_target))], + ); + 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 OldManagerProxy { - const NAME: &'static str = "OLD_MANAGER_PROXY"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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) } - impl substreams_ethereum::rpc::RPCDecodable> for OldManagerProxy { - 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 AcceptTransferOwnership { - pub u_target: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl AcceptTransferOwnership { - const METHOD_ID: [u8; 4] = [168u8, 242u8, 44u8, 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 { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddBasePool { + pub u_target: Vec, + pub u_base_pool: Vec, + pub u_fee_receiver: Vec, + pub u_asset_type: substreams::scalar::BigInt, + pub u_implementations: [Vec; 10usize], + } + impl AddBasePool { + const METHOD_ID: [u8; 4] = [34u8, 174u8, 132u8, 163u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_target), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), ], - ); - 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 u_target: Vec, - pub u_base_pool: Vec, - pub u_fee_receiver: Vec, - pub u_asset_type: substreams::scalar::BigInt, - pub u_implementations: [Vec; 10usize], - } - impl AddBasePool { - const METHOD_ID: [u8; 4] = [34u8, 174u8, 132u8, 163u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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), - 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 { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_fee_receiver: values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_asset_type: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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), - ] + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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.u_target)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_fee_receiver), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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 + .u_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, } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 AddReward { + pub u_gauge: Vec, + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl AddReward { + const METHOD_ID: [u8; 4] = [77u8, 202u8, 125u8, 240u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_target), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_fee_receiver), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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 - .u_implementations - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + 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) + } + impl substreams_ethereum::Function for AddReward { + const NAME: &'static str = "add_reward"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ApplyNewFee { + pub u_pool: Vec, + } + impl ApplyNewFee { + const METHOD_ID: [u8; 4] = [232u8, 214u8, 77u8, 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 { + u_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.u_pool))], + ); + 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 ApplyNewFee { + const NAME: &'static str = "apply_new_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ApplySetAdmins {} + impl ApplySetAdmins { + const METHOD_ID: [u8; 4] = [97u8, 137u8, 57u8, 33u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct AddReward { - pub u_gauge: Vec, - pub u_reward_token: Vec, - pub u_distributor: Vec, + } + impl substreams_ethereum::Function for ApplySetAdmins { + const NAME: &'static str = "apply_set_admins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl AddReward { - const METHOD_ID: [u8; 4] = [77u8, 202u8, 125u8, 240u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values + 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 CommitNewFee { + pub u_pool: Vec, + pub u_new_fee: substreams::scalar::BigInt, + } + impl CommitNewFee { + const METHOD_ID: [u8; 4] = [27u8, 22u8, 147u8, 117u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_new_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .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) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_new_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 match_call(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( + } + } + impl substreams_ethereum::Function for CommitNewFee { + const NAME: &'static str = "commit_new_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 CommitSetAdmins { + pub u_o_admin: Vec, + pub u_p_admin: Vec, + pub u_e_admin: Vec, + } + impl CommitSetAdmins { + const METHOD_ID: [u8; 4] = [140u8, 177u8, 108u8, 138u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_o_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_p_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_e_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.u_o_admin)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_p_admin)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_e_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 AddReward { - const NAME: &'static str = "add_reward"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 CommitSetAdmins { + const NAME: &'static str = "commit_set_admins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 u_target: Vec, + pub u_new_admin: Vec, + } + impl CommitTransferOwnership { + const METHOD_ID: [u8; 4] = [62u8, 161u8, 198u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_new_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.u_target)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_new_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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct ApplyNewFee { - pub u_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 ApplyNewFee { - const METHOD_ID: [u8; 4] = [232u8, 214u8, 77u8, 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 { - u_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.u_pool))], - ); - 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) + } + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployGauge1 { + pub u_pool: Vec, + } + impl DeployGauge1 { + 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 { + u_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.u_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 ApplyNewFee { - const NAME: &'static str = "apply_new_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ApplySetAdmins {} - impl ApplySetAdmins { - const METHOD_ID: [u8; 4] = [97u8, 137u8, 57u8, 33u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 DeployGauge1 { + const NAME: &'static str = "deploy_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 DeployGauge1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployGauge2 { + pub u_pool: Vec, + pub u_manager: Vec, + } + impl DeployGauge2 { + const METHOD_ID: [u8; 4] = [151u8, 249u8, 230u8, 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::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_manager)), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for ApplySetAdmins { - const NAME: &'static str = "apply_set_admins"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 DeployGauge2 { + const NAME: &'static str = "deploy_gauge2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitNewFee { - pub u_pool: Vec, - pub u_new_fee: substreams::scalar::BigInt, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl CommitNewFee { - const METHOD_ID: [u8; 4] = [27u8, 22u8, 147u8, 117u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_pool: values + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool1 { + pub u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_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), + ] + }, + u_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + let mut v = [0 as u8; 32]; + values + .pop() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_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) + .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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_coins + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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.u_new_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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, + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for CommitNewFee { - const NAME: &'static str = "commit_new_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 DeployPlainPool1 { + const NAME: &'static str = "deploy_plain_pool1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitSetAdmins { - pub u_o_admin: Vec, - pub u_p_admin: Vec, - pub u_e_admin: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl CommitSetAdmins { - const METHOD_ID: [u8; 4] = [140u8, 177u8, 108u8, 138u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_o_admin: values + 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 u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_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), + ] + }, + u_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_p_admin: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_e_admin: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_asset_type: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_o_admin), + .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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_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.u_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::Address( - ethabi::Address::from_slice(&self.u_p_admin), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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::Address( - ethabi::Address::from_slice(&self.u_e_admin), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for CommitSetAdmins { - const NAME: &'static str = "commit_set_admins"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 DeployPlainPool2 { + const NAME: &'static str = "deploy_plain_pool2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitTransferOwnership { - pub u_target: Vec, - pub u_new_admin: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl CommitTransferOwnership { - const METHOD_ID: [u8; 4] = [62u8, 161u8, 198u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_target: values + 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 u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_asset_type: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_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), + ] + }, + u_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_new_admin: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + 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.u_target), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_new_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 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 DeployGauge1 { - pub u_pool: Vec, - } - impl DeployGauge1 { - 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 { - u_pool: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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( + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementation_idx: { + 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::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_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.u_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.u_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.u_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.u_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 DeployGauge1 { - const NAME: &'static str = "deploy_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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for DeployGauge1 { - 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 DeployGauge2 { - pub u_pool: Vec, - pub u_manager: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl DeployGauge2 { - const METHOD_ID: [u8; 4] = [151u8, 249u8, 230u8, 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::Address, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool3 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool4 { + pub u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_asset_type: substreams::scalar::BigInt, + pub u_implementation_idx: substreams::scalar::BigInt, + pub u_ma_exp_time: substreams::scalar::BigInt, + } + impl DeployPlainPool4 { + const METHOD_ID: [u8; 4] = [212u8, 185u8, 226u8, 20u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_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), + ] + }, + u_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_manager: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + 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.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_manager), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_asset_type: { + 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 DeployGauge2 { - const NAME: &'static str = "deploy_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 DeployGauge2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployPlainPool1 { - pub u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_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 { - u_name: values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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.u_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( + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementation_idx: { + 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 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 u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_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 { - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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) - }, - u_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.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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.u_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.u_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 u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_asset_type: substreams::scalar::BigInt, - pub u_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 { - u_name: values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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) - }, - u_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) - }, - u_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.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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.u_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.u_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.u_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( + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_ma_exp_time: { + 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 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 DeployPlainPool4 { - pub u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_asset_type: substreams::scalar::BigInt, - pub u_implementation_idx: substreams::scalar::BigInt, - pub u_ma_exp_time: substreams::scalar::BigInt, - } - impl DeployPlainPool4 { - const METHOD_ID: [u8; 4] = [212u8, 185u8, 226u8, 20u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) + .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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_coins + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - u_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) - }, - u_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) - }, - u_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) - }, - u_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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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") - } + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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 - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for DeployPlainPool4 { - const NAME: &'static str = "deploy_plain_pool4"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool4 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct EmergencyAdmin {} - impl EmergencyAdmin { - const METHOD_ID: [u8; 4] = [104u8, 12u8, 119u8, 131u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for EmergencyAdmin { - const NAME: &'static str = "emergency_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 EmergencyAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureEmergencyAdmin {} - impl FutureEmergencyAdmin { - const METHOD_ID: [u8; 4] = [88u8, 102u8, 80u8, 122u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + } + impl substreams_ethereum::Function for DeployPlainPool4 { + const NAME: &'static str = "deploy_plain_pool4"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for FutureEmergencyAdmin { - const NAME: &'static str = "future_emergency_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 FutureEmergencyAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureOwnershipAdmin {} - impl FutureOwnershipAdmin { - const METHOD_ID: [u8; 4] = [60u8, 47u8, 203u8, 244u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for FutureOwnershipAdmin { - const NAME: &'static str = "future_ownership_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 FutureOwnershipAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureParameterAdmin {} - impl FutureParameterAdmin { - const METHOD_ID: [u8; 4] = [130u8, 75u8, 80u8, 133u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for FutureParameterAdmin { - const NAME: &'static str = "future_parameter_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 FutureParameterAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GaugeManager { - pub arg0: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool4 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl GaugeManager { - const METHOD_ID: [u8; 4] = [11u8, 188u8, 54u8, 206u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 EmergencyAdmin {} + impl EmergencyAdmin { + const METHOD_ID: [u8; 4] = [104u8, 12u8, 119u8, 131u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GaugeManager { - const NAME: &'static str = "gauge_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::Function for EmergencyAdmin { + const NAME: &'static str = "emergency_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeManager { - 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 MigrateGaugeManager { - pub u_gauge: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl MigrateGaugeManager { - const METHOD_ID: [u8; 4] = [233u8, 244u8, 7u8, 63u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge))], - ); - 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 EmergencyAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl substreams_ethereum::Function for MigrateGaugeManager { - const NAME: &'static str = "migrate_gauge_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 OwnershipAdmin {} - impl OwnershipAdmin { - const METHOD_ID: [u8; 4] = [71u8, 200u8, 113u8, 95u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 FutureEmergencyAdmin {} + impl FutureEmergencyAdmin { + const METHOD_ID: [u8; 4] = [88u8, 102u8, 80u8, 122u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for OwnershipAdmin { - const NAME: &'static str = "ownership_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 OwnershipAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ParameterAdmin {} - impl ParameterAdmin { - const METHOD_ID: [u8; 4] = [165u8, 176u8, 183u8, 233u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + } + impl substreams_ethereum::Function for FutureEmergencyAdmin { + const NAME: &'static str = "future_emergency_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for ParameterAdmin { - const NAME: &'static str = "parameter_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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable> for ParameterAdmin { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct RampA { - pub u_pool: Vec, - pub u_future_a: substreams::scalar::BigInt, - pub u_future_time: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable> for FutureEmergencyAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl RampA { - const METHOD_ID: [u8; 4] = [157u8, 74u8, 67u8, 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), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_future_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) - }, - u_future_time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_future_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.u_future_time.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureOwnershipAdmin {} + impl FutureOwnershipAdmin { + const METHOD_ID: [u8; 4] = [60u8, 47u8, 203u8, 244u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for RampA { - const NAME: &'static str = "ramp_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetFactoryManager { - pub u_target: Vec, - pub u_manager: Vec, + } + impl substreams_ethereum::Function for FutureOwnershipAdmin { + const NAME: &'static str = "future_ownership_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetFactoryManager { - const METHOD_ID: [u8; 4] = [217u8, 31u8, 24u8, 248u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_target), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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, - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for SetFactoryManager { - const NAME: &'static str = "set_factory_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 SetFeeReceiver { - pub u_target: Vec, - pub u_base_pool: Vec, - pub u_fee_receiver: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl SetFeeReceiver { - const METHOD_ID: [u8; 4] = [168u8, 223u8, 233u8, 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::Address, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_target), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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::rpc::RPCDecodable> for FutureOwnershipAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureParameterAdmin {} + impl FutureParameterAdmin { + const METHOD_ID: [u8; 4] = [130u8, 75u8, 80u8, 133u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - 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) + } + impl substreams_ethereum::Function for FutureParameterAdmin { + const NAME: &'static str = "future_parameter_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 FutureParameterAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GaugeManager { + pub arg0: Vec, + } + impl GaugeManager { + const METHOD_ID: [u8; 4] = [11u8, 188u8, 54u8, 206u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } } - fn encode(&self) -> Vec { - self.encode() + } + } + impl substreams_ethereum::Function for GaugeManager { + const NAME: &'static str = "gauge_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 GaugeManager { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MigrateGaugeManager { + pub u_gauge: Vec, + } + impl MigrateGaugeManager { + const METHOD_ID: [u8; 4] = [233u8, 244u8, 7u8, 63u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge))], + ); + 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 SetGaugeImplementation { - pub u_target: Vec, - pub u_gauge_implementation: Vec, + } + impl substreams_ethereum::Function for MigrateGaugeManager { + const NAME: &'static str = "migrate_gauge_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) } - impl SetGaugeImplementation { - const METHOD_ID: [u8; 4] = [56u8, 203u8, 235u8, 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()); + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OwnershipAdmin {} + impl OwnershipAdmin { + const METHOD_ID: [u8; 4] = [71u8, 200u8, 113u8, 95u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_target), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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 OwnershipAdmin { + const NAME: &'static str = "ownership_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 OwnershipAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ParameterAdmin {} + impl ParameterAdmin { + const METHOD_ID: [u8; 4] = [165u8, 176u8, 183u8, 233u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - 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() - } + } + impl substreams_ethereum::Function for ParameterAdmin { + const NAME: &'static str = "parameter_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetGaugeManager { - pub u_gauge: Vec, - pub u_manager: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl SetGaugeManager { - const METHOD_ID: [u8; 4] = [193u8, 240u8, 79u8, 118u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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 { - u_gauge: values + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for ParameterAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RampA { + pub u_pool: Vec, + pub u_future_a: substreams::scalar::BigInt, + pub u_future_time: substreams::scalar::BigInt, + } + impl RampA { + const METHOD_ID: [u8; 4] = [157u8, 74u8, 67u8, 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), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_future_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_manager: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_future_time: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), + .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.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_future_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::Address( - ethabi::Address::from_slice(&self.u_manager), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_future_time.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for SetGaugeManager { - const NAME: &'static str = "set_gauge_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() + pub fn 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 SetKilled { - pub u_gauge: Vec, - pub u_is_killed: bool, + } + impl substreams_ethereum::Function for RampA { + const NAME: &'static str = "ramp_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) } - impl SetKilled { - const METHOD_ID: [u8; 4] = [67u8, 68u8, 206u8, 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, ethabi::ParamType::Bool], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_is_killed: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFactoryManager { + pub u_target: Vec, + pub u_manager: Vec, + } + impl SetFactoryManager { + const METHOD_ID: [u8; 4] = [217u8, 31u8, 24u8, 248u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_target)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for SetFactoryManager { + const NAME: &'static str = "set_factory_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 SetFeeReceiver { + pub u_target: Vec, + pub u_base_pool: Vec, + pub u_fee_receiver: Vec, + } + impl SetFeeReceiver { + const METHOD_ID: [u8; 4] = [168u8, 223u8, 233u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Bool(self.u_is_killed.clone()), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_target)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_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 SetKilled { - const NAME: &'static str = "set_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + } + 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 u_target: Vec, + pub u_gauge_implementation: Vec, + } + impl SetGaugeImplementation { + const METHOD_ID: [u8; 4] = [56u8, 203u8, 235u8, 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, ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_target)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_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, } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) + } + } + 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 SetGaugeManager { + pub u_gauge: Vec, + pub u_manager: Vec, + } + impl SetGaugeManager { + const METHOD_ID: [u8; 4] = [193u8, 240u8, 79u8, 118u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_gauge)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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, } - fn encode(&self) -> Vec { - self.encode() + } + } + impl substreams_ethereum::Function for SetGaugeManager { + const NAME: &'static str = "set_gauge_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 SetKilled { + pub u_gauge: Vec, + pub u_is_killed: bool, + } + impl SetKilled { + const METHOD_ID: [u8; 4] = [67u8, 68u8, 206u8, 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, ethabi::ParamType::Bool], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_is_killed: 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.u_gauge)), + ethabi::Token::Bool(self.u_is_killed.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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetMaExpTime { - pub u_pool: Vec, - pub u_ma_exp_time: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for SetKilled { + const NAME: &'static str = "set_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetMaExpTime { - const METHOD_ID: [u8; 4] = [21u8, 0u8, 22u8, 10u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_pool: values + 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 SetMaExpTime { + pub u_pool: Vec, + pub u_ma_exp_time: substreams::scalar::BigInt, + } + impl SetMaExpTime { + const METHOD_ID: [u8; 4] = [21u8, 0u8, 22u8, 10u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_ma_exp_time: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .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.u_pool)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for SetMaExpTime { - const NAME: &'static str = "set_ma_exp_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 SetMetapoolImplementations { - pub u_target: Vec, - pub u_base_pool: Vec, - pub u_implementations: [Vec; 10usize], + } + impl substreams_ethereum::Function for SetMaExpTime { + const NAME: &'static str = "set_ma_exp_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetMetapoolImplementations { - const METHOD_ID: [u8; 4] = [179u8, 4u8, 67u8, 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::Address, - 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 { - u_target: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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( + 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 u_target: Vec, + pub u_base_pool: Vec, + pub u_implementations: [Vec; 10usize], + } + impl SetMetapoolImplementations { + const METHOD_ID: [u8; 4] = [179u8, 4u8, 67u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_target), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - { - let v = self - .u_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, - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_target)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + { + let v = self + .u_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 } - 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() + pub fn 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 SetPlainImplementations { - pub u_target: Vec, - pub u_n_coins: substreams::scalar::BigInt, - pub u_implementations: [Vec; 10usize], + } + 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) } - impl SetPlainImplementations { - const METHOD_ID: [u8; 4] = [247u8, 222u8, 27u8, 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), - 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 { - u_target: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetPlainImplementations { + pub u_target: Vec, + pub u_n_coins: substreams::scalar::BigInt, + pub u_implementations: [Vec; 10usize], + } + impl SetPlainImplementations { + const METHOD_ID: [u8; 4] = [247u8, 222u8, 27u8, 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), + 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 { + u_target: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_n_coins: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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), - ] + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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.u_target)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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 + .u_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, } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetRewardDistributor { + pub u_gauge: Vec, + pub u_reward_token: Vec, + pub u_distributor: Vec, + } + impl SetRewardDistributor { + const METHOD_ID: [u8; 4] = [200u8, 23u8, 80u8, 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::Token::Address( - ethabi::Address::from_slice(&self.u_target), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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 - .u_implementations - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_gauge: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_reward_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_distributor: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_gauge)), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_reward_token), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_distributor), + ), + ], + ); + 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() - } + } + impl substreams_ethereum::Function for SetRewardDistributor { + const NAME: &'static str = "set_reward_distributor"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetRewardDistributor { - pub u_gauge: Vec, - pub u_reward_token: Vec, - pub u_distributor: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl SetRewardDistributor { - const METHOD_ID: [u8; 4] = [200u8, 23u8, 80u8, 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::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_gauge: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_reward_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_distributor: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct StopRampA { + pub u_pool: Vec, + } + impl StopRampA { + const METHOD_ID: [u8; 4] = [83u8, 247u8, 155u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_pool))], + ); + 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 encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for StopRampA { + const NAME: &'static str = "stop_ramp_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() + } + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct ApplyAdmins { + pub ownership_admin: Vec, + pub parameter_admin: Vec, + pub emergency_admin: Vec, + } + impl ApplyAdmins { + const TOPIC_ID: [u8; 32] = [ + 214u8, + 26u8, + 22u8, + 145u8, + 46u8, + 251u8, + 154u8, + 28u8, + 91u8, + 213u8, + 54u8, + 29u8, + 255u8, + 35u8, + 139u8, + 149u8, + 244u8, + 82u8, + 103u8, + 45u8, + 237u8, + 117u8, + 26u8, + 66u8, + 92u8, + 17u8, + 219u8, + 94u8, + 79u8, + 88u8, + 129u8, + 118u8, + ]; + 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::Token::Address( - ethabi::Address::from_slice(&self.u_gauge), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_reward_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_distributor), - ), + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, ], - ); - 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, - } - } + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + ownership_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + parameter_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + emergency_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for SetRewardDistributor { - const NAME: &'static str = "set_reward_distributor"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Event for ApplyAdmins { + const NAME: &'static str = "ApplyAdmins"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct StopRampA { - pub u_pool: Vec, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl StopRampA { - const METHOD_ID: [u8; 4] = [83u8, 247u8, 155u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_pool))], - ); - 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 CommitAdmins { + pub ownership_admin: Vec, + pub parameter_admin: Vec, + pub emergency_admin: Vec, + } + impl CommitAdmins { + const TOPIC_ID: [u8; 32] = [ + 120u8, + 87u8, + 33u8, + 49u8, + 253u8, + 139u8, + 154u8, + 46u8, + 52u8, + 92u8, + 72u8, + 166u8, + 175u8, + 191u8, + 85u8, + 188u8, + 18u8, + 25u8, + 227u8, + 147u8, + 85u8, + 63u8, + 234u8, + 198u8, + 148u8, + 248u8, + 152u8, + 137u8, + 144u8, + 61u8, + 39u8, + 4u8, + ]; + 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 { + ownership_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + parameter_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + emergency_admin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for StopRampA { - const NAME: &'static str = "stop_ramp_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() - } - } - } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct ApplyAdmins { - pub ownership_admin: Vec, - pub parameter_admin: Vec, - pub emergency_admin: Vec, - } - impl ApplyAdmins { - const TOPIC_ID: [u8; 32] = [ - 214u8, - 26u8, - 22u8, - 145u8, - 46u8, - 251u8, - 154u8, - 28u8, - 91u8, - 213u8, - 54u8, - 29u8, - 255u8, - 35u8, - 139u8, - 149u8, - 244u8, - 82u8, - 103u8, - 45u8, - 237u8, - 117u8, - 26u8, - 66u8, - 92u8, - 17u8, - 219u8, - 94u8, - 79u8, - 88u8, - 129u8, - 118u8, - ]; - 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 { - ownership_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - parameter_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - emergency_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for ApplyAdmins { - const NAME: &'static str = "ApplyAdmins"; - 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 CommitAdmins { - pub ownership_admin: Vec, - pub parameter_admin: Vec, - pub emergency_admin: Vec, - } - impl CommitAdmins { - const TOPIC_ID: [u8; 32] = [ - 120u8, - 87u8, - 33u8, - 49u8, - 253u8, - 139u8, - 154u8, - 46u8, - 52u8, - 92u8, - 72u8, - 166u8, - 175u8, - 191u8, - 85u8, - 188u8, - 18u8, - 25u8, - 227u8, - 147u8, - 85u8, - 63u8, - 234u8, - 198u8, - 148u8, - 248u8, - 152u8, - 137u8, - 144u8, - 61u8, - 39u8, - 4u8, - ]; - 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 { - ownership_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - parameter_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - emergency_admin: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + } + impl substreams_ethereum::Event for CommitAdmins { + const NAME: &'static str = "CommitAdmins"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::Event for CommitAdmins { - const NAME: &'static str = "CommitAdmins"; - 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) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/abi/curve/pool.rs b/src/abi/curve/pool.rs index aa68e4f..8d02812 100644 --- a/src/abi/curve/pool.rs +++ b/src/abi/curve/pool.rs @@ -1,12500 +1,12124 @@ - 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 A {} - impl A { - const METHOD_ID: [u8; 4] = [244u8, 70u8, 193u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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 - } +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 A {} + impl A { + const METHOD_ID: [u8; 4] = [244u8, 70u8, 193u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + 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 A { - const NAME: &'static str = "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::Function for A { + const NAME: &'static str = "A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for A { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct D {} - impl D { - const METHOD_ID: [u8; 4] = [15u8, 82u8, 155u8, 162u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 - } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for A { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct D {} + impl D { + const METHOD_ID: [u8; 4] = [15u8, 82u8, 155u8, 162u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 D { - const NAME: &'static str = "D"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 D { + const NAME: &'static str = "D"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for D { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AddLiquidity1 { - pub amounts: [substreams::scalar::BigInt; 2usize], - pub min_mint_amount: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl AddLiquidity1 { - const METHOD_ID: [u8; 4] = [11u8, 76u8, 126u8, 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - amounts: { - 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), - ] - }, - min_mint_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable for D { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity1 { + pub amounts: [substreams::scalar::BigInt; 2usize], + pub min_mint_amount: substreams::scalar::BigInt, + } + impl AddLiquidity1 { + const METHOD_ID: [u8; 4] = [11u8, 76u8, 126u8, 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( &[ - { - 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::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.min_mint_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + amounts: { + 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)] + }, + min_mint_amount: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + 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::FixedArray(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.min_mint_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::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 AddLiquidity1 { - const NAME: &'static str = "add_liquidity1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AddLiquidity1 { + const NAME: &'static str = "add_liquidity1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AddLiquidity1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AddLiquidity2 { - pub amounts: [substreams::scalar::BigInt; 2usize], - pub min_mint_amount: substreams::scalar::BigInt, - pub use_eth: bool, + fn encode(&self) -> Vec { + self.encode() } - impl AddLiquidity2 { - const METHOD_ID: [u8; 4] = [238u8, 34u8, 190u8, 35u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - amounts: { - 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), - ] - }, - min_mint_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) - }, - use_eth: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for AddLiquidity1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity2 { + pub amounts: [substreams::scalar::BigInt; 2usize], + pub min_mint_amount: substreams::scalar::BigInt, + pub use_eth: bool, + } + impl AddLiquidity2 { + const METHOD_ID: [u8; 4] = [238u8, 34u8, 190u8, 35u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - { - 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::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.min_mint_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), - ethabi::Token::Bool(self.use_eth.clone()), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + amounts: { + 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)] + }, + min_mint_amount: { 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, + }, + use_eth: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + 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::FixedArray(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.min_mint_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bool(self.use_eth.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 { + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for AddLiquidity2 { + const NAME: &'static str = "add_liquidity2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AddLiquidity2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AdjustmentStep {} + impl AdjustmentStep { + const METHOD_ID: [u8; 4] = [8u8, 56u8, 18u8, 229u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 AddLiquidity2 { - const NAME: &'static str = "add_liquidity2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AdjustmentStep { + const NAME: &'static str = "adjustment_step"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AddLiquidity2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AdjustmentStep {} - impl AdjustmentStep { - const METHOD_ID: [u8; 4] = [8u8, 56u8, 18u8, 229u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AdjustmentStep { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AdminActionsDeadline {} + impl AdminActionsDeadline { + const METHOD_ID: [u8; 4] = [64u8, 94u8, 40u8, 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 { + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for AdminActionsDeadline { + const NAME: &'static str = "admin_actions_deadline"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AdminActionsDeadline { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AdminFee {} + impl AdminFee { + const METHOD_ID: [u8; 4] = [254u8, 227u8, 247u8, 249u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 AdjustmentStep { - const NAME: &'static str = "adjustment_step"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AdminFee { + const NAME: &'static str = "admin_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AdjustmentStep { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminActionsDeadline {} - impl AdminActionsDeadline { - const METHOD_ID: [u8; 4] = [64u8, 94u8, 40u8, 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 { - 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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AdminFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AdminFeeReceiver {} + impl AdminFeeReceiver { + const METHOD_ID: [u8; 4] = [110u8, 66u8, 228u8, 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 AdminFeeReceiver { + const NAME: &'static str = "admin_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 AdminFeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AllowedExtraProfit {} + impl AllowedExtraProfit { + const METHOD_ID: [u8; 4] = [73u8, 254u8, 158u8, 119u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 AdminActionsDeadline { - const NAME: &'static str = "admin_actions_deadline"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AllowedExtraProfit { + const NAME: &'static str = "allowed_extra_profit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AdminActionsDeadline { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminFee {} - impl AdminFee { - const METHOD_ID: [u8; 4] = [254u8, 227u8, 247u8, 249u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AllowedExtraProfit { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ApplyNewParameters {} + impl ApplyNewParameters { + const METHOD_ID: [u8; 4] = [42u8, 125u8, 215u8, 205u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) + } + } + impl substreams_ethereum::Function for ApplyNewParameters { + const NAME: &'static str = "apply_new_parameters"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ApplyTransferOwnership {} + impl ApplyTransferOwnership { + const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 match_call(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(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({ + } + } + impl substreams_ethereum::Function for ApplyTransferOwnership { + const NAME: &'static str = "apply_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 Balances1 { + pub arg0: substreams::scalar::BigInt, + } + impl Balances1 { + const METHOD_ID: [u8; 4] = [73u8, 3u8, 176u8, 209u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::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") + .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 - } + }, + }) + } + 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::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 AdminFee { - const NAME: &'static str = "admin_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Balances1 { + const NAME: &'static str = "balances1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AdminFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminFeeReceiver {} - impl AdminFeeReceiver { - const METHOD_ID: [u8; 4] = [110u8, 66u8, 228u8, 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for AdminFeeReceiver { - const NAME: &'static str = "admin_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() - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::rpc::RPCDecodable> for AdminFeeReceiver { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + } + impl substreams_ethereum::rpc::RPCDecodable + for Balances1 { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct AllowedExtraProfit {} - impl AllowedExtraProfit { - const METHOD_ID: [u8; 4] = [73u8, 254u8, 158u8, 119u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 Balances2 { + pub arg0: substreams::scalar::BigInt, + } + impl Balances2 { + const METHOD_ID: [u8; 4] = [6u8, 90u8, 128u8, 216u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Int(128usize)], + 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_uint() + .expect(INTERNAL_ERR) + .into_int() .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 - } + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.arg0.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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(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 AllowedExtraProfit { - const NAME: &'static str = "allowed_extra_profit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for AllowedExtraProfit { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ApplyNewParameters {} - impl ApplyNewParameters { - const METHOD_ID: [u8; 4] = [42u8, 125u8, 215u8, 205u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 Balances2 { + const NAME: &'static str = "balances2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for ApplyNewParameters { - const NAME: &'static str = "apply_new_parameters"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ApplyTransferOwnership {} - impl ApplyTransferOwnership { - const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 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 ApplyTransferOwnership { - const NAME: &'static str = "apply_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() - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct Balances1 { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable + for Balances2 { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl Balances1 { - const METHOD_ID: [u8; 4] = [73u8, 3u8, 176u8, 209u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::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( + } + #[derive(Debug, Clone, PartialEq)] + pub struct CalcTokenAmount { + pub amounts: [substreams::scalar::BigInt; 2usize], + } + impl CalcTokenAmount { + const METHOD_ID: [u8; 4] = [141u8, 142u8, 167u8, 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::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::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), ], - ); - let mut encoded = Vec::with_capacity(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 + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + amounts: { + let mut iter = 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 - } + .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( + &[ + { + 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::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::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 Balances1 { - const NAME: &'static str = "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::Function for CalcTokenAmount { + const NAME: &'static str = "calc_token_amount"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Balances1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Balances2 { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Balances2 { - const METHOD_ID: [u8; 4] = [6u8, 90u8, 128u8, 216u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Int(128usize)], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for CalcTokenAmount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CalcWithdrawOneCoin { + pub token_amount: substreams::scalar::BigInt, + pub i: substreams::scalar::BigInt, + } + impl CalcWithdrawOneCoin { + const METHOD_ID: [u8; 4] = [79u8, 176u8, 140u8, 94u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - { - let non_full_signed_bytes = self.arg0.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()), - ) - }, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_amount: { 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 - } + }, + 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::Uint( + ethabi::Uint::from_big_endian( + match self.token_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + 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 { + 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 Balances2 { - const NAME: &'static str = "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::Function for CalcWithdrawOneCoin { + const NAME: &'static str = "calc_withdraw_one_coin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Balances2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CalcTokenAmount { - pub amounts: [substreams::scalar::BigInt; 2usize], + fn encode(&self) -> Vec { + self.encode() } - impl CalcTokenAmount { - const METHOD_ID: [u8; 4] = [141u8, 142u8, 167u8, 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::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 { - amounts: { - 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), - ] - }, - }) + } + impl substreams_ethereum::rpc::RPCDecodable + for CalcWithdrawOneCoin { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ClaimAdminFees {} + impl ClaimAdminFees { + const METHOD_ID: [u8; 4] = [201u8, 63u8, 73u8, 232u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(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 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::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::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + } + impl substreams_ethereum::Function for ClaimAdminFees { + const NAME: &'static str = "claim_admin_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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Coins1 { + pub i: substreams::scalar::BigInt, + } + impl Coins1 { + const METHOD_ID: [u8; 4] = [198u8, 97u8, 6u8, 87u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + i: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + 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 CalcTokenAmount { - const NAME: &'static str = "calc_token_amount"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Coins1 { + const NAME: &'static str = "coins1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for CalcTokenAmount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CalcWithdrawOneCoin { - pub token_amount: substreams::scalar::BigInt, - pub i: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl CalcWithdrawOneCoin { - const METHOD_ID: [u8; 4] = [79u8, 176u8, 140u8, 94u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - token_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) - }, - 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::Uint( - ethabi::Uint::from_big_endian( - match self.token_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - 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 { - 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({ + } + impl substreams_ethereum::rpc::RPCDecodable> for Coins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Coins2 { + pub arg0: substreams::scalar::BigInt, + } + impl Coins2 { + const METHOD_ID: [u8; 4] = [35u8, 116u8, 110u8, 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::Int(128usize)], + 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_uint() + .expect(INTERNAL_ERR) + .into_int() .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 - } + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.arg0.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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for CalcWithdrawOneCoin { - const NAME: &'static str = "calc_withdraw_one_coin"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for CalcWithdrawOneCoin { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for Coins2 { + const NAME: &'static str = "coins2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ClaimAdminFees {} - impl ClaimAdminFees { - const METHOD_ID: [u8; 4] = [201u8, 63u8, 73u8, 232u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn 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 ClaimAdminFees { - const NAME: &'static str = "claim_admin_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() - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct Coins1 { - pub i: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable> for Coins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl Coins1 { - const METHOD_ID: [u8; 4] = [198u8, 97u8, 6u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - 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( + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitNewParameters { + pub u_new_mid_fee: substreams::scalar::BigInt, + pub u_new_out_fee: substreams::scalar::BigInt, + pub u_new_admin_fee: substreams::scalar::BigInt, + pub u_new_fee_gamma: substreams::scalar::BigInt, + pub u_new_allowed_extra_profit: substreams::scalar::BigInt, + pub u_new_adjustment_step: substreams::scalar::BigInt, + pub u_new_ma_half_time: substreams::scalar::BigInt, + } + impl CommitNewParameters { + const METHOD_ID: [u8; 4] = [164u8, 60u8, 51u8, 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::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(), - ), - ), + 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), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_new_mid_fee: { + 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 Coins1 { - const NAME: &'static str = "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 Coins1 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Coins2 { - pub arg0: substreams::scalar::BigInt, - } - impl Coins2 { - const METHOD_ID: [u8; 4] = [35u8, 116u8, 110u8, 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::Int(128usize)], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let non_full_signed_bytes = self.arg0.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()), - ) - }, - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> 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) + }, + u_new_out_fee: { + 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 Coins2 { - const NAME: &'static str = "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 Coins2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitNewParameters { - pub u_new_mid_fee: substreams::scalar::BigInt, - pub u_new_out_fee: substreams::scalar::BigInt, - pub u_new_admin_fee: substreams::scalar::BigInt, - pub u_new_fee_gamma: substreams::scalar::BigInt, - pub u_new_allowed_extra_profit: substreams::scalar::BigInt, - pub u_new_adjustment_step: substreams::scalar::BigInt, - pub u_new_ma_half_time: substreams::scalar::BigInt, - } - impl CommitNewParameters { - const METHOD_ID: [u8; 4] = [164u8, 60u8, 51u8, 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::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 { - u_new_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) - }, - u_new_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) - }, - u_new_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) - }, - u_new_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) - }, - u_new_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) - }, - u_new_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) - }, - u_new_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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_new_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") - } + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_new_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) + }, + u_new_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) + }, + u_new_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) + }, + u_new_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) + }, + u_new_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) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_new_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_new_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_new_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_new_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_new_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_new_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_new_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_new_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_new_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_new_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_new_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_new_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_new_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(), - ), + } + .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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for CommitNewParameters { - const NAME: &'static str = "commit_new_parameters"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 CommitTransferOwnership { - pub u_owner: Vec, + } + impl substreams_ethereum::Function for CommitNewParameters { + const NAME: &'static str = "commit_new_parameters"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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 { - u_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner))], - ); - 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 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() + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitTransferOwnership { + pub u_owner: 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 { + u_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner))], + ); + 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 Exchange1 { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub dx: substreams::scalar::BigInt, - pub min_dy: substreams::scalar::BigInt, + } + 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 Exchange1 { - const METHOD_ID: [u8; 4] = [91u8, 65u8, 185u8, 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::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 { - 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) - }, - j: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - dx: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - min_dy: { - let mut v = [0 as u8; 32]; - values - .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( + 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 Exchange1 { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub dx: substreams::scalar::BigInt, + pub min_dy: substreams::scalar::BigInt, + } + impl Exchange1 { + const METHOD_ID: [u8; 4] = [91u8, 65u8, 185u8, 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::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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.j.clone().to_bytes_be() { - (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.dx.clone().to_bytes_be() { - (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.min_dy.clone().to_bytes_be() { - (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::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { 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 - } + }, + j: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + dx: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + min_dy: { + let mut v = [0 as u8; 32]; + values + .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.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(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.j.clone().to_bytes_be() { + (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.dx.clone().to_bytes_be() { + (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.min_dy.clone().to_bytes_be() { + (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 Exchange1 { - const NAME: &'static str = "exchange1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Exchange1 { + const NAME: &'static str = "exchange1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Exchange1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Exchange2 { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub dx: substreams::scalar::BigInt, - pub min_dy: substreams::scalar::BigInt, - pub use_eth: bool, + fn encode(&self) -> Vec { + self.encode() } - impl Exchange2 { - const METHOD_ID: [u8; 4] = [57u8, 71u8, 71u8, 197u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - j: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - dx: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - min_dy: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - use_eth: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for Exchange1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Exchange2 { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub dx: substreams::scalar::BigInt, + pub min_dy: substreams::scalar::BigInt, + pub use_eth: bool, + } + impl Exchange2 { + const METHOD_ID: [u8; 4] = [57u8, 71u8, 71u8, 197u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - 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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.j.clone().to_bytes_be() { - (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.dx.clone().to_bytes_be() { - (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.min_dy.clone().to_bytes_be() { - (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.use_eth.clone()), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { 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 Exchange2 { - const NAME: &'static str = "exchange2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Exchange2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ExchangeUnderlying { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub dx: substreams::scalar::BigInt, - pub min_dy: substreams::scalar::BigInt, - } - impl ExchangeUnderlying { - const METHOD_ID: [u8; 4] = [101u8, 178u8, 72u8, 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::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 { - 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) - }, - j: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - dx: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - min_dy: { - let mut v = [0 as u8; 32]; - values - .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.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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.j.clone().to_bytes_be() { - (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.dx.clone().to_bytes_be() { - (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.min_dy.clone().to_bytes_be() { - (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({ + }, + j: { 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 ExchangeUnderlying { - const NAME: &'static str = "exchange_underlying"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ExchangeUnderlying { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Fee {} - impl Fee { - const METHOD_ID: [u8; 4] = [221u8, 202u8, 63u8, 67u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + dx: { 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 Fee { - const NAME: &'static str = "fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for Fee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FeeGamma {} - impl FeeGamma { - const METHOD_ID: [u8; 4] = [114u8, 212u8, 240u8, 226u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + min_dy: { 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 - } + }, + use_eth: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + 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(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.j.clone().to_bytes_be() { + (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.dx.clone().to_bytes_be() { + (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.min_dy.clone().to_bytes_be() { + (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.use_eth.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 { + 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 FeeGamma { - const NAME: &'static str = "fee_gamma"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Exchange2 { + const NAME: &'static str = "exchange2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FeeGamma { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAGamma {} - impl FutureAGamma { - const METHOD_ID: [u8; 4] = [243u8, 12u8, 250u8, 213u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Exchange2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ExchangeUnderlying { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub dx: substreams::scalar::BigInt, + pub min_dy: substreams::scalar::BigInt, + } + impl ExchangeUnderlying { + const METHOD_ID: [u8; 4] = [101u8, 178u8, 72u8, 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::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 { + i: { 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 FutureAGamma { - const NAME: &'static str = "future_A_gamma"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureAGamma { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAGammaTime {} - impl FutureAGammaTime { - const METHOD_ID: [u8; 4] = [249u8, 237u8, 149u8, 151u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + j: { 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 FutureAGammaTime { - const NAME: &'static str = "future_A_gamma_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureAGammaTime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdjustmentStep {} - impl FutureAdjustmentStep { - const METHOD_ID: [u8; 4] = [78u8, 161u8, 44u8, 125u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + dx: { 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 FutureAdjustmentStep { - const NAME: &'static str = "future_adjustment_step"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureAdjustmentStep { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdminFee {} - impl FutureAdminFee { - const METHOD_ID: [u8; 4] = [227u8, 130u8, 68u8, 98u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + min_dy: { 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 FutureAdminFee { - const NAME: &'static str = "future_admin_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::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(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.j.clone().to_bytes_be() { + (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.dx.clone().to_bytes_be() { + (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.min_dy.clone().to_bytes_be() { + (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::rpc::RPCDecodable - for FutureAdminFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for ExchangeUnderlying { + const NAME: &'static str = "exchange_underlying"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAllowedExtraProfit {} - impl FutureAllowedExtraProfit { - const METHOD_ID: [u8; 4] = [114u8, 124u8, 237u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ExchangeUnderlying { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Fee {} + impl Fee { + const METHOD_ID: [u8; 4] = [221u8, 202u8, 63u8, 67u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Fee { + const NAME: &'static str = "fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Fee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FeeGamma {} + impl FeeGamma { + const METHOD_ID: [u8; 4] = [114u8, 212u8, 240u8, 226u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 FutureAllowedExtraProfit { - const NAME: &'static str = "future_allowed_extra_profit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FeeGamma { + const NAME: &'static str = "fee_gamma"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureAllowedExtraProfit { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureFeeGamma {} - impl FutureFeeGamma { - const METHOD_ID: [u8; 4] = [215u8, 195u8, 220u8, 190u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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) - }) + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FeeGamma { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAGamma {} + impl FutureAGamma { + const METHOD_ID: [u8; 4] = [243u8, 12u8, 250u8, 213u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } - pub fn 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 FutureAGamma { + const NAME: &'static str = "future_A_gamma"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureAGamma { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAGammaTime {} + impl FutureAGammaTime { + const METHOD_ID: [u8; 4] = [249u8, 237u8, 149u8, 151u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; + } + } + impl substreams_ethereum::Function for FutureAGammaTime { + const NAME: &'static str = "future_A_gamma_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureAGammaTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAdjustmentStep {} + impl FutureAdjustmentStep { + const METHOD_ID: [u8; 4] = [78u8, 161u8, 44u8, 125u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + } + impl substreams_ethereum::Function for FutureAdjustmentStep { + const NAME: &'static str = "future_adjustment_step"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureAdjustmentStep { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAdminFee {} + impl FutureAdminFee { + const METHOD_ID: [u8; 4] = [227u8, 130u8, 68u8, 98u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 FutureFeeGamma { - const NAME: &'static str = "future_fee_gamma"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + } + impl substreams_ethereum::Function for FutureAdminFee { + const NAME: &'static str = "future_admin_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureAdminFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAllowedExtraProfit {} + impl FutureAllowedExtraProfit { + const METHOD_ID: [u8; 4] = [114u8, 124u8, 237u8, 87u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) + } + } + impl substreams_ethereum::Function for FutureAllowedExtraProfit { + const NAME: &'static str = "future_allowed_extra_profit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureAllowedExtraProfit { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureFeeGamma {} + impl FutureFeeGamma { + const METHOD_ID: [u8; 4] = [215u8, 195u8, 220u8, 190u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } - fn encode(&self) -> Vec { - self.encode() + } + } + impl substreams_ethereum::Function for FutureFeeGamma { + const NAME: &'static str = "future_fee_gamma"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureFeeGamma { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureMaHalfTime {} + impl FutureMaHalfTime { + const METHOD_ID: [u8; 4] = [12u8, 94u8, 35u8, 212u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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::rpc::RPCDecodable - for FutureFeeGamma { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for FutureMaHalfTime { + const NAME: &'static str = "future_ma_half_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureMaHalfTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureMidFee {} + impl FutureMidFee { + const METHOD_ID: [u8; 4] = [124u8, 249u8, 174u8, 220u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureMaHalfTime {} - impl FutureMaHalfTime { - const METHOD_ID: [u8; 4] = [12u8, 94u8, 35u8, 212u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) + } + impl substreams_ethereum::Function for FutureMidFee { + const NAME: &'static str = "future_mid_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureMidFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureOutFee {} + impl FutureOutFee { + const METHOD_ID: [u8; 4] = [125u8, 27u8, 6u8, 12u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + } + } + impl substreams_ethereum::Function for FutureOutFee { + const NAME: &'static str = "future_out_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureOutFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureOwner {} + impl FutureOwner { + const METHOD_ID: [u8; 4] = [30u8, 192u8, 205u8, 193u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) + } + } + impl substreams_ethereum::Function for FutureOwner { + const NAME: &'static str = "future_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 FutureOwner { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Gamma {} + impl Gamma { + const METHOD_ID: [u8; 4] = [177u8, 55u8, 57u8, 41u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } - 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({ + } + } + impl substreams_ethereum::Function for Gamma { + const NAME: &'static str = "gamma"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Gamma { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDy { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub dx: substreams::scalar::BigInt, + } + impl GetDy { + const METHOD_ID: [u8; 4] = [85u8, 109u8, 110u8, 159u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { 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 FutureMaHalfTime { - const NAME: &'static str = "future_ma_half_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureMaHalfTime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureMidFee {} - impl FutureMidFee { - const METHOD_ID: [u8; 4] = [124u8, 249u8, 174u8, 220u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + j: { 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 FutureMidFee { - const NAME: &'static str = "future_mid_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureMidFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureOutFee {} - impl FutureOutFee { - const METHOD_ID: [u8; 4] = [125u8, 27u8, 6u8, 12u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + dx: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + 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(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.j.clone().to_bytes_be() { + (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.dx.clone().to_bytes_be() { + (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 FutureOutFee { - const NAME: &'static str = "future_out_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetDy { + const NAME: &'static str = "get_dy"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureOutFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureOwner {} - impl FutureOwner { - const METHOD_ID: [u8; 4] = [30u8, 192u8, 205u8, 193u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for GetDy { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetVirtualPrice {} + impl GetVirtualPrice { + const METHOD_ID: [u8; 4] = [187u8, 123u8, 139u8, 128u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 FutureOwner { - const NAME: &'static str = "future_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::Function for GetVirtualPrice { + const NAME: &'static str = "get_virtual_price"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FutureOwner { - 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 GetVirtualPrice { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct Gamma {} - impl Gamma { - const METHOD_ID: [u8; 4] = [177u8, 55u8, 57u8, 41u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) + } + #[derive(Debug, Clone, PartialEq)] + pub struct InitialAGamma {} + impl InitialAGamma { + const METHOD_ID: [u8; 4] = [32u8, 79u8, 227u8, 213u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + } + } + impl substreams_ethereum::Function for InitialAGamma { + const NAME: &'static str = "initial_A_gamma"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for InitialAGamma { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InitialAGammaTime {} + impl InitialAGammaTime { + const METHOD_ID: [u8; 4] = [232u8, 152u8, 118u8, 255u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for InitialAGammaTime { + const NAME: &'static str = "initial_A_gamma_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for InitialAGammaTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsKilled {} + impl IsKilled { + const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 Gamma { - const NAME: &'static str = "gamma"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IsKilled { + const NAME: &'static str = "is_killed"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Gamma { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDy { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub dx: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable for IsKilled { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl GetDy { - const METHOD_ID: [u8; 4] = [85u8, 109u8, 110u8, 159u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 KillDeadline {} + impl KillDeadline { + const METHOD_ID: [u8; 4] = [42u8, 66u8, 104u8, 150u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - let mut values = ethabi::decode( - &[ - 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 { - 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) - }, - j: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - dx: { - let mut v = [0 as u8; 32]; - values - .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.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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.j.clone().to_bytes_be() { - (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.dx.clone().to_bytes_be() { - (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) - }) + } + } + impl substreams_ethereum::Function for KillDeadline { + const NAME: &'static str = "kill_deadline"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for KillDeadline { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct KillMe {} + impl KillMe { + const METHOD_ID: [u8; 4] = [227u8, 105u8, 136u8, 83u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 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 KillMe { + const NAME: &'static str = "kill_me"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LastPrices {} + impl LastPrices { + const METHOD_ID: [u8; 4] = [193u8, 70u8, 191u8, 148u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for LastPrices { + const NAME: &'static str = "last_prices"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for LastPrices { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct LastPricesTimestamp {} + impl LastPricesTimestamp { + const METHOD_ID: [u8; 4] = [97u8, 18u8, 199u8, 71u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 GetDy { - const NAME: &'static str = "get_dy"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 LastPricesTimestamp { + const NAME: &'static str = "last_prices_timestamp"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetDy { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetVirtualPrice {} - impl GetVirtualPrice { - const METHOD_ID: [u8; 4] = [187u8, 123u8, 139u8, 128u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for LastPricesTimestamp { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct LpPrice {} + impl LpPrice { + const METHOD_ID: [u8; 4] = [84u8, 240u8, 247u8, 213u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for LpPrice { + const NAME: &'static str = "lp_price"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for LpPrice { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct LpToken {} + impl LpToken { + const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetVirtualPrice { - const NAME: &'static str = "get_virtual_price"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 LpToken { + const NAME: &'static str = "lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetVirtualPrice { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct InitialAGamma {} - impl InitialAGamma { - const METHOD_ID: [u8; 4] = [32u8, 79u8, 227u8, 213u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for LpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MaHalfTime {} + impl MaHalfTime { + const METHOD_ID: [u8; 4] = [102u8, 43u8, 98u8, 116u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for MaHalfTime { + const NAME: &'static str = "ma_half_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for MaHalfTime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MidFee {} + impl MidFee { + const METHOD_ID: [u8; 4] = [146u8, 82u8, 108u8, 12u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 InitialAGamma { - const NAME: &'static str = "initial_A_gamma"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 MidFee { + const NAME: &'static str = "mid_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for InitialAGamma { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct InitialAGammaTime {} - impl InitialAGammaTime { - const METHOD_ID: [u8; 4] = [232u8, 152u8, 118u8, 255u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for MidFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OutFee {} + impl OutFee { + const METHOD_ID: [u8; 4] = [238u8, 141u8, 230u8, 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 { + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for OutFee { + const NAME: &'static str = "out_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for OutFee { + 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 InitialAGammaTime { - const NAME: &'static str = "initial_A_gamma_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Owner { + const NAME: &'static str = "owner"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for InitialAGammaTime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsKilled {} - impl IsKilled { - const METHOD_ID: [u8; 4] = [156u8, 134u8, 138u8, 192u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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), + 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 PriceOracle {} + impl PriceOracle { + const METHOD_ID: [u8; 4] = [134u8, 252u8, 136u8, 211u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for PriceOracle { + const NAME: &'static str = "price_oracle"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for PriceOracle { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PriceScale {} + impl PriceScale { + const METHOD_ID: [u8; 4] = [185u8, 232u8, 201u8, 253u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 IsKilled { - const NAME: &'static str = "is_killed"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 PriceScale { + const NAME: &'static str = "price_scale"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsKilled { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct KillDeadline {} - impl KillDeadline { - const METHOD_ID: [u8; 4] = [42u8, 66u8, 104u8, 150u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for PriceScale { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RampAGamma { + pub future_a: substreams::scalar::BigInt, + pub future_gamma: substreams::scalar::BigInt, + pub future_time: substreams::scalar::BigInt, + } + impl RampAGamma { + const METHOD_ID: [u8; 4] = [94u8, 36u8, 128u8, 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(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 { + future_a: { 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 KillDeadline { - const NAME: &'static str = "kill_deadline"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for KillDeadline { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct KillMe {} - impl KillMe { - const METHOD_ID: [u8; 4] = [227u8, 105u8, 136u8, 83u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 KillMe { - const NAME: &'static str = "kill_me"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LastPrices {} - impl LastPrices { - const METHOD_ID: [u8; 4] = [193u8, 70u8, 191u8, 148u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + future_gamma: { 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 LastPrices { - const NAME: &'static str = "last_prices"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for LastPrices { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct LastPricesTimestamp {} - impl LastPricesTimestamp { - const METHOD_ID: [u8; 4] = [97u8, 18u8, 199u8, 71u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + future_time: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.future_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.future_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.future_time.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for LastPricesTimestamp { - const NAME: &'static str = "last_prices_timestamp"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 LastPricesTimestamp { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for RampAGamma { + const NAME: &'static str = "ramp_A_gamma"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct LpPrice {} - impl LpPrice { - const METHOD_ID: [u8; 4] = [84u8, 240u8, 247u8, 213u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + 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 RemoveLiquidity1 { + pub u_amount: substreams::scalar::BigInt, + pub min_amounts: [substreams::scalar::BigInt; 2usize], + } + impl RemoveLiquidity1 { + const METHOD_ID: [u8; 4] = [91u8, 54u8, 56u8, 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::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 { + u_amount: { 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 LpPrice { - const NAME: &'static str = "lp_price"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for LpPrice { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct LpToken {} - impl LpToken { - const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values + }, + min_amounts: { + let mut iter = values .pop() - .expect("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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_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::Uint( + ethabi::Uint::from_big_endian( + match self.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let v = self + .min_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::FixedArray(v) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for LpToken { - const NAME: &'static str = "lp_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() + pub fn 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 LpToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + } + impl substreams_ethereum::Function for RemoveLiquidity1 { + const NAME: &'static str = "remove_liquidity1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct MaHalfTime {} - impl MaHalfTime { - const METHOD_ID: [u8; 4] = [102u8, 43u8, 98u8, 116u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + 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 RemoveLiquidity2 { + pub u_amount: substreams::scalar::BigInt, + pub min_amounts: [substreams::scalar::BigInt; 2usize], + pub use_eth: bool, + } + impl RemoveLiquidity2 { + const METHOD_ID: [u8; 4] = [38u8, 155u8, 85u8, 129u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::Bool, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amount: { 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 - } - } + }, + min_amounts: { + 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)] + }, + use_eth: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let v = self + .min_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::FixedArray(v) + }, + ethabi::Token::Bool(self.use_eth.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 MaHalfTime { - const NAME: &'static str = "ma_half_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RemoveLiquidity2 { + const NAME: &'static str = "remove_liquidity2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for MaHalfTime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct MidFee {} - impl MidFee { - const METHOD_ID: [u8; 4] = [146u8, 82u8, 108u8, 12u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityOneCoin1 { + pub token_amount: substreams::scalar::BigInt, + pub i: substreams::scalar::BigInt, + pub min_amount: substreams::scalar::BigInt, + } + impl RemoveLiquidityOneCoin1 { + const METHOD_ID: [u8; 4] = [241u8, 220u8, 60u8, 201u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_amount: { 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 MidFee { - const NAME: &'static str = "mid_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for MidFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct OutFee {} - impl OutFee { - const METHOD_ID: [u8; 4] = [238u8, 141u8, 230u8, 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 { - 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({ + }, + i: { 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 OutFee { - const NAME: &'static str = "out_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for OutFee { - 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( + }, + min_amount: { + 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(), + .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.token_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + 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(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.min_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::Function for RemoveLiquidityOneCoin1 { + const NAME: &'static str = "remove_liquidity_one_coin1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Owner { - 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 PriceOracle {} - impl PriceOracle { - const METHOD_ID: [u8; 4] = [134u8, 252u8, 136u8, 211u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RemoveLiquidityOneCoin1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityOneCoin2 { + pub token_amount: substreams::scalar::BigInt, + pub i: substreams::scalar::BigInt, + pub min_amount: substreams::scalar::BigInt, + pub use_eth: bool, + } + impl RemoveLiquidityOneCoin2 { + const METHOD_ID: [u8; 4] = [143u8, 21u8, 182u8, 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_amount: { 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 PriceOracle { - const NAME: &'static str = "price_oracle"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for PriceOracle { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PriceScale {} - impl PriceScale { - const METHOD_ID: [u8; 4] = [185u8, 232u8, 201u8, 253u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + i: { 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 PriceScale { - const NAME: &'static str = "price_scale"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for PriceScale { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RampAGamma { - pub future_a: substreams::scalar::BigInt, - pub future_gamma: substreams::scalar::BigInt, - pub future_time: substreams::scalar::BigInt, - } - impl RampAGamma { - const METHOD_ID: [u8; 4] = [94u8, 36u8, 128u8, 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(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 { - future_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) - }, - future_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) - }, - future_time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.future_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") - } + }, + min_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) + }, + use_eth: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.token_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.future_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") - } + ), + 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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.future_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.min_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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, + ), + ethabi::Token::Bool(self.use_eth.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 { + 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 RampAGamma { - const NAME: &'static str = "ramp_A_gamma"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + } + impl substreams_ethereum::Function for RemoveLiquidityOneCoin2 { + const NAME: &'static str = "remove_liquidity_one_coin2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RemoveLiquidityOneCoin2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RevertNewParameters {} + impl RevertNewParameters { + const METHOD_ID: [u8; 4] = [34u8, 104u8, 64u8, 251u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 RevertNewParameters { + const NAME: &'static str = "revert_new_parameters"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 RevertTransferOwnership {} + impl RevertTransferOwnership { + const METHOD_ID: [u8; 4] = [134u8, 251u8, 241u8, 147u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 RevertTransferOwnership { + const NAME: &'static str = "revert_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 SetAdminFeeReceiver { + pub u_admin_fee_receiver: Vec, + } + impl SetAdminFeeReceiver { + const METHOD_ID: [u8; 4] = [114u8, 66u8, 229u8, 36u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_admin_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.u_admin_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, } - fn encode(&self) -> Vec { - self.encode() + } + } + impl substreams_ethereum::Function for SetAdminFeeReceiver { + const NAME: &'static str = "set_admin_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 StopRampAGamma {} + impl StopRampAGamma { + const METHOD_ID: [u8; 4] = [36u8, 76u8, 124u8, 46u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidity1 { - pub u_amount: substreams::scalar::BigInt, - pub min_amounts: [substreams::scalar::BigInt; 2usize], + } + impl substreams_ethereum::Function for StopRampAGamma { + const NAME: &'static str = "stop_ramp_A_gamma"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl RemoveLiquidity1 { - const METHOD_ID: [u8; 4] = [91u8, 54u8, 56u8, 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()); + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Token {} + impl Token { + const METHOD_ID: [u8; 4] = [252u8, 12u8, 84u8, 106u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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::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 { - u_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) - }, - min_amounts: { - 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::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - { - let v = self - .min_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::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 Token { + const NAME: &'static str = "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 Token { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferOwnershipDeadline {} + impl TransferOwnershipDeadline { + const METHOD_ID: [u8; 4] = [224u8, 160u8, 181u8, 134u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 RemoveLiquidity1 { - const NAME: &'static str = "remove_liquidity1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 TransferOwnershipDeadline { + const NAME: &'static str = "transfer_ownership_deadline"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidity2 { - pub u_amount: substreams::scalar::BigInt, - pub min_amounts: [substreams::scalar::BigInt; 2usize], - pub use_eth: bool, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl RemoveLiquidity2 { - const METHOD_ID: [u8; 4] = [38u8, 155u8, 85u8, 129u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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) - }, - min_amounts: { - 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), - ] - }, - use_eth: values + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TransferOwnershipDeadline { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UnderlyingCoins { + pub arg0: substreams::scalar::BigInt, + } + impl UnderlyingCoins { + const METHOD_ID: [u8; 4] = [183u8, 57u8, 149u8, 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::Int(128usize)], + 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_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.arg0.to_signed_bytes_be(); + let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 + == 0x80 { - let v = self - .min_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::FixedArray(v) - }, - ethabi::Token::Bool(self.use_eth.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, + 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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for RemoveLiquidity2 { - const NAME: &'static str = "remove_liquidity2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + } + impl substreams_ethereum::Function for UnderlyingCoins { + const NAME: &'static str = "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 UnderlyingCoins { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UnkillMe {} + impl UnkillMe { + const METHOD_ID: [u8; 4] = [48u8, 70u8, 249u8, 114u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 UnkillMe { + const NAME: &'static str = "unkill_me"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 VirtualPrice {} + impl VirtualPrice { + const METHOD_ID: [u8; 4] = [12u8, 70u8, 183u8, 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 { + 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 + } } - fn encode(&self) -> Vec { - self.encode() + } + } + impl substreams_ethereum::Function for VirtualPrice { + const NAME: &'static str = "virtual_price"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for VirtualPrice { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct XcpProfit {} + impl XcpProfit { + const METHOD_ID: [u8; 4] = [123u8, 161u8, 167u8, 77u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidityOneCoin1 { - pub token_amount: substreams::scalar::BigInt, - pub i: substreams::scalar::BigInt, - pub min_amount: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for XcpProfit { + const NAME: &'static str = "xcp_profit"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for XcpProfit { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl RemoveLiquidityOneCoin1 { - const METHOD_ID: [u8; 4] = [241u8, 220u8, 60u8, 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct XcpProfitA {} + impl XcpProfitA { + const METHOD_ID: [u8; 4] = [11u8, 123u8, 89u8, 75u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - let mut values = ethabi::decode( - &[ - 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 { - token_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) - }, - 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) - }, - min_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for XcpProfitA { + const NAME: &'static str = "xcp_profit_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 XcpProfitA { + 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 AddLiquidity1 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 2usize], + pub fee: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl AddLiquidity1 { + const TOPIC_ID: [u8; 32] = [ + 84u8, + 10u8, + 179u8, + 133u8, + 249u8, + 181u8, + 212u8, + 80u8, + 162u8, + 116u8, + 4u8, + 23u8, + 44u8, + 170u8, + 222u8, + 81u8, + 107u8, + 59u8, + 163u8, + 244u8, + 190u8, + 136u8, + 35u8, + 154u8, + 197u8, + 106u8, + 42u8, + 209u8, + 222u8, + 42u8, + 31u8, + 90u8, + ]; + 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::Token::Uint( - ethabi::Uint::from_big_endian( - match self.token_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - 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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.min_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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(), + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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)] + }, + fee: { 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 RemoveLiquidityOneCoin1 { - const NAME: &'static str = "remove_liquidity_one_coin1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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::rpc::RPCDecodable - for RemoveLiquidityOneCoin1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Event for AddLiquidity1 { + const NAME: &'static str = "AddLiquidity1"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidityOneCoin2 { - pub token_amount: substreams::scalar::BigInt, - pub i: substreams::scalar::BigInt, - pub min_amount: substreams::scalar::BigInt, - pub use_eth: bool, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl RemoveLiquidityOneCoin2 { - const METHOD_ID: [u8; 4] = [143u8, 21u8, 182u8, 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - token_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) - }, - 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) - }, - min_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) - }, - use_eth: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity2 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 3usize], + pub fee: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl AddLiquidity2 { + const TOPIC_ID: [u8; 32] = [ + 150u8, + 180u8, + 134u8, + 72u8, + 84u8, + 32u8, + 185u8, + 99u8, + 237u8, + 211u8, + 253u8, + 236u8, + 11u8, + 1u8, + 149u8, + 115u8, + 0u8, + 53u8, + 96u8, + 15u8, + 235u8, + 125u8, + 230u8, + 245u8, + 68u8, + 56u8, + 61u8, + 121u8, + 80u8, + 250u8, + 151u8, + 238u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Token::Uint( - ethabi::Uint::from_big_endian( - match self.token_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, ), - 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(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.min_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Bool(self.use_eth.clone()), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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(), + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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), + ] + }, + fee: { 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 RemoveLiquidityOneCoin2 { - const NAME: &'static str = "remove_liquidity_one_coin2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for RemoveLiquidityOneCoin2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RevertNewParameters {} - impl RevertNewParameters { - const METHOD_ID: [u8; 4] = [34u8, 104u8, 64u8, 251u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 RevertNewParameters { - const NAME: &'static str = "revert_new_parameters"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 RevertTransferOwnership {} - impl RevertTransferOwnership { - const METHOD_ID: [u8; 4] = [134u8, 251u8, 241u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 RevertTransferOwnership { - const NAME: &'static str = "revert_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 SetAdminFeeReceiver { - pub u_admin_fee_receiver: Vec, - } - impl SetAdminFeeReceiver { - const METHOD_ID: [u8; 4] = [114u8, 66u8, 229u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_admin_fee_receiver: values + }, + token_supply: { + 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.u_admin_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, - } - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Function for SetAdminFeeReceiver { - const NAME: &'static str = "set_admin_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 StopRampAGamma {} - impl StopRampAGamma { - const METHOD_ID: [u8; 4] = [36u8, 76u8, 124u8, 46u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 AddLiquidity2 { + const NAME: &'static str = "AddLiquidity2"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::Function for StopRampAGamma { - const NAME: &'static str = "stop_ramp_A_gamma"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct Token {} - impl Token { - const METHOD_ID: [u8; 4] = [252u8, 12u8, 84u8, 106u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity3 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 2usize], + pub fees: [substreams::scalar::BigInt; 2usize], + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl AddLiquidity3 { + const TOPIC_ID: [u8; 32] = [ + 38u8, + 245u8, + 90u8, + 133u8, + 8u8, + 29u8, + 36u8, + 151u8, + 78u8, + 133u8, + 198u8, + 192u8, + 0u8, + 69u8, + 208u8, + 240u8, + 69u8, + 57u8, + 145u8, + 233u8, + 88u8, + 115u8, + 245u8, + 43u8, + 255u8, + 13u8, + 33u8, + 175u8, + 64u8, + 121u8, + 167u8, + 104u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + 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 { + provider: ethabi::decode( &[ethabi::ParamType::Address], - data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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)] + }, + fees: { + 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)] + }, + invariant: { + 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 Token { - const NAME: &'static str = "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 Token { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferOwnershipDeadline {} - impl TransferOwnershipDeadline { - const METHOD_ID: [u8; 4] = [224u8, 160u8, 181u8, 134u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + token_supply: { 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 TransferOwnershipDeadline { - const NAME: &'static str = "transfer_ownership_deadline"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + }, + }) } - impl substreams_ethereum::rpc::RPCDecodable - for TransferOwnershipDeadline { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Event for AddLiquidity3 { + const NAME: &'static str = "AddLiquidity3"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct UnderlyingCoins { - pub arg0: substreams::scalar::BigInt, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl UnderlyingCoins { - const METHOD_ID: [u8; 4] = [183u8, 57u8, 149u8, 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::Int(128usize)], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity4 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 3usize], + pub fees: [substreams::scalar::BigInt; 3usize], + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl AddLiquidity4 { + const TOPIC_ID: [u8; 32] = [ + 66u8, + 63u8, + 100u8, + 149u8, + 160u8, + 143u8, + 198u8, + 82u8, + 66u8, + 92u8, + 244u8, + 237u8, + 13u8, + 31u8, + 158u8, + 55u8, + 229u8, + 113u8, + 217u8, + 185u8, + 82u8, + 155u8, + 28u8, + 28u8, + 35u8, + 204u8, + 231u8, + 128u8, + 178u8, + 231u8, + 223u8, + 13u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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( &[ - { - let non_full_signed_bytes = self.arg0.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()), - ) - }, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( &[ethabi::ParamType::Address], - data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + let mut iter = values .pop() - .expect("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for UnderlyingCoins { - const NAME: &'static str = "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 UnderlyingCoins { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UnkillMe {} - impl UnkillMe { - const METHOD_ID: [u8; 4] = [48u8, 70u8, 249u8, 114u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 UnkillMe { - const NAME: &'static str = "unkill_me"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 VirtualPrice {} - impl VirtualPrice { - const METHOD_ID: [u8; 4] = [12u8, 70u8, 183u8, 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 { - 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({ + .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), + ] + }, + fees: { + 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), + ] + }, + invariant: { 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 VirtualPrice { - const NAME: &'static str = "virtual_price"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for VirtualPrice { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct XcpProfit {} - impl XcpProfit { - const METHOD_ID: [u8; 4] = [123u8, 161u8, 167u8, 77u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + token_supply: { 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 XcpProfit { - const NAME: &'static str = "xcp_profit"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Event for AddLiquidity4 { + const NAME: &'static str = "AddLiquidity4"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable - for XcpProfit { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct XcpProfitA {} - impl XcpProfitA { - const METHOD_ID: [u8; 4] = [11u8, 123u8, 89u8, 75u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity5 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 4usize], + pub fees: [substreams::scalar::BigInt; 4usize], + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl AddLiquidity5 { + const TOPIC_ID: [u8; 32] = [ + 63u8, + 25u8, + 21u8, + 119u8, + 94u8, + 12u8, + 154u8, + 56u8, + 165u8, + 122u8, + 123u8, + 183u8, + 241u8, + 249u8, + 0u8, + 95u8, + 72u8, + 111u8, + 185u8, + 4u8, + 225u8, + 248u8, + 74u8, + 162u8, + 21u8, + 54u8, + 77u8, + 86u8, + 115u8, + 25u8, + 165u8, + 141u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 320usize { + 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::Uint(256usize)), + 4usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 4usize, + ), + 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 { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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), + ] + }, + fees: { + 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), + ] + }, + invariant: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + token_supply: { 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 XcpProfitA { - const NAME: &'static str = "xcp_profit_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 XcpProfitA { - 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 AddLiquidity1 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fee: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl AddLiquidity1 { - const TOPIC_ID: [u8; 32] = [ - 84u8, - 10u8, - 179u8, - 133u8, - 249u8, - 181u8, - 212u8, - 80u8, - 162u8, - 116u8, - 4u8, - 23u8, - 44u8, - 170u8, - 222u8, - 81u8, - 107u8, - 59u8, - 163u8, - 244u8, - 190u8, - 136u8, - 35u8, - 154u8, - 197u8, - 106u8, - 42u8, - 209u8, - 222u8, - 42u8, - 31u8, - 90u8, - ]; - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + } + impl substreams_ethereum::Event for AddLiquidity5 { + const NAME: &'static str = "AddLiquidity5"; + 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 AddLiquidity6 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 2usize], + pub fee: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + pub packed_price_scale: substreams::scalar::BigInt, + } + impl AddLiquidity6 { + const TOPIC_ID: [u8; 32] = [ + 113u8, + 150u8, + 203u8, + 246u8, + 61u8, + 241u8, + 242u8, + 236u8, + 32u8, + 99u8, + 142u8, + 104u8, + 62u8, + 190u8, + 81u8, + 209u8, + 130u8, + 96u8, + 190u8, + 81u8, + 5u8, + 146u8, + 238u8, + 30u8, + 46u8, + 254u8, + 63u8, + 60u8, + 253u8, + 76u8, + 51u8, + 233u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fee: { + .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)] + }, + 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) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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_price_scale: { + let mut v = [0 as u8; 32]; + values + .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 AddLiquidity6 { + const NAME: &'static str = "AddLiquidity6"; + 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 AddLiquidity7 { + pub provider: Vec, + pub token_amounts: Vec, + pub fees: Vec, + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl AddLiquidity7 { + const TOPIC_ID: [u8; 32] = [ + 24u8, + 156u8, + 98u8, + 59u8, + 102u8, + 107u8, + 27u8, + 69u8, + 184u8, + 61u8, + 113u8, + 120u8, + 243u8, + 155u8, + 140u8, + 8u8, + 124u8, + 176u8, + 151u8, + 116u8, + 49u8, + 124u8, + 162u8, + 245u8, + 60u8, + 45u8, + 60u8, + 55u8, + 38u8, + 242u8, + 34u8, + 162u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize)), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: 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) - }, - token_supply: { + }) + .collect(), + fees: 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) - }, - }) - } - } - impl substreams_ethereum::Event for AddLiquidity1 { - const NAME: &'static str = "AddLiquidity1"; - 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 AddLiquidity2 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 3usize], - pub fee: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl AddLiquidity2 { - const TOPIC_ID: [u8; 32] = [ - 150u8, - 180u8, - 134u8, - 72u8, - 84u8, - 32u8, - 185u8, - 99u8, - 237u8, - 211u8, - 253u8, - 236u8, - 11u8, - 1u8, - 149u8, - 115u8, - 0u8, - 53u8, - 96u8, - 15u8, - 235u8, - 125u8, - 230u8, - 245u8, - 68u8, - 56u8, - 61u8, - 121u8, - 80u8, - 250u8, - 151u8, - 238u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + }) + .collect(), + invariant: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 AddLiquidity7 { + const NAME: &'static str = "AddLiquidity7"; + 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 ApplyNewFee1 { + pub fee: substreams::scalar::BigInt, + } + impl ApplyNewFee1 { + const TOPIC_ID: [u8; 32] = [ + 168u8, + 113u8, + 87u8, + 112u8, + 101u8, + 79u8, + 84u8, + 96u8, + 57u8, + 71u8, + 173u8, + 223u8, + 56u8, + 198u8, + 137u8, + 173u8, + 189u8, + 113u8, + 130u8, + 226u8, + 22u8, + 115u8, + 178u8, + 139u8, + 207u8, + 48u8, + 106u8, + 149u8, + 122u8, + 171u8, + 162u8, + 21u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + 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) + }, + }) + } + } + impl substreams_ethereum::Event for ApplyNewFee1 { + const NAME: &'static str = "ApplyNewFee1"; + 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 ApplyNewFee2 { + pub fee: substreams::scalar::BigInt, + pub offpeg_fee_multiplier: substreams::scalar::BigInt, + } + impl ApplyNewFee2 { + const TOPIC_ID: [u8; 32] = [ + 117u8, + 13u8, + 16u8, + 167u8, + 243u8, + 116u8, + 102u8, + 206u8, + 120u8, + 94u8, + 230u8, + 188u8, + 182u8, + 4u8, + 170u8, + 197u8, + 67u8, + 53u8, + 141u8, + 180u8, + 42u8, + 251u8, + 204u8, + 51u8, + 42u8, + 60u8, + 18u8, + 164u8, + 156u8, + 128u8, + 191u8, + 109u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + 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) + }, + }) + } + } + impl substreams_ethereum::Event for ApplyNewFee2 { + const NAME: &'static str = "ApplyNewFee2"; + 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 ClaimAdminFee { + pub admin: Vec, + pub tokens: substreams::scalar::BigInt, + } + impl ClaimAdminFee { + const TOPIC_ID: [u8; 32] = [ + 96u8, + 89u8, + 163u8, + 129u8, + 152u8, + 177u8, + 220u8, + 66u8, + 179u8, + 121u8, + 16u8, + 135u8, + 209u8, + 255u8, + 15u8, + 189u8, + 114u8, + 179u8, + 23u8, + 149u8, + 83u8, + 194u8, + 95u8, + 103u8, + 140u8, + 210u8, + 70u8, + 245u8, + 47u8, + 250u8, + 175u8, + 89u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + admin: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], + .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(), + tokens: { + let mut v = [0 as u8; 32]; + values + .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 ClaimAdminFee { + const NAME: &'static str = "ClaimAdminFee"; + 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 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 'provider' from topic of type 'address': {:?}", + "unable to decode param 'deadline' from topic of type 'uint256': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - 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) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 AddLiquidity2 { - const NAME: &'static str = "AddLiquidity2"; - 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 AddLiquidity3 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fees: [substreams::scalar::BigInt; 2usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl AddLiquidity3 { - const TOPIC_ID: [u8; 32] = [ - 38u8, - 245u8, - 90u8, - 133u8, - 8u8, - 29u8, - 36u8, - 151u8, - 78u8, - 133u8, - 198u8, - 192u8, - 0u8, - 69u8, - 208u8, - 240u8, - 69u8, - 57u8, - 145u8, - 233u8, - 88u8, - 115u8, - 245u8, - 43u8, - 255u8, - 13u8, - 33u8, - 175u8, - 64u8, - 121u8, - 167u8, - 104u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .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 log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], + .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 CommitNewParameters { + pub deadline: substreams::scalar::BigInt, + pub admin_fee: 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_half_time: substreams::scalar::BigInt, + } + impl CommitNewParameters { + const TOPIC_ID: [u8; 32] = [ + 145u8, + 63u8, + 222u8, + 154u8, + 55u8, + 225u8, + 248u8, + 171u8, + 103u8, + 135u8, + 106u8, + 77u8, + 12u8, + 232u8, + 7u8, + 144u8, + 215u8, + 100u8, + 252u8, + 252u8, + 86u8, + 146u8, + 244u8, + 82u8, + 149u8, + 38u8, + 223u8, + 156u8, + 107u8, + 221u8, + 229u8, + 83u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::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), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + 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 'provider' from topic of type 'address': {:?}", + "unable to decode param 'deadline' from topic of type 'uint256': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 AddLiquidity3 { - const NAME: &'static str = "AddLiquidity3"; - 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 AddLiquidity4 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 3usize], - pub fees: [substreams::scalar::BigInt; 3usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl AddLiquidity4 { - const TOPIC_ID: [u8; 32] = [ - 66u8, - 63u8, - 100u8, - 149u8, - 160u8, - 143u8, - 198u8, - 82u8, - 66u8, - 92u8, - 244u8, - 237u8, - 13u8, - 31u8, - 158u8, - 55u8, - 229u8, - 113u8, - 217u8, - 185u8, - 82u8, - 155u8, - 28u8, - 28u8, - 35u8, - 204u8, - 231u8, - 128u8, - 178u8, - 231u8, - 223u8, - 13u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - 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 { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 AddLiquidity4 { - const NAME: &'static str = "AddLiquidity4"; - 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 AddLiquidity5 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 4usize], - pub fees: [substreams::scalar::BigInt; 4usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl AddLiquidity5 { - const TOPIC_ID: [u8; 32] = [ - 63u8, - 25u8, - 21u8, - 119u8, - 94u8, - 12u8, - 154u8, - 56u8, - 165u8, - 122u8, - 123u8, - 183u8, - 241u8, - 249u8, - 0u8, - 95u8, - 72u8, - 111u8, - 185u8, - 4u8, - 225u8, - 248u8, - 74u8, - 162u8, - 21u8, - 54u8, - 77u8, - 86u8, - 115u8, - 25u8, - 165u8, - 141u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 320usize { - 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::Uint(256usize)), - 4usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 4usize, - ), - 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 { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .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(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 AddLiquidity5 { - const NAME: &'static str = "AddLiquidity5"; - 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 AddLiquidity6 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fee: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - pub packed_price_scale: substreams::scalar::BigInt, - } - impl AddLiquidity6 { - const TOPIC_ID: [u8; 32] = [ - 113u8, - 150u8, - 203u8, - 246u8, - 61u8, - 241u8, - 242u8, - 236u8, - 32u8, - 99u8, - 142u8, - 104u8, - 62u8, - 190u8, - 81u8, - 209u8, - 130u8, - 96u8, - 190u8, - 81u8, - 5u8, - 146u8, - 238u8, - 30u8, - 46u8, - 254u8, - 63u8, - 60u8, - 253u8, - 76u8, - 51u8, - 233u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - 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) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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_price_scale: { - let mut v = [0 as u8; 32]; - values - .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 AddLiquidity6 { - const NAME: &'static str = "AddLiquidity6"; - 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 AddLiquidity7 { - pub provider: Vec, - pub token_amounts: Vec, - pub fees: Vec, - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl AddLiquidity7 { - const TOPIC_ID: [u8; 32] = [ - 24u8, - 156u8, - 98u8, - 59u8, - 102u8, - 107u8, - 27u8, - 69u8, - 184u8, - 61u8, - 113u8, - 120u8, - 243u8, - 155u8, - 140u8, - 8u8, - 124u8, - 176u8, - 151u8, - 116u8, - 49u8, - 124u8, - 162u8, - 245u8, - 60u8, - 45u8, - 60u8, - 55u8, - 38u8, - 242u8, - 34u8, - 162u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize)), - ), - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Uint(256usize)), - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: values + .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_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(), - fees: values + .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_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(), - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 AddLiquidity7 { - const NAME: &'static str = "AddLiquidity7"; - 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 ApplyNewFee1 { - pub fee: substreams::scalar::BigInt, - } - impl ApplyNewFee1 { - const TOPIC_ID: [u8; 32] = [ - 168u8, - 113u8, - 87u8, - 112u8, - 101u8, - 79u8, - 84u8, - 96u8, - 57u8, - 71u8, - 173u8, - 223u8, - 56u8, - 198u8, - 137u8, - 173u8, - 189u8, - 113u8, - 130u8, - 226u8, - 22u8, - 115u8, - 178u8, - 139u8, - 207u8, - 48u8, - 106u8, - 149u8, - 122u8, - 171u8, - 162u8, - 21u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - }) - } - } - impl substreams_ethereum::Event for ApplyNewFee1 { - const NAME: &'static str = "ApplyNewFee1"; - 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 ApplyNewFee2 { - pub fee: substreams::scalar::BigInt, - pub offpeg_fee_multiplier: substreams::scalar::BigInt, - } - impl ApplyNewFee2 { - const TOPIC_ID: [u8; 32] = [ - 117u8, - 13u8, - 16u8, - 167u8, - 243u8, - 116u8, - 102u8, - 206u8, - 120u8, - 94u8, - 230u8, - 188u8, - 182u8, - 4u8, - 170u8, - 197u8, - 67u8, - 53u8, - 141u8, - 180u8, - 42u8, - 251u8, - 204u8, - 51u8, - 42u8, - 60u8, - 18u8, - 164u8, - 156u8, - 128u8, - 191u8, - 109u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - }) - } - } - impl substreams_ethereum::Event for ApplyNewFee2 { - const NAME: &'static str = "ApplyNewFee2"; - 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 ClaimAdminFee { - pub admin: Vec, - pub tokens: substreams::scalar::BigInt, - } - impl ClaimAdminFee { - const TOPIC_ID: [u8; 32] = [ - 96u8, - 89u8, - 163u8, - 129u8, - 152u8, - 177u8, - 220u8, - 66u8, - 179u8, - 121u8, - 16u8, - 135u8, - 209u8, - 255u8, - 15u8, - 189u8, - 114u8, - 179u8, - 23u8, - 149u8, - 83u8, - 194u8, - 95u8, - 103u8, - 140u8, - 210u8, - 70u8, - 245u8, - 47u8, - 250u8, - 175u8, - 89u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 32usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), + .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) + }, + }) + } + } + impl substreams_ethereum::Event for CommitNewParameters { + const NAME: &'static str = "CommitNewParameters"; + 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 log.data: {:?}", e))?; - values.reverse(); - 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 ) - .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) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct NewFee1 { + pub fee: substreams::scalar::BigInt, + pub admin_fee: substreams::scalar::BigInt, + } + impl NewFee1 { + const TOPIC_ID: [u8; 32] = [ + 190u8, + 18u8, + 133u8, + 155u8, + 99u8, + 106u8, + 237u8, + 96u8, + 125u8, + 82u8, + 48u8, + 178u8, + 204u8, + 39u8, + 17u8, + 246u8, + 141u8, + 112u8, + 229u8, + 16u8, + 96u8, + 230u8, + 204u8, + 161u8, + 245u8, + 117u8, + 239u8, + 93u8, + 47u8, + 204u8, + 149u8, + 209u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - tokens: { - let mut v = [0 as u8; 32]; - values - .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 ClaimAdminFee { - const NAME: &'static str = "ClaimAdminFee"; - 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 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 - ) - })? + .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) + }, + }) + } + } + impl substreams_ethereum::Event for NewFee1 { + const NAME: &'static str = "NewFee1"; + 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 NewFee2 { + pub fee: substreams::scalar::BigInt, + pub admin_fee: substreams::scalar::BigInt, + pub offpeg_fee_multiplier: substreams::scalar::BigInt, + } + impl NewFee2 { + const TOPIC_ID: [u8; 32] = [ + 207u8, + 202u8, + 150u8, + 224u8, + 254u8, + 243u8, + 67u8, + 33u8, + 70u8, + 145u8, + 59u8, + 42u8, + 90u8, + 34u8, + 104u8, + 165u8, + 93u8, + 63u8, + 71u8, + 95u8, + 224u8, + 87u8, + 231u8, + 255u8, + 222u8, + 16u8, + 130u8, + 183u8, + 118u8, + 147u8, + 244u8, + 243u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + 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) + }, + 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) + }, + 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) + }, + }) + } + } + impl substreams_ethereum::Event for NewFee2 { + const NAME: &'static str = "NewFee2"; + 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 NewParameters1 { + pub a: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub admin_fee: substreams::scalar::BigInt, + } + impl NewParameters1 { + const TOPIC_ID: [u8; 32] = [ + 117u8, + 42u8, + 39u8, + 209u8, + 133u8, + 62u8, + 183u8, + 175u8, + 62u8, + 228u8, + 255u8, + 118u8, + 79u8, + 44u8, + 74u8, + 81u8, + 97u8, + 147u8, + 134u8, + 175u8, + 114u8, + 21u8, + 115u8, + 221u8, + 56u8, + 9u8, + 233u8, + 41u8, + 195u8, + 157u8, + 185u8, + 158u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + 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) + }, + 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) + }, + }) + } + } + impl substreams_ethereum::Event for NewParameters1 { + const NAME: &'static str = "NewParameters1"; + 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 NewParameters2 { + 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_time: substreams::scalar::BigInt, + } + impl NewParameters2 { + const TOPIC_ID: [u8; 32] = [ + 163u8, + 33u8, + 55u8, + 65u8, + 31u8, + 199u8, + 194u8, + 13u8, + 179u8, + 89u8, + 7u8, + 156u8, + 216u8, + 74u8, + 240u8, + 226u8, + 202u8, + 213u8, + 140u8, + 215u8, + 161u8, + 130u8, + 168u8, + 165u8, + 226u8, + 62u8, + 8u8, + 229u8, + 84u8, + 232u8, + 139u8, + 240u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + 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_time: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for NewParameters2 { + const NAME: &'static str = "NewParameters2"; + 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 NewParameters3 { + pub admin_fee: 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_half_time: substreams::scalar::BigInt, + } + impl NewParameters3 { + const TOPIC_ID: [u8; 32] = [ + 28u8, + 101u8, + 187u8, + 220u8, + 147u8, + 159u8, + 52u8, + 110u8, + 93u8, + 111u8, + 11u8, + 222u8, + 31u8, + 7u8, + 40u8, + 25u8, + 148u8, + 116u8, + 56u8, + 212u8, + 252u8, + 123u8, + 24u8, + 44u8, + 197u8, + 156u8, + 47u8, + 109u8, + 197u8, + 80u8, + 64u8, + 135u8, + ]; + 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::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), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + 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) + }, + 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_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) + }, + }) + } + } + impl substreams_ethereum::Event for NewParameters3 { + const NAME: &'static str = "NewParameters3"; + 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 NewParameters4 { + 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_time: substreams::scalar::BigInt, + pub xcp_ma_time: substreams::scalar::BigInt, + } + impl NewParameters4 { + const TOPIC_ID: [u8; 32] = [ + 28u8, + 101u8, + 187u8, + 220u8, + 147u8, + 159u8, + 52u8, + 110u8, + 93u8, + 111u8, + 11u8, + 222u8, + 31u8, + 7u8, + 40u8, + 25u8, + 148u8, + 116u8, + 56u8, + 212u8, + 252u8, + 123u8, + 24u8, + 44u8, + 197u8, + 156u8, + 47u8, + 109u8, + 197u8, + 80u8, + 64u8, + 135u8, + ]; + 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::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), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + 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_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) + }, + xcp_ma_time: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for NewParameters4 { + const NAME: &'static str = "NewParameters4"; + 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 RampAgamma { + pub initial_a: substreams::scalar::BigInt, + pub future_a: substreams::scalar::BigInt, + pub initial_gamma: substreams::scalar::BigInt, + pub future_gamma: substreams::scalar::BigInt, + pub initial_time: substreams::scalar::BigInt, + pub future_time: substreams::scalar::BigInt, + } + impl RampAgamma { + const TOPIC_ID: [u8; 32] = [ + 227u8, + 95u8, + 5u8, + 89u8, + 176u8, + 100u8, + 33u8, + 100u8, + 226u8, + 134u8, + 179u8, + 13u8, + 242u8, + 7u8, + 126u8, + 195u8, + 160u8, + 84u8, + 38u8, + 97u8, + 122u8, + 37u8, + 219u8, + 117u8, + 120u8, + 253u8, + 32u8, + 186u8, + 57u8, + 166u8, + 205u8, + 5u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + initial_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) + }, + future_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) + }, + initial_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) + }, + future_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) + }, + initial_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) + }, + future_time: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for RampAgamma { + const NAME: &'static str = "RampAgamma"; + 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 RemoveLiquidity1 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 2usize], + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidity1 { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 60u8, + 3u8, + 54u8, + 161u8, + 111u8, + 27u8, + 100u8, + 241u8, + 114u8, + 183u8, + 187u8, + 13u8, + 173u8, + 91u8, + 43u8, + 60u8, + 124u8, + 118u8, + 249u8, + 30u8, + 140u8, + 74u8, + 175u8, + 214u8, + 170u8, + 230u8, + 13u8, + 206u8, + 128u8, + 1u8, + 83u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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)] + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidity1 { + const NAME: &'static str = "RemoveLiquidity1"; + 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 RemoveLiquidity2 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 3usize], + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidity2 { + const TOPIC_ID: [u8; 32] = [ + 214u8, + 204u8, + 49u8, + 74u8, + 11u8, + 30u8, + 59u8, + 37u8, + 121u8, + 248u8, + 230u8, + 66u8, + 72u8, + 232u8, + 36u8, + 52u8, + 7u8, + 46u8, + 130u8, + 113u8, + 41u8, + 14u8, + 239u8, + 138u8, + 208u8, + 136u8, + 103u8, + 9u8, + 48u8, + 65u8, + 149u8, + 245u8, + ]; + 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::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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), + ] + }, + token_supply: { + let mut v = [0 as u8; 32]; + values .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 CommitNewParameters { - pub deadline: substreams::scalar::BigInt, - pub admin_fee: 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_half_time: substreams::scalar::BigInt, - } - impl CommitNewParameters { - const TOPIC_ID: [u8; 32] = [ - 145u8, - 63u8, - 222u8, - 154u8, - 55u8, - 225u8, - 248u8, - 171u8, - 103u8, - 135u8, - 106u8, - 77u8, - 12u8, - 232u8, - 7u8, - 144u8, - 215u8, - 100u8, - 252u8, - 252u8, - 86u8, - 146u8, - 244u8, - 82u8, - 149u8, - 38u8, - 223u8, - 156u8, - 107u8, - 221u8, - 229u8, - 83u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::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), - ], - log.data.as_ref(), + .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 RemoveLiquidity2 { + const NAME: &'static str = "RemoveLiquidity2"; + 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 RemoveLiquidity3 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 2usize], + pub fees: [substreams::scalar::BigInt; 2usize], + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidity3 { + const TOPIC_ID: [u8; 32] = [ + 124u8, + 54u8, + 56u8, + 84u8, + 204u8, + 247u8, + 150u8, + 35u8, + 65u8, + 31u8, + 137u8, + 149u8, + 179u8, + 98u8, + 188u8, + 229u8, + 237u8, + 223u8, + 241u8, + 140u8, + 146u8, + 126u8, + 220u8, + 111u8, + 93u8, + 187u8, + 181u8, + 224u8, + 88u8, + 25u8, + 168u8, + 44u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - 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_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) - }, - 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_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) - }, - }) - } - } - impl substreams_ethereum::Event for CommitNewParameters { - const NAME: &'static str = "CommitNewParameters"; - 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 'provider' from topic of type 'address': {:?}", + e ) - .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(), + token_amounts: { + let mut iter = values .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) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct NewFee1 { - pub fee: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - } - impl NewFee1 { - const TOPIC_ID: [u8; 32] = [ - 190u8, - 18u8, - 133u8, - 155u8, - 99u8, - 106u8, - 237u8, - 96u8, - 125u8, - 82u8, - 48u8, - 178u8, - 204u8, - 39u8, - 17u8, - 246u8, - 141u8, - 112u8, - 229u8, - 16u8, - 96u8, - 230u8, - 204u8, - 161u8, - 245u8, - 117u8, - 239u8, - 93u8, - 47u8, - 204u8, - 149u8, - 209u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - 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) - }, - }) - } - } - impl substreams_ethereum::Event for NewFee1 { - const NAME: &'static str = "NewFee1"; - 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 NewFee2 { - pub fee: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - pub offpeg_fee_multiplier: substreams::scalar::BigInt, - } - impl NewFee2 { - const TOPIC_ID: [u8; 32] = [ - 207u8, - 202u8, - 150u8, - 224u8, - 254u8, - 243u8, - 67u8, - 33u8, - 70u8, - 145u8, - 59u8, - 42u8, - 90u8, - 34u8, - 104u8, - 165u8, - 93u8, - 63u8, - 71u8, - 95u8, - 224u8, - 87u8, - 231u8, - 255u8, - 222u8, - 16u8, - 130u8, - 183u8, - 118u8, - 147u8, - 244u8, - 243u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .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)] + }, + fees: { + 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)] + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidity3 { + const NAME: &'static str = "RemoveLiquidity3"; + 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 RemoveLiquidity4 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 3usize], + pub fees: [substreams::scalar::BigInt; 3usize], + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidity4 { + const TOPIC_ID: [u8; 32] = [ + 164u8, + 157u8, + 76u8, + 240u8, + 38u8, + 86u8, + 174u8, + 191u8, + 140u8, + 119u8, + 31u8, + 90u8, + 133u8, + 133u8, + 99u8, + 138u8, + 42u8, + 21u8, + 238u8, + 108u8, + 151u8, + 207u8, + 114u8, + 5u8, + 212u8, + 32u8, + 142u8, + 215u8, + 193u8, + 223u8, + 37u8, + 45u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - 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) - }, - 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) - }, - }) - } - } - impl substreams_ethereum::Event for NewFee2 { - const NAME: &'static str = "NewFee2"; - 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 NewParameters1 { - pub a: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - } - impl NewParameters1 { - const TOPIC_ID: [u8; 32] = [ - 117u8, - 42u8, - 39u8, - 209u8, - 133u8, - 62u8, - 183u8, - 175u8, - 62u8, - 228u8, - 255u8, - 118u8, - 79u8, - 44u8, - 74u8, - 81u8, - 97u8, - 147u8, - 134u8, - 175u8, - 114u8, - 21u8, - 115u8, - 221u8, - 56u8, - 9u8, - 233u8, - 41u8, - 195u8, - 157u8, - 185u8, - 158u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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), + ] + }, + fees: { + 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), + ] + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidity4 { + const NAME: &'static str = "RemoveLiquidity4"; + 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 RemoveLiquidity5 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 4usize], + pub fees: [substreams::scalar::BigInt; 4usize], + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidity5 { + const TOPIC_ID: [u8; 32] = [ + 152u8, + 120u8, + 202u8, + 55u8, + 94u8, + 16u8, + 111u8, + 42u8, + 67u8, + 195u8, + 181u8, + 153u8, + 252u8, + 98u8, + 69u8, + 104u8, + 19u8, + 28u8, + 76u8, + 154u8, + 75u8, + 166u8, + 106u8, + 20u8, + 86u8, + 55u8, + 21u8, + 118u8, + 59u8, + 233u8, + 213u8, + 157u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 288usize { + 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::Uint(256usize)), + 4usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 4usize, + ), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - 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) - }, - }) - } - } - impl substreams_ethereum::Event for NewParameters1 { - const NAME: &'static str = "NewParameters1"; - 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 NewParameters2 { - 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_time: substreams::scalar::BigInt, - } - impl NewParameters2 { - const TOPIC_ID: [u8; 32] = [ - 163u8, - 33u8, - 55u8, - 65u8, - 31u8, - 199u8, - 194u8, - 13u8, - 179u8, - 89u8, - 7u8, - 156u8, - 216u8, - 74u8, - 240u8, - 226u8, - 202u8, - 213u8, - 140u8, - 215u8, - 161u8, - 130u8, - 168u8, - 165u8, - 226u8, - 62u8, - 8u8, - 229u8, - 84u8, - 232u8, - 139u8, - 240u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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), + ] + }, + fees: { + 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), + ] + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidity5 { + const NAME: &'static str = "RemoveLiquidity5"; + 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 RemoveLiquidity6 { + pub provider: Vec, + pub token_amounts: Vec, + pub fees: Vec, + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidity6 { + const TOPIC_ID: [u8; 32] = [ + 52u8, + 122u8, + 216u8, + 40u8, + 229u8, + 140u8, + 190u8, + 83u8, + 77u8, + 143u8, + 107u8, + 103u8, + 152u8, + 93u8, + 121u8, + 19u8, + 96u8, + 117u8, + 107u8, + 24u8, + 240u8, + 217u8, + 95u8, + 217u8, + 241u8, + 151u8, + 166u8, + 108u8, + 196u8, + 100u8, + 128u8, + 234u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize)), + ), + ethabi::ParamType::Array( + Box::new(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 { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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: { + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: 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) - }, - ma_time: { + }) + .collect(), + fees: 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) - }, - }) - } - } - impl substreams_ethereum::Event for NewParameters2 { - const NAME: &'static str = "NewParameters2"; - 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 NewParameters3 { - pub admin_fee: 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_half_time: substreams::scalar::BigInt, - } - impl NewParameters3 { - const TOPIC_ID: [u8; 32] = [ - 28u8, - 101u8, - 187u8, - 220u8, - 147u8, - 159u8, - 52u8, - 110u8, - 93u8, - 111u8, - 11u8, - 222u8, - 31u8, - 7u8, - 40u8, - 25u8, - 148u8, - 116u8, - 56u8, - 212u8, - 252u8, - 123u8, - 24u8, - 44u8, - 197u8, - 156u8, - 47u8, - 109u8, - 197u8, - 80u8, - 64u8, - 135u8, - ]; - 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::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), - ], - log.data.as_ref(), + }) + .collect(), + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidity6 { + const NAME: &'static str = "RemoveLiquidity6"; + 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 RemoveLiquidityImbalance1 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 2usize], + pub fees: [substreams::scalar::BigInt; 2usize], + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidityImbalance1 { + const TOPIC_ID: [u8; 32] = [ + 43u8, + 85u8, + 8u8, + 55u8, + 141u8, + 126u8, + 25u8, + 224u8, + 213u8, + 250u8, + 51u8, + 132u8, + 25u8, + 3u8, + 71u8, + 49u8, + 65u8, + 108u8, + 79u8, + 91u8, + 33u8, + 154u8, + 16u8, + 55u8, + 153u8, + 86u8, + 247u8, + 100u8, + 49u8, + 127u8, + 212u8, + 126u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + 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 { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - 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_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) - }, - }) - } - } - impl substreams_ethereum::Event for NewParameters3 { - const NAME: &'static str = "NewParameters3"; - 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 NewParameters4 { - 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_time: substreams::scalar::BigInt, - pub xcp_ma_time: substreams::scalar::BigInt, - } - impl NewParameters4 { - const TOPIC_ID: [u8; 32] = [ - 28u8, - 101u8, - 187u8, - 220u8, - 147u8, - 159u8, - 52u8, - 110u8, - 93u8, - 111u8, - 11u8, - 222u8, - 31u8, - 7u8, - 40u8, - 25u8, - 148u8, - 116u8, - 56u8, - 212u8, - 252u8, - 123u8, - 24u8, - 44u8, - 197u8, - 156u8, - 47u8, - 109u8, - 197u8, - 80u8, - 64u8, - 135u8, - ]; - 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::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), - ], - log.data.as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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)] + }, + fees: { + 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)] + }, + invariant: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidityImbalance1 { + const NAME: &'static str = "RemoveLiquidityImbalance1"; + 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 RemoveLiquidityImbalance2 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 3usize], + pub fees: [substreams::scalar::BigInt; 3usize], + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidityImbalance2 { + const TOPIC_ID: [u8; 32] = [ + 23u8, + 53u8, + 153u8, + 219u8, + 249u8, + 198u8, + 202u8, + 111u8, + 124u8, + 59u8, + 89u8, + 13u8, + 240u8, + 122u8, + 233u8, + 138u8, + 69u8, + 215u8, + 79u8, + 245u8, + 64u8, + 101u8, + 80u8, + 81u8, + 65u8, + 231u8, + 222u8, + 108u8, + 70u8, + 166u8, + 36u8, + 194u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + 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 { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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_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) - }, - xcp_ma_time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for NewParameters4 { - const NAME: &'static str = "NewParameters4"; - 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 RampAgamma { - pub initial_a: substreams::scalar::BigInt, - pub future_a: substreams::scalar::BigInt, - pub initial_gamma: substreams::scalar::BigInt, - pub future_gamma: substreams::scalar::BigInt, - pub initial_time: substreams::scalar::BigInt, - pub future_time: substreams::scalar::BigInt, - } - impl RampAgamma { - const TOPIC_ID: [u8; 32] = [ - 227u8, - 95u8, - 5u8, - 89u8, - 176u8, - 100u8, - 33u8, - 100u8, - 226u8, - 134u8, - 179u8, - 13u8, - 242u8, - 7u8, - 126u8, - 195u8, - 160u8, - 84u8, - 38u8, - 97u8, - 122u8, - 37u8, - 219u8, - 117u8, - 120u8, - 253u8, - 32u8, - 186u8, - 57u8, - 166u8, - 205u8, - 5u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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), + ] + }, + fees: { + 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), + ] + }, + invariant: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidityImbalance2 { + const NAME: &'static str = "RemoveLiquidityImbalance2"; + 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 RemoveLiquidityImbalance3 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 4usize], + pub fees: [substreams::scalar::BigInt; 4usize], + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidityImbalance3 { + const TOPIC_ID: [u8; 32] = [ + 185u8, + 100u8, + 183u8, + 47u8, + 115u8, + 245u8, + 239u8, + 91u8, + 240u8, + 253u8, + 197u8, + 89u8, + 178u8, + 250u8, + 185u8, + 167u8, + 177u8, + 42u8, + 57u8, + 228u8, + 120u8, + 23u8, + 165u8, + 71u8, + 241u8, + 240u8, + 174u8, + 228u8, + 127u8, + 235u8, + 214u8, + 2u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 320usize { + 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::Uint(256usize)), + 4usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 4usize, + ), + 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 { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - initial_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) - }, - future_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) - }, - initial_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) - }, - future_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) - }, - initial_time: { + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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), + ] + }, + fees: { + 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), + ] + }, + invariant: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidityImbalance3 { + const NAME: &'static str = "RemoveLiquidityImbalance3"; + 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 RemoveLiquidityImbalance4 { + pub provider: Vec, + pub token_amounts: Vec, + pub fees: Vec, + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidityImbalance4 { + const TOPIC_ID: [u8; 32] = [ + 54u8, + 49u8, + 194u8, + 139u8, + 31u8, + 157u8, + 210u8, + 19u8, + 224u8, + 49u8, + 159u8, + 177u8, + 103u8, + 181u8, + 84u8, + 215u8, + 107u8, + 108u8, + 40u8, + 58u8, + 65u8, + 20u8, + 62u8, + 180u8, + 0u8, + 160u8, + 209u8, + 173u8, + 177u8, + 175u8, + 23u8, + 85u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize)), + ), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(256usize)), + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: 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) - }, - future_time: { + }) + .collect(), + fees: 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) - }, - }) - } - } - impl substreams_ethereum::Event for RampAgamma { - const NAME: &'static str = "RampAgamma"; - 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 RemoveLiquidity1 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidity1 { - const TOPIC_ID: [u8; 32] = [ - 221u8, - 60u8, - 3u8, - 54u8, - 161u8, - 111u8, - 27u8, - 100u8, - 241u8, - 114u8, - 183u8, - 187u8, - 13u8, - 173u8, - 91u8, - 43u8, - 60u8, - 124u8, - 118u8, - 249u8, - 30u8, - 140u8, - 74u8, - 175u8, - 214u8, - 170u8, - 230u8, - 13u8, - 206u8, - 128u8, - 1u8, - 83u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + }) + .collect(), + invariant: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidityImbalance4 { + const NAME: &'static str = "RemoveLiquidityImbalance4"; + 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 RemoveLiquidityOne1 { + pub provider: Vec, + pub token_amount: substreams::scalar::BigInt, + pub coin_amount: substreams::scalar::BigInt, + } + impl RemoveLiquidityOne1 { + const TOPIC_ID: [u8; 32] = [ + 158u8, + 150u8, + 221u8, + 59u8, + 153u8, + 122u8, + 42u8, + 37u8, + 126u8, + 236u8, + 77u8, + 249u8, + 187u8, + 110u8, + 175u8, + 98u8, + 110u8, + 32u8, + 109u8, + 245u8, + 245u8, + 67u8, + 189u8, + 150u8, + 54u8, + 130u8, + 209u8, + 67u8, + 48u8, + 11u8, + 227u8, + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amount: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidity1 { - const NAME: &'static str = "RemoveLiquidity1"; - 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 RemoveLiquidity2 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 3usize], - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidity2 { - const TOPIC_ID: [u8; 32] = [ - 214u8, - 204u8, - 49u8, - 74u8, - 11u8, - 30u8, - 59u8, - 37u8, - 121u8, - 248u8, - 230u8, - 66u8, - 72u8, - 232u8, - 36u8, - 52u8, - 7u8, - 46u8, - 130u8, - 113u8, - 41u8, - 14u8, - 239u8, - 138u8, - 208u8, - 136u8, - 103u8, - 9u8, - 48u8, - 65u8, - 149u8, - 245u8, - ]; - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + coin_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 RemoveLiquidityOne1 { + const NAME: &'static str = "RemoveLiquidityOne1"; + 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 RemoveLiquidityOne2 { + pub provider: Vec, + pub token_amount: substreams::scalar::BigInt, + pub coin_amount: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidityOne2 { + const TOPIC_ID: [u8; 32] = [ + 90u8, + 208u8, + 86u8, + 242u8, + 226u8, + 138u8, + 140u8, + 236u8, + 35u8, + 32u8, + 21u8, + 64u8, + 107u8, + 132u8, + 54u8, + 104u8, + 193u8, + 227u8, + 108u8, + 218u8, + 89u8, + 129u8, + 39u8, + 236u8, + 59u8, + 140u8, + 89u8, + 184u8, + 199u8, + 39u8, + 115u8, + 160u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amount: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidity2 { - const NAME: &'static str = "RemoveLiquidity2"; - 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 RemoveLiquidity3 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fees: [substreams::scalar::BigInt; 2usize], - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidity3 { - const TOPIC_ID: [u8; 32] = [ - 124u8, - 54u8, - 56u8, - 84u8, - 204u8, - 247u8, - 150u8, - 35u8, - 65u8, - 31u8, - 137u8, - 149u8, - 179u8, - 98u8, - 188u8, - 229u8, - 237u8, - 223u8, - 241u8, - 140u8, - 146u8, - 126u8, - 220u8, - 111u8, - 93u8, - 187u8, - 181u8, - 224u8, - 88u8, - 25u8, - 168u8, - 44u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + coin_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) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidityOne2 { + const NAME: &'static str = "RemoveLiquidityOne2"; + 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 RemoveLiquidityOne3 { + pub provider: Vec, + pub token_amount: substreams::scalar::BigInt, + pub coin_index: substreams::scalar::BigInt, + pub coin_amount: substreams::scalar::BigInt, + pub approx_fee: substreams::scalar::BigInt, + pub packed_price_scale: substreams::scalar::BigInt, + } + impl RemoveLiquidityOne3 { + const TOPIC_ID: [u8; 32] = [ + 226u8, + 0u8, + 226u8, + 77u8, + 74u8, + 76u8, + 124u8, + 211u8, + 103u8, + 221u8, + 155u8, + 239u8, + 227u8, + 148u8, + 220u8, + 138u8, + 20u8, + 230u8, + 213u8, + 140u8, + 136u8, + 255u8, + 94u8, + 47u8, + 81u8, + 45u8, + 101u8, + 169u8, + 224u8, + 170u8, + 156u8, + 92u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_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) + }, + coin_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) + }, + coin_amount: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidity3 { - const NAME: &'static str = "RemoveLiquidity3"; - 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 RemoveLiquidity4 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 3usize], - pub fees: [substreams::scalar::BigInt; 3usize], - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidity4 { - const TOPIC_ID: [u8; 32] = [ - 164u8, - 157u8, - 76u8, - 240u8, - 38u8, - 86u8, - 174u8, - 191u8, - 140u8, - 119u8, - 31u8, - 90u8, - 133u8, - 133u8, - 99u8, - 138u8, - 42u8, - 21u8, - 238u8, - 108u8, - 151u8, - 207u8, - 114u8, - 5u8, - 212u8, - 32u8, - 142u8, - 215u8, - 193u8, - 223u8, - 37u8, - 45u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + approx_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidity4 { - const NAME: &'static str = "RemoveLiquidity4"; - 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 RemoveLiquidity5 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 4usize], - pub fees: [substreams::scalar::BigInt; 4usize], - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidity5 { - const TOPIC_ID: [u8; 32] = [ - 152u8, - 120u8, - 202u8, - 55u8, - 94u8, - 16u8, - 111u8, - 42u8, - 67u8, - 195u8, - 181u8, - 153u8, - 252u8, - 98u8, - 69u8, - 104u8, - 19u8, - 28u8, - 76u8, - 154u8, - 75u8, - 166u8, - 106u8, - 20u8, - 86u8, - 55u8, - 21u8, - 118u8, - 59u8, - 233u8, - 213u8, - 157u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 288usize { - 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::Uint(256usize)), - 4usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 4usize, - ), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + packed_price_scale: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidity5 { - const NAME: &'static str = "RemoveLiquidity5"; - 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 RemoveLiquidity6 { - pub provider: Vec, - pub token_amounts: Vec, - pub fees: Vec, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidity6 { - const TOPIC_ID: [u8; 32] = [ - 52u8, - 122u8, - 216u8, - 40u8, - 229u8, - 140u8, - 190u8, - 83u8, - 77u8, - 143u8, - 107u8, - 103u8, - 152u8, - 93u8, - 121u8, - 19u8, - 96u8, - 117u8, - 107u8, - 24u8, - 240u8, - 217u8, - 95u8, - 217u8, - 241u8, - 151u8, - 166u8, - 108u8, - 196u8, - 100u8, - 128u8, - 234u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize)), - ), - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Uint(256usize)), - ), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for RemoveLiquidityOne3 { + const NAME: &'static str = "RemoveLiquidityOne3"; + 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 RemoveLiquidityOne4 { + pub provider: Vec, + pub token_id: substreams::scalar::BigInt, + pub token_amount: substreams::scalar::BigInt, + pub coin_amount: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidityOne4 { + const TOPIC_ID: [u8; 32] = [ + 111u8, + 72u8, + 18u8, + 157u8, + 177u8, + 243u8, + 124u8, + 203u8, + 156u8, + 197u8, + 221u8, + 126u8, + 17u8, + 156u8, + 179u8, + 39u8, + 80u8, + 202u8, + 189u8, + 247u8, + 91u8, + 72u8, + 55u8, + 93u8, + 115u8, + 13u8, + 38u8, + 206u8, + 54u8, + 89u8, + 187u8, + 225u8, + ]; + 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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + token_amount: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .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(), - fees: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + coin_amount: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .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(), - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidity6 { - const NAME: &'static str = "RemoveLiquidity6"; - 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 RemoveLiquidityImbalance1 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fees: [substreams::scalar::BigInt; 2usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityImbalance1 { - const TOPIC_ID: [u8; 32] = [ - 43u8, - 85u8, - 8u8, - 55u8, - 141u8, - 126u8, - 25u8, - 224u8, - 213u8, - 250u8, - 51u8, - 132u8, - 25u8, - 3u8, - 71u8, - 49u8, - 65u8, - 108u8, - 79u8, - 91u8, - 33u8, - 154u8, - 16u8, - 55u8, - 153u8, - 86u8, - 247u8, - 100u8, - 49u8, - 127u8, - 212u8, - 126u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - 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 { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityImbalance1 { - const NAME: &'static str = "RemoveLiquidityImbalance1"; - 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 RemoveLiquidityImbalance2 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 3usize], - pub fees: [substreams::scalar::BigInt; 3usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityImbalance2 { - const TOPIC_ID: [u8; 32] = [ - 23u8, - 53u8, - 153u8, - 219u8, - 249u8, - 198u8, - 202u8, - 111u8, - 124u8, - 59u8, - 89u8, - 13u8, - 240u8, - 122u8, - 233u8, - 138u8, - 69u8, - 215u8, - 79u8, - 245u8, - 64u8, - 101u8, - 80u8, - 81u8, - 65u8, - 231u8, - 222u8, - 108u8, - 70u8, - 166u8, - 36u8, - 194u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - 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 { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for RemoveLiquidityOne4 { + const NAME: &'static str = "RemoveLiquidityOne4"; + 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 StopRampA { + pub current_a: substreams::scalar::BigInt, + pub current_gamma: substreams::scalar::BigInt, + pub time: substreams::scalar::BigInt, + } + impl StopRampA { + const TOPIC_ID: [u8; 32] = [ + 95u8, + 14u8, + 127u8, + 186u8, + 61u8, + 16u8, + 12u8, + 158u8, + 25u8, + 68u8, + 110u8, + 28u8, + 146u8, + 254u8, + 67u8, + 111u8, + 10u8, + 154u8, + 34u8, + 254u8, + 153u8, + 102u8, + 147u8, + 96u8, + 228u8, + 253u8, + 214u8, + 211u8, + 222u8, + 47u8, + 194u8, + 132u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + current_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityImbalance2 { - const NAME: &'static str = "RemoveLiquidityImbalance2"; - 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 RemoveLiquidityImbalance3 { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 4usize], - pub fees: [substreams::scalar::BigInt; 4usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityImbalance3 { - const TOPIC_ID: [u8; 32] = [ - 185u8, - 100u8, - 183u8, - 47u8, - 115u8, - 245u8, - 239u8, - 91u8, - 240u8, - 253u8, - 197u8, - 89u8, - 178u8, - 250u8, - 185u8, - 167u8, - 177u8, - 42u8, - 57u8, - 228u8, - 120u8, - 23u8, - 165u8, - 71u8, - 241u8, - 240u8, - 174u8, - 228u8, - 127u8, - 235u8, - 214u8, - 2u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - return false; - } - if log.data.len() != 320usize { - 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::Uint(256usize)), - 4usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 4usize, - ), - 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 { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + current_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) + }, + time: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for StopRampA { + const NAME: &'static str = "StopRampA"; + 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 TokenExchange1 { + pub buyer: Vec, + pub sold_id: substreams::scalar::BigInt, + pub tokens_sold: substreams::scalar::BigInt, + pub bought_id: substreams::scalar::BigInt, + pub tokens_bought: substreams::scalar::BigInt, + } + impl TokenExchange1 { + const TOPIC_ID: [u8; 32] = [ + 139u8, + 62u8, + 150u8, + 242u8, + 184u8, + 137u8, + 250u8, + 119u8, + 28u8, + 83u8, + 201u8, + 129u8, + 180u8, + 13u8, + 175u8, + 0u8, + 95u8, + 99u8, + 246u8, + 55u8, + 241u8, + 134u8, + 159u8, + 112u8, + 112u8, + 82u8, + 209u8, + 90u8, + 61u8, + 217u8, + 113u8, + 64u8, + ]; + 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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + buyer: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'buyer' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + sold_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityImbalance3 { - const NAME: &'static str = "RemoveLiquidityImbalance3"; - 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 RemoveLiquidityImbalance4 { - pub provider: Vec, - pub token_amounts: Vec, - pub fees: Vec, - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityImbalance4 { - const TOPIC_ID: [u8; 32] = [ - 54u8, - 49u8, - 194u8, - 139u8, - 31u8, - 157u8, - 210u8, - 19u8, - 224u8, - 49u8, - 159u8, - 177u8, - 103u8, - 181u8, - 84u8, - 215u8, - 107u8, - 108u8, - 40u8, - 58u8, - 65u8, - 20u8, - 62u8, - 180u8, - 0u8, - 160u8, - 209u8, - 173u8, - 177u8, - 175u8, - 23u8, - 85u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize)), - ), - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Uint(256usize)), - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + tokens_sold: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + bought_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_array() + .into_int() .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(), - fees: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + tokens_bought: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .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(), - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityImbalance4 { - const NAME: &'static str = "RemoveLiquidityImbalance4"; - 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 RemoveLiquidityOne1 { - pub provider: Vec, - pub token_amount: substreams::scalar::BigInt, - pub coin_amount: substreams::scalar::BigInt, - } - impl RemoveLiquidityOne1 { - const TOPIC_ID: [u8; 32] = [ - 158u8, - 150u8, - 221u8, - 59u8, - 153u8, - 122u8, - 42u8, - 37u8, - 126u8, - 236u8, - 77u8, - 249u8, - 187u8, - 110u8, - 175u8, - 98u8, - 110u8, - 32u8, - 109u8, - 245u8, - 245u8, - 67u8, - 189u8, - 150u8, - 54u8, - 130u8, - 209u8, - 67u8, - 48u8, - 11u8, - 227u8, - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for TokenExchange1 { + const NAME: &'static str = "TokenExchange1"; + 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 TokenExchange2 { + pub buyer: Vec, + pub sold_id: substreams::scalar::BigInt, + pub tokens_sold: substreams::scalar::BigInt, + pub bought_id: substreams::scalar::BigInt, + pub tokens_bought: substreams::scalar::BigInt, + } + impl TokenExchange2 { + const TOPIC_ID: [u8; 32] = [ + 178u8, + 231u8, + 106u8, + 233u8, + 151u8, + 97u8, + 220u8, + 19u8, + 110u8, + 89u8, + 141u8, + 74u8, + 98u8, + 155u8, + 179u8, + 71u8, + 236u8, + 203u8, + 149u8, + 50u8, + 165u8, + 248u8, + 187u8, + 215u8, + 46u8, + 24u8, + 70u8, + 124u8, + 60u8, + 52u8, + 204u8, + 152u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + buyer: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'buyer' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + sold_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_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) - }, - coin_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 RemoveLiquidityOne1 { - const NAME: &'static str = "RemoveLiquidityOne1"; - 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 RemoveLiquidityOne2 { - pub provider: Vec, - pub token_amount: substreams::scalar::BigInt, - pub coin_amount: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityOne2 { - const TOPIC_ID: [u8; 32] = [ - 90u8, - 208u8, - 86u8, - 242u8, - 226u8, - 138u8, - 140u8, - 236u8, - 35u8, - 32u8, - 21u8, - 64u8, - 107u8, - 132u8, - 54u8, - 104u8, - 193u8, - 227u8, - 108u8, - 218u8, - 89u8, - 129u8, - 39u8, - 236u8, - 59u8, - 140u8, - 89u8, - 184u8, - 199u8, - 39u8, - 115u8, - 160u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tokens_sold: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_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) - }, - coin_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) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityOne2 { - const NAME: &'static str = "RemoveLiquidityOne2"; - 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 RemoveLiquidityOne3 { - pub provider: Vec, - pub token_amount: substreams::scalar::BigInt, - pub coin_index: substreams::scalar::BigInt, - pub coin_amount: substreams::scalar::BigInt, - pub approx_fee: substreams::scalar::BigInt, - pub packed_price_scale: substreams::scalar::BigInt, - } - impl RemoveLiquidityOne3 { - const TOPIC_ID: [u8; 32] = [ - 226u8, - 0u8, - 226u8, - 77u8, - 74u8, - 76u8, - 124u8, - 211u8, - 103u8, - 221u8, - 155u8, - 239u8, - 227u8, - 148u8, - 220u8, - 138u8, - 20u8, - 230u8, - 213u8, - 140u8, - 136u8, - 255u8, - 94u8, - 47u8, - 81u8, - 45u8, - 101u8, - 169u8, - 224u8, - 170u8, - 156u8, - 92u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + bought_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_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) - }, - coin_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) - }, - coin_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) - }, - approx_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) - }, - packed_price_scale: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityOne3 { - const NAME: &'static str = "RemoveLiquidityOne3"; - 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 RemoveLiquidityOne4 { - pub provider: Vec, - pub token_id: substreams::scalar::BigInt, - pub token_amount: substreams::scalar::BigInt, - pub coin_amount: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityOne4 { - const TOPIC_ID: [u8; 32] = [ - 111u8, - 72u8, - 18u8, - 157u8, - 177u8, - 243u8, - 124u8, - 203u8, - 156u8, - 197u8, - 221u8, - 126u8, - 17u8, - 156u8, - 179u8, - 39u8, - 80u8, - 202u8, - 189u8, - 247u8, - 91u8, - 72u8, - 55u8, - 93u8, - 115u8, - 13u8, - 38u8, - 206u8, - 54u8, - 89u8, - 187u8, - 225u8, - ]; - 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tokens_bought: { + let mut v = [0 as u8; 32]; + values + .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 TokenExchange2 { + const NAME: &'static str = "TokenExchange2"; + 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 TokenExchange3 { + pub buyer: Vec, + pub sold_id: substreams::scalar::BigInt, + pub tokens_sold: substreams::scalar::BigInt, + pub bought_id: substreams::scalar::BigInt, + pub tokens_bought: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub packed_price_scale: substreams::scalar::BigInt, + } + impl TokenExchange3 { + const TOPIC_ID: [u8; 32] = [ + 20u8, + 63u8, + 31u8, + 142u8, + 134u8, + 31u8, + 189u8, + 237u8, + 221u8, + 91u8, + 70u8, + 232u8, + 68u8, + 183u8, + 211u8, + 172u8, + 123u8, + 134u8, + 161u8, + 34u8, + 243u8, + 110u8, + 140u8, + 70u8, + 56u8, + 89u8, + 238u8, + 104u8, + 17u8, + 177u8, + 242u8, + 156u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + buyer: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'buyer' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + sold_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) + }, + tokens_sold: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + bought_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) + }, + tokens_bought: { + let mut v = [0 as u8; 32]; + values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_id: { - 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) - }, - token_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) - }, - coin_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) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityOne4 { - const NAME: &'static str = "RemoveLiquidityOne4"; - 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 StopRampA { - pub current_a: substreams::scalar::BigInt, - pub current_gamma: substreams::scalar::BigInt, - pub time: substreams::scalar::BigInt, - } - impl StopRampA { - const TOPIC_ID: [u8; 32] = [ - 95u8, - 14u8, - 127u8, - 186u8, - 61u8, - 16u8, - 12u8, - 158u8, - 25u8, - 68u8, - 110u8, - 28u8, - 146u8, - 254u8, - 67u8, - 111u8, - 10u8, - 154u8, - 34u8, - 254u8, - 153u8, - 102u8, - 147u8, - 96u8, - 228u8, - 253u8, - 214u8, - 211u8, - 222u8, - 47u8, - 194u8, - 132u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - current_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) - }, - current_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) - }, - time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for StopRampA { - const NAME: &'static str = "StopRampA"; - 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 TokenExchange1 { - pub buyer: Vec, - pub sold_id: substreams::scalar::BigInt, - pub tokens_sold: substreams::scalar::BigInt, - pub bought_id: substreams::scalar::BigInt, - pub tokens_bought: substreams::scalar::BigInt, - } - impl TokenExchange1 { - const TOPIC_ID: [u8; 32] = [ - 139u8, - 62u8, - 150u8, - 242u8, - 184u8, - 137u8, - 250u8, - 119u8, - 28u8, - 83u8, - 201u8, - 129u8, - 180u8, - 13u8, - 175u8, - 0u8, - 95u8, - 99u8, - 246u8, - 55u8, - 241u8, - 134u8, - 159u8, - 112u8, - 112u8, - 82u8, - 209u8, - 90u8, - 61u8, - 217u8, - 113u8, - 64u8, - ]; - 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - buyer: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'buyer' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + packed_price_scale: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sold_id: { - 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) - }, - tokens_sold: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - bought_id: { - 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) - }, - tokens_bought: { - let mut v = [0 as u8; 32]; - values - .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 TokenExchange1 { - const NAME: &'static str = "TokenExchange1"; - 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 TokenExchange2 { - pub buyer: Vec, - pub sold_id: substreams::scalar::BigInt, - pub tokens_sold: substreams::scalar::BigInt, - pub bought_id: substreams::scalar::BigInt, - pub tokens_bought: substreams::scalar::BigInt, - } - impl TokenExchange2 { - const TOPIC_ID: [u8; 32] = [ - 178u8, - 231u8, - 106u8, - 233u8, - 151u8, - 97u8, - 220u8, - 19u8, - 110u8, - 89u8, - 141u8, - 74u8, - 98u8, - 155u8, - 179u8, - 71u8, - 236u8, - 203u8, - 149u8, - 50u8, - 165u8, - 248u8, - 187u8, - 215u8, - 46u8, - 24u8, - 70u8, - 124u8, - 60u8, - 52u8, - 204u8, - 152u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for TokenExchange3 { + const NAME: &'static str = "TokenExchange3"; + 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 TokenExchangeUnderlying { + pub buyer: Vec, + pub sold_id: substreams::scalar::BigInt, + pub tokens_sold: substreams::scalar::BigInt, + pub bought_id: substreams::scalar::BigInt, + pub tokens_bought: substreams::scalar::BigInt, + } + impl TokenExchangeUnderlying { + const TOPIC_ID: [u8; 32] = [ + 208u8, + 19u8, + 202u8, + 35u8, + 231u8, + 122u8, + 101u8, + 0u8, + 60u8, + 44u8, + 101u8, + 156u8, + 84u8, + 66u8, + 192u8, + 12u8, + 128u8, + 83u8, + 113u8, + 183u8, + 252u8, + 30u8, + 189u8, + 76u8, + 32u8, + 108u8, + 65u8, + 209u8, + 83u8, + 107u8, + 217u8, + 11u8, + ]; + 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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + buyer: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - buyer: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'buyer' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'buyer' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + sold_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sold_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) - }, - tokens_sold: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - bought_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) - }, - tokens_bought: { - let mut v = [0 as u8; 32]; - values - .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 TokenExchange2 { - const NAME: &'static str = "TokenExchange2"; - 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 TokenExchange3 { - pub buyer: Vec, - pub sold_id: substreams::scalar::BigInt, - pub tokens_sold: substreams::scalar::BigInt, - pub bought_id: substreams::scalar::BigInt, - pub tokens_bought: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub packed_price_scale: substreams::scalar::BigInt, - } - impl TokenExchange3 { - const TOPIC_ID: [u8; 32] = [ - 20u8, - 63u8, - 31u8, - 142u8, - 134u8, - 31u8, - 189u8, - 237u8, - 221u8, - 91u8, - 70u8, - 232u8, - 68u8, - 183u8, - 211u8, - 172u8, - 123u8, - 134u8, - 161u8, - 34u8, - 243u8, - 110u8, - 140u8, - 70u8, - 56u8, - 89u8, - 238u8, - 104u8, - 17u8, - 177u8, - 242u8, - 156u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - buyer: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'buyer' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + tokens_sold: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sold_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) - }, - tokens_sold: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - bought_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) - }, - tokens_bought: { - let mut v = [0 as u8; 32]; - values - .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) - }, - packed_price_scale: { - let mut v = [0 as u8; 32]; - values - .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 TokenExchange3 { - const NAME: &'static str = "TokenExchange3"; - 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 TokenExchangeUnderlying { - pub buyer: Vec, - pub sold_id: substreams::scalar::BigInt, - pub tokens_sold: substreams::scalar::BigInt, - pub bought_id: substreams::scalar::BigInt, - pub tokens_bought: substreams::scalar::BigInt, - } - impl TokenExchangeUnderlying { - const TOPIC_ID: [u8; 32] = [ - 208u8, - 19u8, - 202u8, - 35u8, - 231u8, - 122u8, - 101u8, - 0u8, - 60u8, - 44u8, - 101u8, - 156u8, - 84u8, - 66u8, - 192u8, - 12u8, - 128u8, - 83u8, - 113u8, - 183u8, - 252u8, - 30u8, - 189u8, - 76u8, - 32u8, - 108u8, - 65u8, - 209u8, - 83u8, - 107u8, - 217u8, - 11u8, - ]; - 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - buyer: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'buyer' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + bought_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sold_id: { - 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) - }, - tokens_sold: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - bought_id: { - 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) - }, - tokens_bought: { - let mut v = [0 as u8; 32]; - values - .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) + }, + tokens_bought: { + let mut v = [0 as u8; 32]; + values + .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 TokenExchangeUnderlying { - const NAME: &'static str = "TokenExchangeUnderlying"; - 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 TokenExchangeUnderlying { + const NAME: &'static str = "TokenExchangeUnderlying"; + 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) + } + } +} \ No newline at end of file diff --git a/src/abi/curve/pools/lending_pool.rs b/src/abi/curve/pools/lending_pool.rs index f45621f..6b6c1c0 100644 --- a/src/abi/curve/pools/lending_pool.rs +++ b/src/abi/curve/pools/lending_pool.rs @@ -1,4170 +1,4331 @@ - 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 A {} - impl A { - const METHOD_ID: [u8; 4] = [244u8, 70u8, 193u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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 - } +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 A {} + impl A { + const METHOD_ID: [u8; 4] = [244u8, 70u8, 193u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + 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 A { - const NAME: &'static str = "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::Function for A { + const NAME: &'static str = "A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for A { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct APrecise {} - impl APrecise { - const METHOD_ID: [u8; 4] = [118u8, 162u8, 240u8, 240u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 - } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for A { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct APrecise {} + impl APrecise { + const METHOD_ID: [u8; 4] = [118u8, 162u8, 240u8, 240u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 APrecise { - const NAME: &'static str = "A_precise"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 APrecise { + const NAME: &'static str = "A_precise"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for APrecise { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AddLiquidity1 { - pub u_amounts: [substreams::scalar::BigInt; 3usize], - pub u_min_mint_amount: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl AddLiquidity1 { - const METHOD_ID: [u8; 4] = [69u8, 21u8, 206u8, 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - u_min_mint_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for APrecise { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity1 { + pub u_amounts: [substreams::scalar::BigInt; 3usize], + pub u_min_mint_amount: substreams::scalar::BigInt, + } + impl AddLiquidity1 { + const METHOD_ID: [u8; 4] = [69u8, 21u8, 206u8, 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( &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_min_mint_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, ), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amounts: { + 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), + ] + }, + u_min_mint_amount: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_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::FixedArray(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_min_mint_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::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 AddLiquidity1 { - const NAME: &'static str = "add_liquidity1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AddLiquidity1 { + const NAME: &'static str = "add_liquidity1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AddLiquidity1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AddLiquidity2 { - pub u_amounts: [substreams::scalar::BigInt; 3usize], - pub u_min_mint_amount: substreams::scalar::BigInt, - pub u_use_underlying: bool, + fn encode(&self) -> Vec { + self.encode() } - impl AddLiquidity2 { - const METHOD_ID: [u8; 4] = [43u8, 110u8, 153u8, 58u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - u_min_mint_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) - }, - u_use_underlying: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for AddLiquidity1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity2 { + pub u_amounts: [substreams::scalar::BigInt; 3usize], + pub u_min_mint_amount: substreams::scalar::BigInt, + pub u_use_underlying: bool, + } + impl AddLiquidity2 { + const METHOD_ID: [u8; 4] = [43u8, 110u8, 153u8, 58u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_min_mint_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, ), - ethabi::Token::Bool(self.u_use_underlying.clone()), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amounts: { + 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), + ] + }, + u_min_mint_amount: { 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, + }, + u_use_underlying: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_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::FixedArray(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_min_mint_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bool(self.u_use_underlying.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 { + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for AddLiquidity2 { + const NAME: &'static str = "add_liquidity2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AddLiquidity2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AdminActionsDeadline {} + impl AdminActionsDeadline { + const METHOD_ID: [u8; 4] = [64u8, 94u8, 40u8, 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 { + 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 AddLiquidity2 { - const NAME: &'static str = "add_liquidity2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AdminActionsDeadline { + const NAME: &'static str = "admin_actions_deadline"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AddLiquidity2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminActionsDeadline {} - impl AdminActionsDeadline { - const METHOD_ID: [u8; 4] = [64u8, 94u8, 40u8, 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 { - 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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AdminActionsDeadline { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AdminBalances { + pub arg0: substreams::scalar::BigInt, + } + impl AdminBalances { + const METHOD_ID: [u8; 4] = [226u8, 231u8, 210u8, 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::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") + .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 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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for AdminBalances { + const NAME: &'static str = "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 AdminBalances { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AdminFee {} + impl AdminFee { + const METHOD_ID: [u8; 4] = [254u8, 227u8, 247u8, 249u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 AdminActionsDeadline { - const NAME: &'static str = "admin_actions_deadline"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AdminFee { + const NAME: &'static str = "admin_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AdminFee { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable - for AdminActionsDeadline { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct ApplyNewFee {} + impl ApplyNewFee { + const METHOD_ID: [u8; 4] = [79u8, 18u8, 254u8, 151u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminBalances { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for ApplyNewFee { + const NAME: &'static str = "apply_new_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl AdminBalances { - const METHOD_ID: [u8; 4] = [226u8, 231u8, 210u8, 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::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) - }, - }) + 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 ApplyTransferOwnership {} + impl ApplyTransferOwnership { + const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 match_call(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 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({ + } + } + impl substreams_ethereum::Function for ApplyTransferOwnership { + const NAME: &'static str = "apply_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 Balances { + pub i: substreams::scalar::BigInt, + } + impl Balances { + const METHOD_ID: [u8; 4] = [73u8, 3u8, 176u8, 209u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + 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 { + 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 AdminBalances { - const NAME: &'static str = "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::Function for Balances { + const NAME: &'static str = "balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AdminBalances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminFee {} - impl AdminFee { - const METHOD_ID: [u8; 4] = [254u8, 227u8, 247u8, 249u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for Balances { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CalcTokenAmount { + pub u_amounts: [substreams::scalar::BigInt; 3usize], + pub is_deposit: bool, + } + impl CalcTokenAmount { + const METHOD_ID: [u8; 4] = [56u8, 131u8, 225u8, 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::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::Bool, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amounts: { + let mut iter = 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 - } + .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), + ] + }, + is_deposit: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_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::FixedArray(v) + }, + ethabi::Token::Bool(self.is_deposit.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 { + 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 AdminFee { - const NAME: &'static str = "admin_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for AdminFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ApplyNewFee {} - impl ApplyNewFee { - const METHOD_ID: [u8; 4] = [79u8, 18u8, 254u8, 151u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 CalcTokenAmount { + const NAME: &'static str = "calc_token_amount"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Function for ApplyNewFee { - const NAME: &'static str = "apply_new_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ApplyTransferOwnership {} - impl ApplyTransferOwnership { - const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 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 ApplyTransferOwnership { - const NAME: &'static str = "apply_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() - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct Balances { - pub i: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable + for CalcTokenAmount { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl Balances { - const METHOD_ID: [u8; 4] = [73u8, 3u8, 176u8, 209u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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( + } + #[derive(Debug, Clone, PartialEq)] + pub struct CalcWithdrawOneCoin { + pub u_token_amount: substreams::scalar::BigInt, + pub i: substreams::scalar::BigInt, + } + impl CalcWithdrawOneCoin { + const METHOD_ID: [u8; 4] = [204u8, 43u8, 39u8, 215u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::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(), - ), - ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Int(128usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_token_amount: { 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 - } + }, + i: { + 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) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_token_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let non_full_signed_bytes = self.i.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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(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 Balances { - const NAME: &'static str = "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::Function for CalcWithdrawOneCoin { + const NAME: &'static str = "calc_withdraw_one_coin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Balances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CalcTokenAmount { - pub u_amounts: [substreams::scalar::BigInt; 3usize], - pub is_deposit: bool, + fn encode(&self) -> Vec { + self.encode() } - impl CalcTokenAmount { - const METHOD_ID: [u8; 4] = [56u8, 131u8, 225u8, 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - is_deposit: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Bool(self.is_deposit.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 { - 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({ + } + impl substreams_ethereum::rpc::RPCDecodable + for CalcWithdrawOneCoin { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Coins { + pub arg0: substreams::scalar::BigInt, + } + impl Coins { + const METHOD_ID: [u8; 4] = [198u8, 97u8, 6u8, 87u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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 CalcTokenAmount { - const NAME: &'static str = "calc_token_amount"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Coins { + const NAME: &'static str = "coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for CalcTokenAmount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CalcWithdrawOneCoin { - pub u_token_amount: substreams::scalar::BigInt, - pub i: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl CalcWithdrawOneCoin { - const METHOD_ID: [u8; 4] = [204u8, 43u8, 39u8, 215u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_token_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) - }, - i: { - 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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable> for Coins { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitNewFee { + pub new_fee: substreams::scalar::BigInt, + pub new_admin_fee: substreams::scalar::BigInt, + pub new_offpeg_fee_multiplier: substreams::scalar::BigInt, + } + impl CommitNewFee { + const METHOD_ID: [u8; 4] = [7u8, 70u8, 221u8, 90u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_token_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - { - let non_full_signed_bytes = self.i.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()), - ) - }, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + new_fee: { 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 - } - } - } + }, + new_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) + }, + new_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) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.new_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.new_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.new_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(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for CalcWithdrawOneCoin { - const NAME: &'static str = "calc_withdraw_one_coin"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 CalcWithdrawOneCoin { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for CommitNewFee { + const NAME: &'static str = "commit_new_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 u_owner: 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 { + u_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner))], + ); + 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 Coins { - pub arg0: substreams::scalar::BigInt, + } + 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 Coins { - const METHOD_ID: [u8; 4] = [198u8, 97u8, 6u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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) - }, - }) + 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 DonateAdminFees {} + impl DonateAdminFees { + const METHOD_ID: [u8; 4] = [82u8, 76u8, 57u8, 1u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for DonateAdminFees { + const NAME: &'static str = "donate_admin_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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DynamicFee { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + } + impl DynamicFee { + const METHOD_ID: [u8; 4] = [118u8, 169u8, 205u8, 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::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::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { + 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) + }, + j: { + 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(), + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.i.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()), + ) + }, + { + let non_full_signed_bytes = self.j.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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 Coins { - const NAME: &'static str = "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::Function for DynamicFee { + const NAME: &'static str = "dynamic_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Coins { - 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 CommitNewFee { - pub new_fee: substreams::scalar::BigInt, - pub new_admin_fee: substreams::scalar::BigInt, - pub new_offpeg_fee_multiplier: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl CommitNewFee { - const METHOD_ID: [u8; 4] = [7u8, 70u8, 221u8, 90u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - new_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) - }, - new_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) - }, - new_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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for DynamicFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Exchange { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub dx: substreams::scalar::BigInt, + pub min_dy: substreams::scalar::BigInt, + } + impl Exchange { + const METHOD_ID: [u8; 4] = [61u8, 240u8, 33u8, 36u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.new_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.new_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.new_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::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - 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 CommitNewFee { - const NAME: &'static str = "commit_new_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 u_owner: 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 { - u_owner: values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner))], - ); - 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 DonateAdminFees {} - impl DonateAdminFees { - const METHOD_ID: [u8; 4] = [82u8, 76u8, 57u8, 1u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 DonateAdminFees { - const NAME: &'static str = "donate_admin_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct DynamicFee { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - } - impl DynamicFee { - const METHOD_ID: [u8; 4] = [118u8, 169u8, 205u8, 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::Int(128usize), - ethabi::ParamType::Int(128usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - i: { - 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) - }, - j: { - 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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ], - ); - let mut encoded = Vec::with_capacity(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({ + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + j: { + 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) + }, + dx: { 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 DynamicFee { - const NAME: &'static str = "dynamic_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for DynamicFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Exchange { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub dx: substreams::scalar::BigInt, - pub min_dy: substreams::scalar::BigInt, - } - impl Exchange { - const METHOD_ID: [u8; 4] = [61u8, 240u8, 33u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - 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 { - i: { - 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) - }, - j: { - 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) - }, - dx: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - min_dy: { - let mut v = [0 as u8; 32]; - values - .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( - &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.dx.clone().to_bytes_be() { - (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.min_dy.clone().to_bytes_be() { - (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({ + }, + min_dy: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.i.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()), + ) + }, + { + let non_full_signed_bytes = self.j.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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.dx.clone().to_bytes_be() { + (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.min_dy.clone().to_bytes_be() { + (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 Exchange { - const NAME: &'static str = "exchange"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Exchange { + const NAME: &'static str = "exchange"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Exchange { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ExchangeUnderlying { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub dx: substreams::scalar::BigInt, - pub min_dy: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl ExchangeUnderlying { - const METHOD_ID: [u8; 4] = [166u8, 65u8, 126u8, 214u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - 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 { - i: { - 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) - }, - j: { - 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) - }, - dx: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - min_dy: { - let mut v = [0 as u8; 32]; - values - .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( + } + impl substreams_ethereum::rpc::RPCDecodable + for Exchange { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ExchangeUnderlying { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub dx: substreams::scalar::BigInt, + pub min_dy: substreams::scalar::BigInt, + } + impl ExchangeUnderlying { + const METHOD_ID: [u8; 4] = [166u8, 65u8, 126u8, 214u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.dx.clone().to_bytes_be() { - (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.min_dy.clone().to_bytes_be() { - (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::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { let mut v = [0 as u8; 32]; values .pop() - .expect("one output data should have existed") - .into_uint() + .expect(INTERNAL_ERR) + .into_int() .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 ExchangeUnderlying { - const NAME: &'static str = "exchange_underlying"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ExchangeUnderlying { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Fee {} - impl Fee { - const METHOD_ID: [u8; 4] = [221u8, 202u8, 63u8, 67u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + j: { let mut v = [0 as u8; 32]; values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + dx: { + let mut v = [0 as u8; 32]; + values + .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 { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Fee { - const NAME: &'static str = "fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for Fee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureA {} - impl FutureA { - const METHOD_ID: [u8; 4] = [180u8, 181u8, 119u8, 173u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + min_dy: { 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 - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.i.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()), + ) + }, + { + let non_full_signed_bytes = self.j.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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.dx.clone().to_bytes_be() { + (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.min_dy.clone().to_bytes_be() { + (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 FutureA { - const NAME: &'static str = "future_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::Function for ExchangeUnderlying { + const NAME: &'static str = "exchange_underlying"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureATime {} - impl FutureATime { - const METHOD_ID: [u8; 4] = [20u8, 5u8, 34u8, 136u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ExchangeUnderlying { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Fee {} + impl Fee { + const METHOD_ID: [u8; 4] = [221u8, 202u8, 63u8, 67u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Fee { + const NAME: &'static str = "fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for Fee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureA {} + impl FutureA { + const METHOD_ID: [u8; 4] = [180u8, 181u8, 119u8, 173u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 FutureATime { - const NAME: &'static str = "future_A_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureA { + const NAME: &'static str = "future_A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureATime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdminFee {} - impl FutureAdminFee { - const METHOD_ID: [u8; 4] = [227u8, 130u8, 68u8, 98u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for FutureA { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureATime {} + impl FutureATime { + const METHOD_ID: [u8; 4] = [20u8, 5u8, 34u8, 136u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for FutureATime { + const NAME: &'static str = "future_A_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureATime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAdminFee {} + impl FutureAdminFee { + const METHOD_ID: [u8; 4] = [227u8, 130u8, 68u8, 98u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 FutureAdminFee { - const NAME: &'static str = "future_admin_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureAdminFee { + const NAME: &'static str = "future_admin_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureAdminFee { - 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 FutureAdminFee { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureFee {} - impl FutureFee { - const METHOD_ID: [u8; 4] = [88u8, 104u8, 13u8, 11u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureFee {} + impl FutureFee { + const METHOD_ID: [u8; 4] = [88u8, 104u8, 13u8, 11u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + } + } + impl substreams_ethereum::Function for FutureFee { + const NAME: &'static str = "future_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureOffpegFeeMultiplier {} + impl FutureOffpegFeeMultiplier { + const METHOD_ID: [u8; 4] = [30u8, 76u8, 78u8, 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 { + 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 + } } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) + } + } + impl substreams_ethereum::Function for FutureOffpegFeeMultiplier { + const NAME: &'static str = "future_offpeg_fee_multiplier"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureOffpegFeeMultiplier { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureOwner {} + impl FutureOwner { + const METHOD_ID: [u8; 4] = [30u8, 192u8, 205u8, 193u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + } + } + impl substreams_ethereum::Function for FutureOwner { + const NAME: &'static str = "future_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 FutureOwner { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDy { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub dx: substreams::scalar::BigInt, + } + impl GetDy { + const METHOD_ID: [u8; 4] = [94u8, 13u8, 68u8, 63u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { + 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) + }, + j: { + 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) + }, + dx: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.i.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()), + ) + }, + { + let non_full_signed_bytes = self.j.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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.dx.clone().to_bytes_be() { + (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 FutureFee { - const NAME: &'static str = "future_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetDy { + const NAME: &'static str = "get_dy"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureOffpegFeeMultiplier {} - impl FutureOffpegFeeMultiplier { - const METHOD_ID: [u8; 4] = [30u8, 76u8, 78u8, 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 { - 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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for GetDy { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDyUnderlying { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub dx: substreams::scalar::BigInt, + } + impl GetDyUnderlying { + const METHOD_ID: [u8; 4] = [7u8, 33u8, 30u8, 247u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { + 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) + }, + j: { + 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) + }, + dx: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.i.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()), + ) + }, + { + let non_full_signed_bytes = self.j.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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.dx.clone().to_bytes_be() { + (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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for GetDyUnderlying { + const NAME: &'static str = "get_dy_underlying"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetDyUnderlying { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetVirtualPrice {} + impl GetVirtualPrice { + const METHOD_ID: [u8; 4] = [187u8, 123u8, 139u8, 128u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 FutureOffpegFeeMultiplier { - const NAME: &'static str = "future_offpeg_fee_multiplier"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetVirtualPrice { + const NAME: &'static str = "get_virtual_price"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureOffpegFeeMultiplier { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureOwner {} - impl FutureOwner { - const METHOD_ID: [u8; 4] = [30u8, 192u8, 205u8, 193u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetVirtualPrice { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InitialA {} + impl InitialA { + const METHOD_ID: [u8; 4] = [84u8, 9u8, 73u8, 26u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for InitialA { + const NAME: &'static str = "initial_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 InitialA { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InitialATime {} + impl InitialATime { + const METHOD_ID: [u8; 4] = [32u8, 129u8, 6u8, 108u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 FutureOwner { - const NAME: &'static str = "future_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::Function for InitialATime { + const NAME: &'static str = "initial_A_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for InitialATime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct KillMe {} + impl KillMe { + const METHOD_ID: [u8; 4] = [227u8, 105u8, 136u8, 83u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 FutureOwner { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + } + impl substreams_ethereum::Function for KillMe { + const NAME: &'static str = "kill_me"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LpToken {} + impl LpToken { + const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 GetDy { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub dx: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for LpToken { + const NAME: &'static str = "lp_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 GetDy { - const METHOD_ID: [u8; 4] = [94u8, 13u8, 68u8, 63u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - i: { - 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) - }, - j: { - 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) - }, - dx: { - let mut v = [0 as u8; 32]; - values - .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( - &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.dx.clone().to_bytes_be() { - (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::rpc::RPCDecodable> for LpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OffpegFeeMultiplier {} + impl OffpegFeeMultiplier { + const METHOD_ID: [u8; 4] = [142u8, 223u8, 221u8, 95u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 GetDy { - const NAME: &'static str = "get_dy"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 OffpegFeeMultiplier { + const NAME: &'static str = "offpeg_fee_multiplier"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetDy { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDyUnderlying { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub dx: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable + for OffpegFeeMultiplier { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl GetDyUnderlying { - const METHOD_ID: [u8; 4] = [7u8, 33u8, 30u8, 247u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 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 } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - i: { - 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) - }, - j: { - 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) - }, - dx: { - let mut v = [0 as u8; 32]; - values - .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( + } + } + 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 RampA { + pub u_future_a: substreams::scalar::BigInt, + pub u_future_time: substreams::scalar::BigInt, + } + impl RampA { + const METHOD_ID: [u8; 4] = [60u8, 21u8, 126u8, 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( &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.dx.clone().to_bytes_be() { - (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::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_future_a: { 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 GetDyUnderlying { - const NAME: &'static str = "get_dy_underlying"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for GetDyUnderlying { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetVirtualPrice {} - impl GetVirtualPrice { - const METHOD_ID: [u8; 4] = [187u8, 123u8, 139u8, 128u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + u_future_time: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_future_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.u_future_time.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for GetVirtualPrice { - const NAME: &'static str = "get_virtual_price"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 GetVirtualPrice { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for RampA { + const NAME: &'static str = "ramp_A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct InitialA {} - impl InitialA { - const METHOD_ID: [u8; 4] = [84u8, 9u8, 73u8, 26u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + 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 RemoveLiquidity1 { + pub u_amount: substreams::scalar::BigInt, + pub u_min_amounts: [substreams::scalar::BigInt; 3usize], + } + impl RemoveLiquidity1 { + const METHOD_ID: [u8; 4] = [236u8, 181u8, 134u8, 165u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Uint(256usize)), + 3usize, + ), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amount: { 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(), } + }, + u_min_amounts: { + 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), + ] + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let v = self + .u_min_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::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<[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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 InitialA { - const NAME: &'static str = "initial_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::Function for RemoveLiquidity1 { + const NAME: &'static str = "remove_liquidity1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for InitialA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct InitialATime {} - impl InitialATime { - const METHOD_ID: [u8; 4] = [32u8, 129u8, 6u8, 108u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 3usize]> + for RemoveLiquidity1 { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 3usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidity2 { + pub u_amount: substreams::scalar::BigInt, + pub u_min_amounts: [substreams::scalar::BigInt; 3usize], + pub u_use_underlying: bool, + } + impl RemoveLiquidity2 { + const METHOD_ID: [u8; 4] = [252u8, 230u8, 71u8, 54u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::Bool, + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amount: { 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(), } + }, + u_min_amounts: { + 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), + ] + }, + u_use_underlying: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let v = self + .u_min_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::FixedArray(v) + }, + ethabi::Token::Bool(self.u_use_underlying.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[substreams::scalar::BigInt; 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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 InitialATime { - const NAME: &'static str = "initial_A_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RemoveLiquidity2 { + const NAME: &'static str = "remove_liquidity2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for InitialATime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct KillMe {} - impl KillMe { - const METHOD_ID: [u8; 4] = [227u8, 105u8, 136u8, 83u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for KillMe { - const NAME: &'static str = "kill_me"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - 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 RemoveLiquidity2 { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 3usize], String> { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct LpToken {} - impl LpToken { - const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityImbalance1 { + pub u_amounts: [substreams::scalar::BigInt; 3usize], + pub u_max_burn_amount: substreams::scalar::BigInt, + } + impl RemoveLiquidityImbalance1 { + const METHOD_ID: [u8; 4] = [159u8, 218u8, 234u8, 12u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amounts: { + let mut iter = values .pop() - .expect("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for LpToken { - const NAME: &'static str = "lp_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 LpToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct OffpegFeeMultiplier {} - impl OffpegFeeMultiplier { - const METHOD_ID: [u8; 4] = [142u8, 223u8, 221u8, 95u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 OffpegFeeMultiplier { - const NAME: &'static str = "offpeg_fee_multiplier"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for OffpegFeeMultiplier { - 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 RampA { - pub u_future_a: substreams::scalar::BigInt, - pub u_future_time: substreams::scalar::BigInt, - } - impl RampA { - const METHOD_ID: [u8; 4] = [60u8, 21u8, 126u8, 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_future_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) - }, - u_future_time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_future_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.u_future_time.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - } - impl substreams_ethereum::Function for RampA { - const NAME: &'static str = "ramp_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidity1 { - pub u_amount: substreams::scalar::BigInt, - pub u_min_amounts: [substreams::scalar::BigInt; 3usize], - } - impl RemoveLiquidity1 { - const METHOD_ID: [u8; 4] = [236u8, 181u8, 134u8, 165u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Uint(256usize)), - 3usize, - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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) - }, - u_min_amounts: { - 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), - ] - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - { - let v = self - .u_min_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::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<[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() @@ -4181,197 +4342,164 @@ 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 - } + }, + u_max_burn_amount: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_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::FixedArray(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_max_burn_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::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 RemoveLiquidity1 { - const NAME: &'static str = "remove_liquidity1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RemoveLiquidityImbalance1 { + const NAME: &'static str = "remove_liquidity_imbalance1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 3usize]> - for RemoveLiquidity1 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 3usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidity2 { - pub u_amount: substreams::scalar::BigInt, - pub u_min_amounts: [substreams::scalar::BigInt; 3usize], - pub u_use_underlying: bool, + fn encode(&self) -> Vec { + self.encode() } - impl RemoveLiquidity2 { - const METHOD_ID: [u8; 4] = [252u8, 230u8, 71u8, 54u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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) - }, - u_min_amounts: { - 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), - ] - }, - u_use_underlying: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for RemoveLiquidityImbalance1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityImbalance2 { + pub u_amounts: [substreams::scalar::BigInt; 3usize], + pub u_max_burn_amount: substreams::scalar::BigInt, + pub u_use_underlying: bool, + } + impl RemoveLiquidityImbalance2 { + const METHOD_ID: [u8; 4] = [91u8, 131u8, 105u8, 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::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, ), - { - let v = self - .u_min_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::FixedArray(v) - }, - ethabi::Token::Bool(self.u_use_underlying.clone()), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amounts: { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -4388,2942 +4516,2600 @@ 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 RemoveLiquidity2 { - const NAME: &'static str = "remove_liquidity2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - 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 RemoveLiquidity2 { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 3usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidityImbalance1 { - pub u_amounts: [substreams::scalar::BigInt; 3usize], - pub u_max_burn_amount: substreams::scalar::BigInt, - } - impl RemoveLiquidityImbalance1 { - const METHOD_ID: [u8; 4] = [159u8, 218u8, 234u8, 12u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - u_max_burn_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_max_burn_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + }, + u_max_burn_amount: { 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 - } + }, + u_use_underlying: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_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::FixedArray(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_max_burn_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bool(self.u_use_underlying.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 { + 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 RemoveLiquidityImbalance1 { - const NAME: &'static str = "remove_liquidity_imbalance1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RemoveLiquidityImbalance2 { + const NAME: &'static str = "remove_liquidity_imbalance2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for RemoveLiquidityImbalance1 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidityImbalance2 { - pub u_amounts: [substreams::scalar::BigInt; 3usize], - pub u_max_burn_amount: substreams::scalar::BigInt, - pub u_use_underlying: bool, + fn encode(&self) -> Vec { + self.encode() } - impl RemoveLiquidityImbalance2 { - const METHOD_ID: [u8; 4] = [91u8, 131u8, 105u8, 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - u_max_burn_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) - }, - u_use_underlying: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for RemoveLiquidityImbalance2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityOneCoin1 { + pub u_token_amount: substreams::scalar::BigInt, + pub i: substreams::scalar::BigInt, + pub u_min_amount: substreams::scalar::BigInt, + } + impl RemoveLiquidityOneCoin1 { + const METHOD_ID: [u8; 4] = [26u8, 77u8, 1u8, 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( &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_max_burn_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Bool(self.u_use_underlying.clone()), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_token_amount: { 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 RemoveLiquidityImbalance2 { - const NAME: &'static str = "remove_liquidity_imbalance2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for RemoveLiquidityImbalance2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidityOneCoin1 { - pub u_token_amount: substreams::scalar::BigInt, - pub i: substreams::scalar::BigInt, - pub u_min_amount: substreams::scalar::BigInt, - } - impl RemoveLiquidityOneCoin1 { - const METHOD_ID: [u8; 4] = [26u8, 77u8, 1u8, 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::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_token_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) - }, - i: { - 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) - }, - u_min_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_token_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + }, + i: { + 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) + }, + u_min_amount: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_token_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .as_slice(), ), + ), + { + let non_full_signed_bytes = self.i.to_signed_bytes_be(); + let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 + == 0x80 { - let non_full_signed_bytes = self.i.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_min_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + 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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_min_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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 RemoveLiquidityOneCoin1 { + const NAME: &'static str = "remove_liquidity_one_coin1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RemoveLiquidityOneCoin1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityOneCoin2 { + pub u_token_amount: substreams::scalar::BigInt, + pub i: substreams::scalar::BigInt, + pub u_min_amount: substreams::scalar::BigInt, + pub u_use_underlying: bool, + } + impl RemoveLiquidityOneCoin2 { + const METHOD_ID: [u8; 4] = [81u8, 122u8, 85u8, 163u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Bool, ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_token_amount: { 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 - } + }, + i: { + 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) + }, + u_min_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) + }, + u_use_underlying: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_token_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let non_full_signed_bytes = self.i.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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_min_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Bool(self.u_use_underlying.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 { + 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 RemoveLiquidityOneCoin1 { - const NAME: &'static str = "remove_liquidity_one_coin1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RemoveLiquidityOneCoin2 { + const NAME: &'static str = "remove_liquidity_one_coin2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable - for RemoveLiquidityOneCoin1 { - fn output(data: &[u8]) -> Result { - Self::output(data) + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RemoveLiquidityOneCoin2 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RevertNewParameters {} + impl RevertNewParameters { + const METHOD_ID: [u8; 4] = [34u8, 104u8, 64u8, 251u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidityOneCoin2 { - pub u_token_amount: substreams::scalar::BigInt, - pub i: substreams::scalar::BigInt, - pub u_min_amount: substreams::scalar::BigInt, - pub u_use_underlying: bool, + } + impl substreams_ethereum::Function for RevertNewParameters { + const NAME: &'static str = "revert_new_parameters"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl RemoveLiquidityOneCoin2 { - const METHOD_ID: [u8; 4] = [81u8, 122u8, 85u8, 163u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_token_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) - }, - i: { - 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) - }, - u_min_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) - }, - u_use_underlying: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) + 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 RevertTransferOwnership {} + impl RevertTransferOwnership { + const METHOD_ID: [u8; 4] = [134u8, 251u8, 241u8, 147u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_token_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - { - let non_full_signed_bytes = self.i.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_min_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Bool(self.u_use_underlying.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 { - 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({ + } + } + impl substreams_ethereum::Function for RevertTransferOwnership { + const NAME: &'static str = "revert_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 SetAaveReferral { + pub referral_code: substreams::scalar::BigInt, + } + impl SetAaveReferral { + const METHOD_ID: [u8; 4] = [182u8, 170u8, 100u8, 197u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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 { + referral_code: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.referral_code.clone().to_bytes_be() { + (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 } - impl substreams_ethereum::Function for RemoveLiquidityOneCoin2 { - const NAME: &'static str = "remove_liquidity_one_coin2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 RemoveLiquidityOneCoin2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for SetAaveReferral { + const NAME: &'static str = "set_aave_referral"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct RevertNewParameters {} - impl RevertNewParameters { - const METHOD_ID: [u8; 4] = [34u8, 104u8, 64u8, 251u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 RevertNewParameters { - const NAME: &'static str = "revert_new_parameters"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 RevertTransferOwnership {} - impl RevertTransferOwnership { - const METHOD_ID: [u8; 4] = [134u8, 251u8, 241u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for RevertTransferOwnership { - const NAME: &'static str = "revert_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 StopRampA {} + impl StopRampA { + const METHOD_ID: [u8; 4] = [85u8, 26u8, 101u8, 136u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct SetAaveReferral { - pub referral_code: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for StopRampA { + const NAME: &'static str = "stop_ramp_A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl SetAaveReferral { - const METHOD_ID: [u8; 4] = [182u8, 170u8, 100u8, 197u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - referral_code: { - let mut v = [0 as u8; 32]; - values - .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.referral_code.clone().to_bytes_be() { - (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, - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for SetAaveReferral { - const NAME: &'static str = "set_aave_referral"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 StopRampA {} - impl StopRampA { - const METHOD_ID: [u8; 4] = [85u8, 26u8, 101u8, 136u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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, + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferOwnershipDeadline {} + impl TransferOwnershipDeadline { + const METHOD_ID: [u8; 4] = [224u8, 160u8, 181u8, 134u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 StopRampA { - const NAME: &'static str = "stop_ramp_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferOwnershipDeadline {} - impl TransferOwnershipDeadline { - const METHOD_ID: [u8; 4] = [224u8, 160u8, 181u8, 134u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + } + impl substreams_ethereum::Function for TransferOwnershipDeadline { + const NAME: &'static str = "transfer_ownership_deadline"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for TransferOwnershipDeadline { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UnderlyingCoins1 { + pub arg0: substreams::scalar::BigInt, + } + impl UnderlyingCoins1 { + const METHOD_ID: [u8; 4] = [185u8, 148u8, 126u8, 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::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") + .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 - } + }, + }) + } + 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 TransferOwnershipDeadline { - const NAME: &'static str = "transfer_ownership_deadline"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 UnderlyingCoins1 { + const NAME: &'static str = "underlying_coins1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for TransferOwnershipDeadline { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct UnderlyingCoins1 { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl UnderlyingCoins1 { - const METHOD_ID: [u8; 4] = [185u8, 148u8, 126u8, 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::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( + } + impl substreams_ethereum::rpc::RPCDecodable> for UnderlyingCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UnderlyingCoins2 { + pub arg0: substreams::scalar::BigInt, + } + impl UnderlyingCoins2 { + const METHOD_ID: [u8; 4] = [183u8, 57u8, 149u8, 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::Int(128usize)], + 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_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.arg0.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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for UnderlyingCoins1 { - const NAME: &'static str = "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::Function for UnderlyingCoins2 { + const NAME: &'static str = "underlying_coins2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for UnderlyingCoins1 { - 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 UnderlyingCoins2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UnkillMe {} + impl UnkillMe { + const METHOD_ID: [u8; 4] = [48u8, 70u8, 249u8, 114u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct UnderlyingCoins2 { - pub arg0: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for UnkillMe { + const NAME: &'static str = "unkill_me"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl UnderlyingCoins2 { - const METHOD_ID: [u8; 4] = [183u8, 57u8, 149u8, 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::Int(128usize)], - 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_int() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_signed_bytes_be(&v) - }, - }) + 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 WithdrawAdminFees {} + impl WithdrawAdminFees { + const METHOD_ID: [u8; 4] = [48u8, 197u8, 64u8, 133u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for WithdrawAdminFees { + const NAME: &'static str = "withdraw_admin_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() + } + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 3usize], + pub fees: [substreams::scalar::BigInt; 3usize], + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl AddLiquidity { + const TOPIC_ID: [u8; 32] = [ + 66u8, + 63u8, + 100u8, + 149u8, + 160u8, + 143u8, + 198u8, + 82u8, + 66u8, + 92u8, + 244u8, + 237u8, + 13u8, + 31u8, + 158u8, + 55u8, + 229u8, + 113u8, + 217u8, + 185u8, + 82u8, + 155u8, + 28u8, + 28u8, + 35u8, + 204u8, + 231u8, + 128u8, + 178u8, + 231u8, + 223u8, + 13u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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( &[ - { - let non_full_signed_bytes = self.arg0.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()), - ) - }, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( &[ethabi::ParamType::Address], - data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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), + ] + }, + fees: { + 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), + ] + }, + invariant: { + 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 UnderlyingCoins2 { - const NAME: &'static str = "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 UnderlyingCoins2 { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - #[derive(Debug, Clone, PartialEq)] - pub struct UnkillMe {} - impl UnkillMe { - const METHOD_ID: [u8; 4] = [48u8, 70u8, 249u8, 114u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 AddLiquidity { + const NAME: &'static str = "AddLiquidity"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::Function for UnkillMe { - const NAME: &'static str = "unkill_me"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 WithdrawAdminFees {} - impl WithdrawAdminFees { - const METHOD_ID: [u8; 4] = [48u8, 197u8, 64u8, 133u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl substreams_ethereum::Function for WithdrawAdminFees { - const NAME: &'static str = "withdraw_admin_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() - } - } - } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct AddLiquidity { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 3usize], - pub fees: [substreams::scalar::BigInt; 3usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl AddLiquidity { - const TOPIC_ID: [u8; 32] = [ - 66u8, - 63u8, - 100u8, - 149u8, - 160u8, - 143u8, - 198u8, - 82u8, - 66u8, - 92u8, - 244u8, - 237u8, - 13u8, - 31u8, - 158u8, - 55u8, - 229u8, - 113u8, - 217u8, - 185u8, - 82u8, - 155u8, - 28u8, - 28u8, - 35u8, - 204u8, - 231u8, - 128u8, - 178u8, - 231u8, - 223u8, - 13u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - 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 { - provider: ethabi::decode( - &[ethabi::ParamType::Address], + } + #[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 'provider' from topic of type 'address': {:?}", + "unable to decode param 'deadline' from topic of type 'uint256': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 AddLiquidity { - const NAME: &'static str = "AddLiquidity"; - 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 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(), + .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 CommitNewFee { + pub deadline: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub admin_fee: substreams::scalar::BigInt, + pub offpeg_fee_multiplier: substreams::scalar::BigInt, + } + impl CommitNewFee { + const TOPIC_ID: [u8; 32] = [ + 227u8, + 71u8, + 205u8, + 224u8, + 116u8, + 171u8, + 135u8, + 224u8, + 148u8, + 73u8, + 250u8, + 43u8, + 3u8, + 232u8, + 242u8, + 207u8, + 121u8, + 9u8, + 76u8, + 177u8, + 38u8, + 95u8, + 76u8, + 145u8, + 67u8, + 101u8, + 210u8, + 36u8, + 125u8, + 65u8, + 71u8, + 163u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + 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 'admin' from topic of type 'address': {:?}", + "unable to decode param 'deadline' from topic of type 'uint256': {:?}", 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 CommitNewFee { - pub deadline: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - pub offpeg_fee_multiplier: substreams::scalar::BigInt, - } - impl CommitNewFee { - const TOPIC_ID: [u8; 32] = [ - 227u8, - 71u8, - 205u8, - 224u8, - 116u8, - 171u8, - 135u8, - 224u8, - 148u8, - 73u8, - 250u8, - 43u8, - 3u8, - 232u8, - 242u8, - 207u8, - 121u8, - 9u8, - 76u8, - 177u8, - 38u8, - 95u8, - 76u8, - 145u8, - 67u8, - 101u8, - 210u8, - 36u8, - 125u8, - 65u8, - 71u8, - 163u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .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) + }, + 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) + }, + 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) + }, + }) + } + } + impl substreams_ethereum::Event for CommitNewFee { + const NAME: &'static str = "CommitNewFee"; + 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 log.data: {:?}", e))?; - values.reverse(); - 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) - }, - 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) - }, - 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) - }, - 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) - }, - }) - } - } - impl substreams_ethereum::Event for CommitNewFee { - const NAME: &'static str = "CommitNewFee"; - 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 ) - .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) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct NewFee { + pub fee: substreams::scalar::BigInt, + pub admin_fee: substreams::scalar::BigInt, + pub offpeg_fee_multiplier: substreams::scalar::BigInt, + } + impl NewFee { + const TOPIC_ID: [u8; 32] = [ + 207u8, + 202u8, + 150u8, + 224u8, + 254u8, + 243u8, + 67u8, + 33u8, + 70u8, + 145u8, + 59u8, + 42u8, + 90u8, + 34u8, + 104u8, + 165u8, + 93u8, + 63u8, + 71u8, + 95u8, + 224u8, + 87u8, + 231u8, + 255u8, + 222u8, + 16u8, + 130u8, + 183u8, + 118u8, + 147u8, + 244u8, + 243u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + fee: { + let mut v = [0 as u8; 32]; + values .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) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct NewFee { - pub fee: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - pub offpeg_fee_multiplier: substreams::scalar::BigInt, - } - impl NewFee { - const TOPIC_ID: [u8; 32] = [ - 207u8, - 202u8, - 150u8, - 224u8, - 254u8, - 243u8, - 67u8, - 33u8, - 70u8, - 145u8, - 59u8, - 42u8, - 90u8, - 34u8, - 104u8, - 165u8, - 93u8, - 63u8, - 71u8, - 95u8, - 224u8, - 87u8, - 231u8, - 255u8, - 222u8, - 16u8, - 130u8, - 183u8, - 118u8, - 147u8, - 244u8, - 243u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - 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) - }, - 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) - }, - }) - } - } - impl substreams_ethereum::Event for NewFee { - const NAME: &'static str = "NewFee"; - 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 RampA { - pub old_a: substreams::scalar::BigInt, - pub new_a: substreams::scalar::BigInt, - pub initial_time: substreams::scalar::BigInt, - pub future_time: substreams::scalar::BigInt, - } - impl RampA { - const TOPIC_ID: [u8; 32] = [ - 162u8, - 183u8, - 30u8, - 198u8, - 223u8, - 148u8, - 147u8, - 0u8, - 181u8, - 154u8, - 171u8, - 54u8, - 181u8, - 94u8, - 24u8, - 150u8, - 151u8, - 183u8, - 80u8, - 17u8, - 157u8, - 211u8, - 73u8, - 252u8, - 250u8, - 140u8, - 15u8, - 119u8, - 158u8, - 131u8, - 194u8, - 84u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 128usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_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) - }, - new_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) - }, - initial_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) - }, - future_time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for RampA { - const NAME: &'static str = "RampA"; - 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 RemoveLiquidity { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 3usize], - pub fees: [substreams::scalar::BigInt; 3usize], - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidity { - const TOPIC_ID: [u8; 32] = [ - 164u8, - 157u8, - 76u8, - 240u8, - 38u8, - 86u8, - 174u8, - 191u8, - 140u8, - 119u8, - 31u8, - 90u8, - 133u8, - 133u8, - 99u8, - 138u8, - 42u8, - 21u8, - 238u8, - 108u8, - 151u8, - 207u8, - 114u8, - 5u8, - 212u8, - 32u8, - 142u8, - 215u8, - 193u8, - 223u8, - 37u8, - 45u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .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) + }, + 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) + }, + }) + } + } + impl substreams_ethereum::Event for NewFee { + const NAME: &'static str = "NewFee"; + 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 RampA { + pub old_a: substreams::scalar::BigInt, + pub new_a: substreams::scalar::BigInt, + pub initial_time: substreams::scalar::BigInt, + pub future_time: substreams::scalar::BigInt, + } + impl RampA { + const TOPIC_ID: [u8; 32] = [ + 162u8, + 183u8, + 30u8, + 198u8, + 223u8, + 148u8, + 147u8, + 0u8, + 181u8, + 154u8, + 171u8, + 54u8, + 181u8, + 94u8, + 24u8, + 150u8, + 151u8, + 183u8, + 80u8, + 17u8, + 157u8, + 211u8, + 73u8, + 252u8, + 250u8, + 140u8, + 15u8, + 119u8, + 158u8, + 131u8, + 194u8, + 84u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 128usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_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) + }, + new_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) + }, + initial_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) + }, + future_time: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for RampA { + const NAME: &'static str = "RampA"; + 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 RemoveLiquidity { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 3usize], + pub fees: [substreams::scalar::BigInt; 3usize], + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidity { + const TOPIC_ID: [u8; 32] = [ + 164u8, + 157u8, + 76u8, + 240u8, + 38u8, + 86u8, + 174u8, + 191u8, + 140u8, + 119u8, + 31u8, + 90u8, + 133u8, + 133u8, + 99u8, + 138u8, + 42u8, + 21u8, + 238u8, + 108u8, + 151u8, + 207u8, + 114u8, + 5u8, + 212u8, + 32u8, + 142u8, + 215u8, + 193u8, + 223u8, + 37u8, + 45u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidity { - const NAME: &'static str = "RemoveLiquidity"; - 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 RemoveLiquidityImbalance { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 3usize], - pub fees: [substreams::scalar::BigInt; 3usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityImbalance { - const TOPIC_ID: [u8; 32] = [ - 23u8, - 53u8, - 153u8, - 219u8, - 249u8, - 198u8, - 202u8, - 111u8, - 124u8, - 59u8, - 89u8, - 13u8, - 240u8, - 122u8, - 233u8, - 138u8, - 69u8, - 215u8, - 79u8, - 245u8, - 64u8, - 101u8, - 80u8, - 81u8, - 65u8, - 231u8, - 222u8, - 108u8, - 70u8, - 166u8, - 36u8, - 194u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 3usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .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), + ] + }, + fees: { + 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), + ] + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidity { + const NAME: &'static str = "RemoveLiquidity"; + 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 RemoveLiquidityImbalance { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 3usize], + pub fees: [substreams::scalar::BigInt; 3usize], + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidityImbalance { + const TOPIC_ID: [u8; 32] = [ + 23u8, + 53u8, + 153u8, + 219u8, + 249u8, + 198u8, + 202u8, + 111u8, + 124u8, + 59u8, + 89u8, + 13u8, + 240u8, + 122u8, + 233u8, + 138u8, + 69u8, + 215u8, + 79u8, + 245u8, + 64u8, + 101u8, + 80u8, + 81u8, + 65u8, + 231u8, + 222u8, + 108u8, + 70u8, + 166u8, + 36u8, + 194u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + 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 { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityImbalance { - const NAME: &'static str = "RemoveLiquidityImbalance"; - 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 RemoveLiquidityOne { - pub provider: Vec, - pub token_amount: substreams::scalar::BigInt, - pub coin_amount: substreams::scalar::BigInt, - } - impl RemoveLiquidityOne { - const TOPIC_ID: [u8; 32] = [ - 158u8, - 150u8, - 221u8, - 59u8, - 153u8, - 122u8, - 42u8, - 37u8, - 126u8, - 236u8, - 77u8, - 249u8, - 187u8, - 110u8, - 175u8, - 98u8, - 110u8, - 32u8, - 109u8, - 245u8, - 245u8, - 67u8, - 189u8, - 150u8, - 54u8, - 130u8, - 209u8, - 67u8, - 48u8, - 11u8, - 227u8, - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .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), + ] + }, + fees: { + 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), + ] + }, + invariant: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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 RemoveLiquidityImbalance { + const NAME: &'static str = "RemoveLiquidityImbalance"; + 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 RemoveLiquidityOne { + pub provider: Vec, + pub token_amount: substreams::scalar::BigInt, + pub coin_amount: substreams::scalar::BigInt, + } + impl RemoveLiquidityOne { + const TOPIC_ID: [u8; 32] = [ + 158u8, + 150u8, + 221u8, + 59u8, + 153u8, + 122u8, + 42u8, + 37u8, + 126u8, + 236u8, + 77u8, + 249u8, + 187u8, + 110u8, + 175u8, + 98u8, + 110u8, + 32u8, + 109u8, + 245u8, + 245u8, + 67u8, + 189u8, + 150u8, + 54u8, + 130u8, + 209u8, + 67u8, + 48u8, + 11u8, + 227u8, + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amount: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_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) - }, - coin_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 RemoveLiquidityOne { - const NAME: &'static str = "RemoveLiquidityOne"; - 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 StopRampA { - pub a: substreams::scalar::BigInt, - pub t: substreams::scalar::BigInt, - } - impl StopRampA { - const TOPIC_ID: [u8; 32] = [ - 70u8, - 226u8, - 47u8, - 179u8, - 112u8, - 154u8, - 210u8, - 137u8, - 246u8, - 44u8, - 230u8, - 61u8, - 70u8, - 146u8, - 72u8, - 83u8, - 109u8, - 188u8, - 120u8, - 216u8, - 43u8, - 132u8, - 163u8, - 215u8, - 231u8, - 74u8, - 214u8, - 6u8, - 220u8, - 32u8, - 25u8, - 56u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - t: { - let mut v = [0 as u8; 32]; - values - .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 StopRampA { - const NAME: &'static str = "StopRampA"; - 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 TokenExchange { - pub buyer: Vec, - pub sold_id: substreams::scalar::BigInt, - pub tokens_sold: substreams::scalar::BigInt, - pub bought_id: substreams::scalar::BigInt, - pub tokens_bought: substreams::scalar::BigInt, - } - impl TokenExchange { - const TOPIC_ID: [u8; 32] = [ - 139u8, - 62u8, - 150u8, - 242u8, - 184u8, - 137u8, - 250u8, - 119u8, - 28u8, - 83u8, - 201u8, - 129u8, - 180u8, - 13u8, - 175u8, - 0u8, - 95u8, - 99u8, - 246u8, - 55u8, - 241u8, - 134u8, - 159u8, - 112u8, - 112u8, - 82u8, - 209u8, - 90u8, - 61u8, - 217u8, - 113u8, - 64u8, - ]; - 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + coin_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 RemoveLiquidityOne { + const NAME: &'static str = "RemoveLiquidityOne"; + 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 StopRampA { + pub a: substreams::scalar::BigInt, + pub t: substreams::scalar::BigInt, + } + impl StopRampA { + const TOPIC_ID: [u8; 32] = [ + 70u8, + 226u8, + 47u8, + 179u8, + 112u8, + 154u8, + 210u8, + 137u8, + 246u8, + 44u8, + 230u8, + 61u8, + 70u8, + 146u8, + 72u8, + 83u8, + 109u8, + 188u8, + 120u8, + 216u8, + 43u8, + 132u8, + 163u8, + 215u8, + 231u8, + 74u8, + 214u8, + 6u8, + 220u8, + 32u8, + 25u8, + 56u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + 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) + }, + t: { + let mut v = [0 as u8; 32]; + values + .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 StopRampA { + const NAME: &'static str = "StopRampA"; + 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 TokenExchange { + pub buyer: Vec, + pub sold_id: substreams::scalar::BigInt, + pub tokens_sold: substreams::scalar::BigInt, + pub bought_id: substreams::scalar::BigInt, + pub tokens_bought: substreams::scalar::BigInt, + } + impl TokenExchange { + const TOPIC_ID: [u8; 32] = [ + 139u8, + 62u8, + 150u8, + 242u8, + 184u8, + 137u8, + 250u8, + 119u8, + 28u8, + 83u8, + 201u8, + 129u8, + 180u8, + 13u8, + 175u8, + 0u8, + 95u8, + 99u8, + 246u8, + 55u8, + 241u8, + 134u8, + 159u8, + 112u8, + 112u8, + 82u8, + 209u8, + 90u8, + 61u8, + 217u8, + 113u8, + 64u8, + ]; + 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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + buyer: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - buyer: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'buyer' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'buyer' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + sold_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sold_id: { - 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) - }, - tokens_sold: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - bought_id: { - 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) - }, - tokens_bought: { - let mut v = [0 as u8; 32]; - values - .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 TokenExchange { - const NAME: &'static str = "TokenExchange"; - 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 TokenExchangeUnderlying { - pub buyer: Vec, - pub sold_id: substreams::scalar::BigInt, - pub tokens_sold: substreams::scalar::BigInt, - pub bought_id: substreams::scalar::BigInt, - pub tokens_bought: substreams::scalar::BigInt, - } - impl TokenExchangeUnderlying { - const TOPIC_ID: [u8; 32] = [ - 208u8, - 19u8, - 202u8, - 35u8, - 231u8, - 122u8, - 101u8, - 0u8, - 60u8, - 44u8, - 101u8, - 156u8, - 84u8, - 66u8, - 192u8, - 12u8, - 128u8, - 83u8, - 113u8, - 183u8, - 252u8, - 30u8, - 189u8, - 76u8, - 32u8, - 108u8, - 65u8, - 209u8, - 83u8, - 107u8, - 217u8, - 11u8, - ]; - 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + tokens_sold: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + bought_id: { + 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) + }, + tokens_bought: { + let mut v = [0 as u8; 32]; + values + .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 TokenExchange { + const NAME: &'static str = "TokenExchange"; + 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 TokenExchangeUnderlying { + pub buyer: Vec, + pub sold_id: substreams::scalar::BigInt, + pub tokens_sold: substreams::scalar::BigInt, + pub bought_id: substreams::scalar::BigInt, + pub tokens_bought: substreams::scalar::BigInt, + } + impl TokenExchangeUnderlying { + const TOPIC_ID: [u8; 32] = [ + 208u8, + 19u8, + 202u8, + 35u8, + 231u8, + 122u8, + 101u8, + 0u8, + 60u8, + 44u8, + 101u8, + 156u8, + 84u8, + 66u8, + 192u8, + 12u8, + 128u8, + 83u8, + 113u8, + 183u8, + 252u8, + 30u8, + 189u8, + 76u8, + 32u8, + 108u8, + 65u8, + 209u8, + 83u8, + 107u8, + 217u8, + 11u8, + ]; + 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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + buyer: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - buyer: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'buyer' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'buyer' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + sold_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sold_id: { - 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) - }, - tokens_sold: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - bought_id: { - 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) - }, - tokens_bought: { - let mut v = [0 as u8; 32]; - values - .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) + }, + tokens_sold: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + bought_id: { + 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) + }, + tokens_bought: { + let mut v = [0 as u8; 32]; + values + .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 TokenExchangeUnderlying { - const NAME: &'static str = "TokenExchangeUnderlying"; - 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 TokenExchangeUnderlying { + const NAME: &'static str = "TokenExchangeUnderlying"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/abi/curve/pools/metapool_old.rs b/src/abi/curve/pools/metapool_old.rs index 7bb7323..ef25644 100644 --- a/src/abi/curve/pools/metapool_old.rs +++ b/src/abi/curve/pools/metapool_old.rs @@ -1,4004 +1,5302 @@ - 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 A {} - impl A { - const METHOD_ID: [u8; 4] = [244u8, 70u8, 193u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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 - } +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 A {} + impl A { + const METHOD_ID: [u8; 4] = [244u8, 70u8, 193u8, 208u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + 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 A { - const NAME: &'static str = "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::Function for A { + const NAME: &'static str = "A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for A { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct APrecise {} - impl APrecise { - const METHOD_ID: [u8; 4] = [118u8, 162u8, 240u8, 240u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 - } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for A { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct APrecise {} + impl APrecise { + const METHOD_ID: [u8; 4] = [118u8, 162u8, 240u8, 240u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 APrecise { - const NAME: &'static str = "A_precise"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 APrecise { + const NAME: &'static str = "A_precise"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for APrecise { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AddLiquidity { - pub u_amounts: [substreams::scalar::BigInt; 2usize], - pub u_min_mint_amount: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl AddLiquidity { - const METHOD_ID: [u8; 4] = [11u8, 76u8, 126u8, 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - u_min_mint_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable + for APrecise { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity { + pub u_amounts: [substreams::scalar::BigInt; 2usize], + pub u_min_mint_amount: substreams::scalar::BigInt, + } + impl AddLiquidity { + const METHOD_ID: [u8; 4] = [11u8, 76u8, 126u8, 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( &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_min_mint_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amounts: { + 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)] + }, + u_min_mint_amount: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_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::FixedArray(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_min_mint_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for AddLiquidity { + const NAME: &'static str = "add_liquidity"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AddLiquidity { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AdminActionsDeadline {} + impl AdminActionsDeadline { + const METHOD_ID: [u8; 4] = [64u8, 94u8, 40u8, 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 { + 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 AddLiquidity { - const NAME: &'static str = "add_liquidity"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AdminActionsDeadline { + const NAME: &'static str = "admin_actions_deadline"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AddLiquidity { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminActionsDeadline {} - impl AdminActionsDeadline { - const METHOD_ID: [u8; 4] = [64u8, 94u8, 40u8, 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 { - 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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for AdminActionsDeadline { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AdminBalances { + pub i: substreams::scalar::BigInt, + } + impl AdminBalances { + const METHOD_ID: [u8; 4] = [226u8, 231u8, 210u8, 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::Uint(256usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { 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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + 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 { + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for AdminBalances { + const NAME: &'static str = "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 AdminBalances { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AdminFee {} + impl AdminFee { + const METHOD_ID: [u8; 4] = [254u8, 227u8, 247u8, 249u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 AdminActionsDeadline { - const NAME: &'static str = "admin_actions_deadline"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AdminFee { + const NAME: &'static str = "admin_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::rpc::RPCDecodable - for AdminActionsDeadline { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::rpc::RPCDecodable + for AdminFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ApplyNewFee {} + impl ApplyNewFee { + const METHOD_ID: [u8; 4] = [79u8, 18u8, 254u8, 151u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminBalances { - pub i: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for ApplyNewFee { + const NAME: &'static str = "apply_new_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl AdminBalances { - const METHOD_ID: [u8; 4] = [226u8, 231u8, 210u8, 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::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - }) + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ApplyTransferOwnership {} + impl ApplyTransferOwnership { + const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 match_call(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.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 { - 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({ + } + } + impl substreams_ethereum::Function for ApplyTransferOwnership { + const NAME: &'static str = "apply_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 Balances { + pub arg0: substreams::scalar::BigInt, + } + impl Balances { + const METHOD_ID: [u8; 4] = [73u8, 3u8, 176u8, 209u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::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") + .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 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::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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for Balances { + const NAME: &'static str = "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 Balances { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BaseCacheUpdated {} + impl BaseCacheUpdated { + const METHOD_ID: [u8; 4] = [130u8, 150u8, 248u8, 79u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 AdminBalances { - const NAME: &'static str = "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::Function for BaseCacheUpdated { + const NAME: &'static str = "base_cache_updated"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AdminBalances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminFee {} - impl AdminFee { - const METHOD_ID: [u8; 4] = [254u8, 227u8, 247u8, 249u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for BaseCacheUpdated { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BaseCoins { + pub arg0: substreams::scalar::BigInt, + } + impl BaseCoins { + const METHOD_ID: [u8; 4] = [135u8, 203u8, 79u8, 87u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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 AdminFee { - const NAME: &'static str = "admin_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 BaseCoins { + const NAME: &'static str = "base_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for AdminFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ApplyNewFee {} - impl ApplyNewFee { - const METHOD_ID: [u8; 4] = [79u8, 18u8, 254u8, 151u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for BaseCoins { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl substreams_ethereum::Function for ApplyNewFee { - const NAME: &'static str = "apply_new_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ApplyTransferOwnership {} - impl ApplyTransferOwnership { - const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 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 BasePool {} + impl BasePool { + const METHOD_ID: [u8; 4] = [93u8, 99u8, 98u8, 187u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for ApplyTransferOwnership { - const NAME: &'static str = "apply_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 BasePool { + const NAME: &'static str = "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) } - #[derive(Debug, Clone, PartialEq)] - pub struct Balances { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for BasePool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl Balances { - const METHOD_ID: [u8; 4] = [73u8, 3u8, 176u8, 209u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct BaseVirtualPrice {} + impl BaseVirtualPrice { + const METHOD_ID: [u8; 4] = [149u8, 204u8, 192u8, 47u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - 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( + } + } + impl substreams_ethereum::Function for BaseVirtualPrice { + const NAME: &'static str = "base_virtual_price"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for BaseVirtualPrice { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CalcTokenAmount { + pub u_amounts: [substreams::scalar::BigInt; 2usize], + pub u_is_deposit: bool, + } + impl CalcTokenAmount { + const METHOD_ID: [u8; 4] = [237u8, 142u8, 132u8, 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::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::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), + ethabi::ParamType::Bool, ], - ); - let mut encoded = Vec::with_capacity(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 + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amounts: { + let mut iter = 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 - } + .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)] + }, + u_is_deposit: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_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::FixedArray(v) + }, + ethabi::Token::Bool(self.u_is_deposit.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 { + 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 Balances { - const NAME: &'static str = "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::Function for CalcTokenAmount { + const NAME: &'static str = "calc_token_amount"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Balances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct BaseCacheUpdated {} - impl BaseCacheUpdated { - const METHOD_ID: [u8; 4] = [130u8, 150u8, 248u8, 79u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for CalcTokenAmount { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CalcWithdrawOneCoin { + pub u_token_amount: substreams::scalar::BigInt, + pub i: substreams::scalar::BigInt, + } + impl CalcWithdrawOneCoin { + const METHOD_ID: [u8; 4] = [204u8, 43u8, 39u8, 215u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Int(128usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_token_amount: { 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 BaseCacheUpdated { - const NAME: &'static str = "base_cache_updated"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for BaseCacheUpdated { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BaseCoins { - pub arg0: substreams::scalar::BigInt, - } - impl BaseCoins { - const METHOD_ID: [u8; 4] = [135u8, 203u8, 79u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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( + }, + i: { + 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(), + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_token_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let non_full_signed_bytes = self.i.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()), + ) + }, + ], + ); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 BaseCoins { - const NAME: &'static str = "base_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 BaseCoins { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + } + impl substreams_ethereum::Function for CalcWithdrawOneCoin { + const NAME: &'static str = "calc_withdraw_one_coin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePool {} - impl BasePool { - const METHOD_ID: [u8; 4] = [93u8, 99u8, 98u8, 187u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for BasePool { - const NAME: &'static str = "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() - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::rpc::RPCDecodable> for BasePool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + } + impl substreams_ethereum::rpc::RPCDecodable + for CalcWithdrawOneCoin { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct BaseVirtualPrice {} - impl BaseVirtualPrice { - const METHOD_ID: [u8; 4] = [149u8, 204u8, 192u8, 47u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 Coins { + pub arg0: substreams::scalar::BigInt, + } + impl Coins { + const METHOD_ID: [u8; 4] = [198u8, 97u8, 6u8, 87u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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") + .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 - } + }, + }) + } + 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 BaseVirtualPrice { - const NAME: &'static str = "base_virtual_price"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Coins { + const NAME: &'static str = "coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for BaseVirtualPrice { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CalcTokenAmount { - pub u_amounts: [substreams::scalar::BigInt; 2usize], - pub u_is_deposit: bool, + fn encode(&self) -> Vec { + self.encode() } - impl CalcTokenAmount { - const METHOD_ID: [u8; 4] = [237u8, 142u8, 132u8, 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - u_is_deposit: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + impl substreams_ethereum::rpc::RPCDecodable> for Coins { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CommitNewFee { + pub u_new_fee: substreams::scalar::BigInt, + pub u_new_admin_fee: substreams::scalar::BigInt, + } + impl CommitNewFee { + const METHOD_ID: [u8; 4] = [91u8, 90u8, 20u8, 103u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Bool(self.u_is_deposit.clone()), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_new_fee: { 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 - } - } - } + }, + u_new_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) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_new_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.u_new_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(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for CalcTokenAmount { - const NAME: &'static str = "calc_token_amount"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 CalcTokenAmount { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for CommitNewFee { + const NAME: &'static str = "commit_new_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 u_owner: 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 { + u_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner))], + ); + 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 CalcWithdrawOneCoin { - pub u_token_amount: substreams::scalar::BigInt, - pub i: substreams::scalar::BigInt, + } + 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 CalcWithdrawOneCoin { - const METHOD_ID: [u8; 4] = [204u8, 43u8, 39u8, 215u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_token_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) - }, - i: { - 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) - }, - }) + 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 DonateAdminFees {} + impl DonateAdminFees { + const METHOD_ID: [u8; 4] = [82u8, 76u8, 57u8, 1u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for DonateAdminFees { + const NAME: &'static str = "donate_admin_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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Exchange { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub u_dx: substreams::scalar::BigInt, + pub u_min_dy: substreams::scalar::BigInt, + } + impl Exchange { + const METHOD_ID: [u8; 4] = [61u8, 240u8, 33u8, 36u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_token_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - { - let non_full_signed_bytes = self.i.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()), - ) - }, + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { + 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) + }, + j: { + 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) + }, + u_dx: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_min_dy: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.i.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()), + ) + }, + { + let non_full_signed_bytes = self.j.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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_dx.clone().to_bytes_be() { + (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.u_min_dy.clone().to_bytes_be() { + (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 CalcWithdrawOneCoin { - const NAME: &'static str = "calc_withdraw_one_coin"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Exchange { + const NAME: &'static str = "exchange"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for CalcWithdrawOneCoin { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Coins { - pub arg0: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Coins { - const METHOD_ID: [u8; 4] = [198u8, 97u8, 6u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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( + } + impl substreams_ethereum::rpc::RPCDecodable + for Exchange { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ExchangeUnderlying { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub u_dx: substreams::scalar::BigInt, + pub u_min_dy: substreams::scalar::BigInt, + } + impl ExchangeUnderlying { + const METHOD_ID: [u8; 4] = [166u8, 65u8, 126u8, 214u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - 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::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { + 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) + }, + j: { + 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) + }, + u_dx: { + 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(), + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_min_dy: { + let mut v = [0 as u8; 32]; + values + .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( + &[ + { + let non_full_signed_bytes = self.i.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()), + ) + }, + { + let non_full_signed_bytes = self.j.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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_dx.clone().to_bytes_be() { + (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.u_min_dy.clone().to_bytes_be() { + (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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for ExchangeUnderlying { + const NAME: &'static str = "exchange_underlying"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for ExchangeUnderlying { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Fee {} + impl Fee { + const METHOD_ID: [u8; 4] = [221u8, 202u8, 63u8, 67u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 Coins { - const NAME: &'static str = "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::Function for Fee { + const NAME: &'static str = "fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for Coins { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitNewFee { - pub u_new_fee: substreams::scalar::BigInt, - pub u_new_admin_fee: substreams::scalar::BigInt, + } + impl substreams_ethereum::rpc::RPCDecodable for Fee { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl CommitNewFee { - const METHOD_ID: [u8; 4] = [91u8, 90u8, 20u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::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 FutureA {} + impl FutureA { + const METHOD_ID: [u8; 4] = [180u8, 181u8, 119u8, 173u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - 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 { - u_new_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) - }, - u_new_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) - }, - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_new_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.u_new_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(), - ), - ), - ], - ); - 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 FutureA { + const NAME: &'static str = "future_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 FutureA { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureATime {} + impl FutureATime { + const METHOD_ID: [u8; 4] = [20u8, 5u8, 34u8, 136u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 CommitNewFee { - const NAME: &'static str = "commit_new_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 FutureATime { + const NAME: &'static str = "future_A_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitTransferOwnership { - pub u_owner: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner))], - ); - 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::rpc::RPCDecodable + for FutureATime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureAdminFee {} + impl FutureAdminFee { + const METHOD_ID: [u8; 4] = [227u8, 130u8, 68u8, 98u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 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 DonateAdminFees {} - impl DonateAdminFees { - const METHOD_ID: [u8; 4] = [82u8, 76u8, 57u8, 1u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 FutureAdminFee { + const NAME: &'static str = "future_admin_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureAdminFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureFee {} + impl FutureFee { + const METHOD_ID: [u8; 4] = [88u8, 104u8, 13u8, 11u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 DonateAdminFees { - const NAME: &'static str = "donate_admin_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::Function for FutureFee { + const NAME: &'static str = "future_fee"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Exchange { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub u_dx: substreams::scalar::BigInt, - pub u_min_dy: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl Exchange { - const METHOD_ID: [u8; 4] = [61u8, 240u8, 33u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + impl substreams_ethereum::rpc::RPCDecodable + for FutureFee { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FutureOwner {} + impl FutureOwner { + const METHOD_ID: [u8; 4] = [30u8, 192u8, 205u8, 193u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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::Int(128usize), - ethabi::ParamType::Int(128usize), - 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 { - i: { - 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) - }, - j: { - 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) - }, - u_dx: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_min_dy: { - let mut v = [0 as u8; 32]; - values - .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( + } + } + impl substreams_ethereum::Function for FutureOwner { + const NAME: &'static str = "future_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 FutureOwner { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDy { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub u_dx: substreams::scalar::BigInt, + } + impl GetDy { + const METHOD_ID: [u8; 4] = [94u8, 13u8, 68u8, 63u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { + 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) + }, + j: { + 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) + }, + u_dx: { + let mut v = [0 as u8; 32]; + values + .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( + &[ + { + let non_full_signed_bytes = self.i.to_signed_bytes_be(); + let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 + == 0x80 { - let non_full_signed_bytes = self.i.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()), - ) - }, + 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()), + ) + }, + { + let non_full_signed_bytes = self.j.to_signed_bytes_be(); + let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 + == 0x80 { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_dx.clone().to_bytes_be() { - (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.u_min_dy.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } + 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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_dx.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") } - .as_slice(), - ), + } + .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 GetDy { + const NAME: &'static str = "get_dy"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for GetDy { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDyUnderlying { + pub i: substreams::scalar::BigInt, + pub j: substreams::scalar::BigInt, + pub u_dx: substreams::scalar::BigInt, + } + impl GetDyUnderlying { + const METHOD_ID: [u8; 4] = [7u8, 33u8, 30u8, 247u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + i: { + 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) + }, + j: { + 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) + }, + u_dx: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let non_full_signed_bytes = self.i.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()), + ) + }, + { + let non_full_signed_bytes = self.j.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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_dx.clone().to_bytes_be() { + (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 Exchange { - const NAME: &'static str = "exchange"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetDyUnderlying { + const NAME: &'static str = "get_dy_underlying"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for Exchange { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ExchangeUnderlying { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub u_dx: substreams::scalar::BigInt, - pub u_min_dy: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - impl ExchangeUnderlying { - const METHOD_ID: [u8; 4] = [166u8, 65u8, 126u8, 214u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); + } + impl substreams_ethereum::rpc::RPCDecodable + for GetDyUnderlying { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetVirtualPrice {} + impl GetVirtualPrice { + const METHOD_ID: [u8; 4] = [187u8, 123u8, 139u8, 128u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - 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 { - i: { - 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) - }, - j: { - 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) - }, - u_dx: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_min_dy: { - let mut v = [0 as u8; 32]; - values - .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( - &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_dx.clone().to_bytes_be() { - (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.u_min_dy.clone().to_bytes_be() { - (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, + } + } + impl substreams_ethereum::Function for GetVirtualPrice { + const NAME: &'static str = "get_virtual_price"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetVirtualPrice { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InitialA {} + impl InitialA { + const METHOD_ID: [u8; 4] = [84u8, 9u8, 73u8, 26u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + } + impl substreams_ethereum::Function for InitialA { + const NAME: &'static str = "initial_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 InitialA { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct InitialATime {} + impl InitialATime { + const METHOD_ID: [u8; 4] = [32u8, 129u8, 6u8, 108u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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 ExchangeUnderlying { - const NAME: &'static str = "exchange_underlying"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 InitialATime { + const NAME: &'static str = "initial_A_time"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for ExchangeUnderlying { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct Fee {} - impl Fee { - const METHOD_ID: [u8; 4] = [221u8, 202u8, 63u8, 67u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) + } + impl substreams_ethereum::rpc::RPCDecodable + for InitialATime { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct KillMe {} + impl KillMe { + const METHOD_ID: [u8; 4] = [227u8, 105u8, 136u8, 83u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + } + } + impl substreams_ethereum::Function for KillMe { + const NAME: &'static str = "kill_me"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LpToken {} + impl LpToken { + const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) + } + } + impl substreams_ethereum::Function for LpToken { + const NAME: &'static str = "lp_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 LpToken { + fn output(data: &[u8]) -> Result, String> { + 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 + } } - 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({ + } + } + 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 RampA { + pub u_future_a: substreams::scalar::BigInt, + pub u_future_time: substreams::scalar::BigInt, + } + impl RampA { + const METHOD_ID: [u8; 4] = [60u8, 21u8, 126u8, 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_future_a: { 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 Fee { - const NAME: &'static str = "fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for Fee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureA {} - impl FutureA { - const METHOD_ID: [u8; 4] = [180u8, 181u8, 119u8, 173u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + u_future_time: { 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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_future_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.u_future_time.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for FutureA { - const NAME: &'static str = "future_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() + pub fn 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 FutureA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Function for RampA { + const NAME: &'static str = "ramp_A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureATime {} - impl FutureATime { - const METHOD_ID: [u8; 4] = [20u8, 5u8, 34u8, 136u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + 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 RemoveLiquidity { + pub u_amount: substreams::scalar::BigInt, + pub u_min_amounts: [substreams::scalar::BigInt; 2usize], + } + impl RemoveLiquidity { + const METHOD_ID: [u8; 4] = [91u8, 54u8, 56u8, 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::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 { + u_amount: { 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(), } + }, + u_min_amounts: { + 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::Uint( + ethabi::Uint::from_big_endian( + match self.u_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let v = self + .u_min_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::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<[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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 FutureATime { - const NAME: &'static str = "future_A_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RemoveLiquidity { + const NAME: &'static str = "remove_liquidity"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureATime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdminFee {} - impl FutureAdminFee { - const METHOD_ID: [u8; 4] = [227u8, 130u8, 68u8, 98u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 2usize]> + for RemoveLiquidity { + fn output(data: &[u8]) -> Result<[substreams::scalar::BigInt; 2usize], String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityImbalance { + pub u_amounts: [substreams::scalar::BigInt; 2usize], + pub u_max_burn_amount: substreams::scalar::BigInt, + } + impl RemoveLiquidityImbalance { + const METHOD_ID: [u8; 4] = [227u8, 16u8, 50u8, 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::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_amounts: { + 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)] + }, + u_max_burn_amount: { 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 - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_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::FixedArray(v) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_max_burn_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::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 FutureAdminFee { - const NAME: &'static str = "future_admin_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RemoveLiquidityImbalance { + const NAME: &'static str = "remove_liquidity_imbalance"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureAdminFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureFee {} - impl FutureFee { - const METHOD_ID: [u8; 4] = [88u8, 104u8, 13u8, 11u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RemoveLiquidityImbalance { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityOneCoin { + pub u_token_amount: substreams::scalar::BigInt, + pub i: substreams::scalar::BigInt, + pub u_min_amount: substreams::scalar::BigInt, + } + impl RemoveLiquidityOneCoin { + const METHOD_ID: [u8; 4] = [26u8, 77u8, 1u8, 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::Uint(256usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_token_amount: { 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 - } + }, + i: { + 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) + }, + u_min_amount: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_token_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + { + let non_full_signed_bytes = self.i.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()), + ) + }, + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_min_amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::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 FutureFee { - const NAME: &'static str = "future_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 RemoveLiquidityOneCoin { + const NAME: &'static str = "remove_liquidity_one_coin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for FutureFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureOwner {} - impl FutureOwner { - const METHOD_ID: [u8; 4] = [30u8, 192u8, 205u8, 193u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for RemoveLiquidityOneCoin { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RevertNewParameters {} + impl RevertNewParameters { + const METHOD_ID: [u8; 4] = [34u8, 104u8, 64u8, 251u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + } + } + impl substreams_ethereum::Function for RevertNewParameters { + const NAME: &'static str = "revert_new_parameters"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 RevertTransferOwnership {} + impl RevertTransferOwnership { + const METHOD_ID: [u8; 4] = [134u8, 251u8, 241u8, 147u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) + } + } + impl substreams_ethereum::Function for RevertTransferOwnership { + const NAME: &'static str = "revert_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 StopRampA {} + impl StopRampA { + const METHOD_ID: [u8; 4] = [85u8, 26u8, 101u8, 136u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + } + impl substreams_ethereum::Function for StopRampA { + const NAME: &'static str = "stop_ramp_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() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TransferOwnershipDeadline {} + impl TransferOwnershipDeadline { + const METHOD_ID: [u8; 4] = [224u8, 160u8, 181u8, 134u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 FutureOwner { - const NAME: &'static str = "future_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::Function for TransferOwnershipDeadline { + const NAME: &'static str = "transfer_ownership_deadline"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FutureOwner { - 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 TransferOwnershipDeadline { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UnkillMe {} + impl UnkillMe { + const METHOD_ID: [u8; 4] = [48u8, 70u8, 249u8, 114u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDy { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub u_dx: substreams::scalar::BigInt, + } + impl substreams_ethereum::Function for UnkillMe { + const NAME: &'static str = "unkill_me"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl GetDy { - const METHOD_ID: [u8; 4] = [94u8, 13u8, 68u8, 63u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - i: { - 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) - }, - j: { - 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) - }, - u_dx: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) + 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 WithdrawAdminFees {} + impl WithdrawAdminFees { + const METHOD_ID: [u8; 4] = [48u8, 197u8, 64u8, 133u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + 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 encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for WithdrawAdminFees { + const NAME: &'static str = "withdraw_admin_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() + } + } +} +/// Contract's events. +#[allow(dead_code, unused_imports, unused_variables)] +pub mod events { + use super::INTERNAL_ERR; + #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 2usize], + pub fees: [substreams::scalar::BigInt; 2usize], + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl AddLiquidity { + const TOPIC_ID: [u8; 32] = [ + 38u8, + 245u8, + 90u8, + 133u8, + 8u8, + 29u8, + 36u8, + 151u8, + 78u8, + 133u8, + 198u8, + 192u8, + 0u8, + 69u8, + 208u8, + 240u8, + 69u8, + 57u8, + 145u8, + 233u8, + 88u8, + 115u8, + 245u8, + 43u8, + 255u8, + 13u8, + 33u8, + 175u8, + 64u8, + 121u8, + 167u8, + 104u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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( &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_dx.clone().to_bytes_be() { - (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::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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(), + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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)] + }, + fees: { + 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)] + }, + invariant: { 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 GetDy { - const NAME: &'static str = "get_dy"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for GetDy { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDyUnderlying { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub u_dx: substreams::scalar::BigInt, - } - impl GetDyUnderlying { - const METHOD_ID: [u8; 4] = [7u8, 33u8, 30u8, 247u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - i: { - 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) - }, - j: { - 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) - }, - u_dx: { - let mut v = [0 as u8; 32]; - values - .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( - &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_dx.clone().to_bytes_be() { - (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({ + }, + token_supply: { 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 GetDyUnderlying { - const NAME: &'static str = "get_dy_underlying"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Event for AddLiquidity { + const NAME: &'static str = "AddLiquidity"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable - for GetDyUnderlying { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetVirtualPrice {} - impl GetVirtualPrice { - const METHOD_ID: [u8; 4] = [187u8, 123u8, 139u8, 128u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 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]; - values + 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("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 - } - } - } + }, + 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::Function for GetVirtualPrice { - const NAME: &'static str = "get_virtual_price"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + 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) } - impl substreams_ethereum::rpc::RPCDecodable - for GetVirtualPrice { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct InitialA {} - impl InitialA { - const METHOD_ID: [u8; 4] = [84u8, 9u8, 73u8, 26u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 CommitNewFee { + pub deadline: substreams::scalar::BigInt, + pub fee: substreams::scalar::BigInt, + pub admin_fee: substreams::scalar::BigInt, + } + impl CommitNewFee { + const TOPIC_ID: [u8; 32] = [ + 53u8, + 31u8, + 197u8, + 218u8, + 47u8, + 191u8, + 72u8, + 15u8, + 34u8, + 37u8, + 222u8, + 191u8, + 54u8, + 100u8, + 164u8, + 188u8, + 144u8, + 250u8, + 153u8, + 35u8, + 116u8, + 58u8, + 173u8, + 88u8, + 180u8, + 96u8, + 63u8, + 100u8, + 142u8, + 147u8, + 31u8, + 224u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + 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) + }, + fee: { 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 InitialA { - const NAME: &'static str = "initial_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 InitialA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct InitialATime {} - impl InitialATime { - const METHOD_ID: [u8; 4] = [32u8, 129u8, 6u8, 108u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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({ + }, + admin_fee: { 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 InitialATime { - const NAME: &'static str = "initial_A_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for InitialATime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + }, + }) } - #[derive(Debug, Clone, PartialEq)] - pub struct KillMe {} - impl KillMe { - const METHOD_ID: [u8; 4] = [227u8, 105u8, 136u8, 83u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 CommitNewFee { + const NAME: &'static str = "CommitNewFee"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::Function for KillMe { - const NAME: &'static str = "kill_me"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct LpToken {} - impl LpToken { - const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( + } + #[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], - data.as_ref(), + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .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::Function for LpToken { - const NAME: &'static str = "lp_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::Event for NewAdmin { + const NAME: &'static str = "NewAdmin"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable> for LpToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[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( + } + #[derive(Debug, Clone, PartialEq)] + pub struct NewFee { + pub fee: substreams::scalar::BigInt, + pub admin_fee: substreams::scalar::BigInt, + } + impl NewFee { + const TOPIC_ID: [u8; 32] = [ + 190u8, + 18u8, + 133u8, + 155u8, + 99u8, + 106u8, + 237u8, + 96u8, + 125u8, + 82u8, + 48u8, + 178u8, + 204u8, + 39u8, + 17u8, + 246u8, + 141u8, + 112u8, + 229u8, + 16u8, + 96u8, + 230u8, + 204u8, + 161u8, + 245u8, + 117u8, + 239u8, + 93u8, + 47u8, + 204u8, + 149u8, + 209u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + fee: { + 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 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() - } + .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) + }, + }) } - impl substreams_ethereum::rpc::RPCDecodable> for Owner { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + } + impl substreams_ethereum::Event for NewFee { + const NAME: &'static str = "NewFee"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct RampA { - pub u_future_a: substreams::scalar::BigInt, - pub u_future_time: substreams::scalar::BigInt, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl RampA { - const METHOD_ID: [u8; 4] = [60u8, 21u8, 126u8, 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_future_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) - }, - u_future_time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct RampA { + pub old_a: substreams::scalar::BigInt, + pub new_a: substreams::scalar::BigInt, + pub initial_time: substreams::scalar::BigInt, + pub future_time: substreams::scalar::BigInt, + } + impl RampA { + const TOPIC_ID: [u8; 32] = [ + 162u8, + 183u8, + 30u8, + 198u8, + 223u8, + 148u8, + 147u8, + 0u8, + 181u8, + 154u8, + 171u8, + 54u8, + 181u8, + 94u8, + 24u8, + 150u8, + 151u8, + 183u8, + 80u8, + 17u8, + 157u8, + 211u8, + 73u8, + 252u8, + 250u8, + 140u8, + 15u8, + 119u8, + 158u8, + 131u8, + 194u8, + 84u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 1usize { + return false; + } + if log.data.len() != 128usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_future_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.u_future_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::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - 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, - } - } + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + old_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) + }, + new_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) + }, + initial_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) + }, + future_time: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Function for RampA { - const NAME: &'static str = "ramp_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::Event for RampA { + const NAME: &'static str = "RampA"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidity { - pub u_amount: substreams::scalar::BigInt, - pub u_min_amounts: [substreams::scalar::BigInt; 2usize], + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl RemoveLiquidity { - const METHOD_ID: [u8; 4] = [91u8, 54u8, 56u8, 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::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 { - u_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) - }, - u_min_amounts: { - 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( + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidity { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 2usize], + pub fees: [substreams::scalar::BigInt; 2usize], + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidity { + const TOPIC_ID: [u8; 32] = [ + 124u8, + 54u8, + 56u8, + 84u8, + 204u8, + 247u8, + 150u8, + 35u8, + 65u8, + 31u8, + 137u8, + 149u8, + 179u8, + 98u8, + 188u8, + 229u8, + 237u8, + 223u8, + 241u8, + 140u8, + 146u8, + 126u8, + 220u8, + 111u8, + 93u8, + 187u8, + 181u8, + 224u8, + 88u8, + 25u8, + 168u8, + 44u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), - { - let v = self - .u_min_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::FixedArray(v) - }, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, + ), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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(), + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -4011,2207 +5309,691 @@ 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 RemoveLiquidity { - const NAME: &'static str = "remove_liquidity"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - 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 RemoveLiquidity { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidityImbalance { - pub u_amounts: [substreams::scalar::BigInt; 2usize], - pub u_max_burn_amount: substreams::scalar::BigInt, - } - impl RemoveLiquidityImbalance { - const METHOD_ID: [u8; 4] = [227u8, 16u8, 50u8, 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - u_max_burn_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_max_burn_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + }, + fees: { + 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)] + }, + token_supply: { 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 RemoveLiquidityImbalance { - const NAME: &'static str = "remove_liquidity_imbalance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + }, + }) } - impl substreams_ethereum::rpc::RPCDecodable - for RemoveLiquidityImbalance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + impl substreams_ethereum::Event for RemoveLiquidity { + const NAME: &'static str = "RemoveLiquidity"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidityOneCoin { - pub u_token_amount: substreams::scalar::BigInt, - pub i: substreams::scalar::BigInt, - pub u_min_amount: substreams::scalar::BigInt, + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl RemoveLiquidityOneCoin { - const METHOD_ID: [u8; 4] = [26u8, 77u8, 1u8, 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::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_token_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) - }, - i: { - 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) - }, - u_min_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityImbalance { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 2usize], + pub fees: [substreams::scalar::BigInt; 2usize], + pub invariant: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidityImbalance { + const TOPIC_ID: [u8; 32] = [ + 43u8, + 85u8, + 8u8, + 55u8, + 141u8, + 126u8, + 25u8, + 224u8, + 213u8, + 250u8, + 51u8, + 132u8, + 25u8, + 3u8, + 71u8, + 49u8, + 65u8, + 108u8, + 79u8, + 91u8, + 33u8, + 154u8, + 16u8, + 55u8, + 153u8, + 86u8, + 247u8, + 100u8, + 49u8, + 127u8, + 212u8, + 126u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_token_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), - { - let non_full_signed_bytes = self.i.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_min_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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(), + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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)] + }, + fees: { + 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)] + }, + invariant: { 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 RemoveLiquidityOneCoin { - const NAME: &'static str = "remove_liquidity_one_coin"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for RemoveLiquidityOneCoin { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RevertNewParameters {} - impl RevertNewParameters { - const METHOD_ID: [u8; 4] = [34u8, 104u8, 64u8, 251u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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, - } - } + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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::Function for RevertNewParameters { - const NAME: &'static str = "revert_new_parameters"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 RevertTransferOwnership {} - impl RevertTransferOwnership { - const METHOD_ID: [u8; 4] = [134u8, 251u8, 241u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 RemoveLiquidityImbalance { + const NAME: &'static str = "RemoveLiquidityImbalance"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::Function for RevertTransferOwnership { - const NAME: &'static str = "revert_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 StopRampA {} - impl StopRampA { - const METHOD_ID: [u8; 4] = [85u8, 26u8, 101u8, 136u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - impl substreams_ethereum::Function for StopRampA { - const NAME: &'static str = "stop_ramp_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferOwnershipDeadline {} - impl TransferOwnershipDeadline { - const METHOD_ID: [u8; 4] = [224u8, 160u8, 181u8, 134u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityOne { + pub provider: Vec, + pub token_amount: substreams::scalar::BigInt, + pub coin_amount: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + } + impl RemoveLiquidityOne { + const TOPIC_ID: [u8; 32] = [ + 90u8, + 208u8, + 86u8, + 242u8, + 226u8, + 138u8, + 140u8, + 236u8, + 35u8, + 32u8, + 21u8, + 64u8, + 107u8, + 132u8, + 54u8, + 104u8, + 193u8, + 227u8, + 108u8, + 218u8, + 89u8, + 129u8, + 39u8, + 236u8, + 59u8, + 140u8, + 89u8, + 184u8, + 199u8, + 39u8, + 115u8, + 160u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amount: { 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 - } - } - } + }, + coin_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) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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::Function for TransferOwnershipDeadline { - const NAME: &'static str = "transfer_ownership_deadline"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::Event for RemoveLiquidityOne { + const NAME: &'static str = "RemoveLiquidityOne"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::rpc::RPCDecodable - for TransferOwnershipDeadline { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct UnkillMe {} - impl UnkillMe { - const METHOD_ID: [u8; 4] = [48u8, 70u8, 249u8, 114u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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, - } - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct StopRampA { + pub a: substreams::scalar::BigInt, + pub t: substreams::scalar::BigInt, + } + impl StopRampA { + const TOPIC_ID: [u8; 32] = [ + 70u8, + 226u8, + 47u8, + 179u8, + 112u8, + 154u8, + 210u8, + 137u8, + 246u8, + 44u8, + 230u8, + 61u8, + 70u8, + 146u8, + 72u8, + 83u8, + 109u8, + 188u8, + 120u8, + 216u8, + 43u8, + 132u8, + 163u8, + 215u8, + 231u8, + 74u8, + 214u8, + 6u8, + 220u8, + 32u8, + 25u8, + 56u8, + ]; + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + 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) + }, + t: { + let mut v = [0 as u8; 32]; + values + .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::Function for UnkillMe { - const NAME: &'static str = "unkill_me"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 WithdrawAdminFees {} - impl WithdrawAdminFees { - const METHOD_ID: [u8; 4] = [48u8, 197u8, 64u8, 133u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 StopRampA { + const NAME: &'static str = "StopRampA"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - impl substreams_ethereum::Function for WithdrawAdminFees { - const NAME: &'static str = "withdraw_admin_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() - } - } - } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct AddLiquidity { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fees: [substreams::scalar::BigInt; 2usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl AddLiquidity { - const TOPIC_ID: [u8; 32] = [ - 38u8, - 245u8, - 90u8, - 133u8, - 8u8, - 29u8, - 36u8, - 151u8, - 78u8, - 133u8, - 198u8, - 192u8, - 0u8, - 69u8, - 208u8, - 240u8, - 69u8, - 57u8, - 145u8, - 233u8, - 88u8, - 115u8, - 245u8, - 43u8, - 255u8, - 13u8, - 33u8, - 175u8, - 64u8, - 121u8, - 167u8, - 104u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct TokenExchange { + pub buyer: Vec, + pub sold_id: substreams::scalar::BigInt, + pub tokens_sold: substreams::scalar::BigInt, + pub bought_id: substreams::scalar::BigInt, + pub tokens_bought: substreams::scalar::BigInt, + } + impl TokenExchange { + const TOPIC_ID: [u8; 32] = [ + 139u8, + 62u8, + 150u8, + 242u8, + 184u8, + 137u8, + 250u8, + 119u8, + 28u8, + 83u8, + 201u8, + 129u8, + 180u8, + 13u8, + 175u8, + 0u8, + 95u8, + 99u8, + 246u8, + 55u8, + 241u8, + 134u8, + 159u8, + 112u8, + 112u8, + 82u8, + 209u8, + 90u8, + 61u8, + 217u8, + 113u8, + 64u8, + ]; + 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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + buyer: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'buyer' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + sold_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 AddLiquidity { - const NAME: &'static str = "AddLiquidity"; - 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 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 - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + tokens_sold: { + let mut v = [0 as u8; 32]; + values .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 CommitNewFee { - pub deadline: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - } - impl CommitNewFee { - const TOPIC_ID: [u8; 32] = [ - 53u8, - 31u8, - 197u8, - 218u8, - 47u8, - 191u8, - 72u8, - 15u8, - 34u8, - 37u8, - 222u8, - 191u8, - 54u8, - 100u8, - 164u8, - 188u8, - 144u8, - 250u8, - 153u8, - 35u8, - 116u8, - 58u8, - 173u8, - 88u8, - 180u8, - 96u8, - 63u8, - 100u8, - 142u8, - 147u8, - 31u8, - 224u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - 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) - }, - 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) - }, - 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) - }, - }) - } - } - impl substreams_ethereum::Event for CommitNewFee { - const NAME: &'static str = "CommitNewFee"; - 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 - ) - })? + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + bought_id: { + let mut v = [0 as u8; 32]; + values .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) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct NewFee { - pub fee: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - } - impl NewFee { - const TOPIC_ID: [u8; 32] = [ - 190u8, - 18u8, - 133u8, - 155u8, - 99u8, - 106u8, - 237u8, - 96u8, - 125u8, - 82u8, - 48u8, - 178u8, - 204u8, - 39u8, - 17u8, - 246u8, - 141u8, - 112u8, - 229u8, - 16u8, - 96u8, - 230u8, - 204u8, - 161u8, - 245u8, - 117u8, - 239u8, - 93u8, - 47u8, - 204u8, - 149u8, - 209u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - 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) - }, - }) - } - } - impl substreams_ethereum::Event for NewFee { - const NAME: &'static str = "NewFee"; - 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 RampA { - pub old_a: substreams::scalar::BigInt, - pub new_a: substreams::scalar::BigInt, - pub initial_time: substreams::scalar::BigInt, - pub future_time: substreams::scalar::BigInt, - } - impl RampA { - const TOPIC_ID: [u8; 32] = [ - 162u8, - 183u8, - 30u8, - 198u8, - 223u8, - 148u8, - 147u8, - 0u8, - 181u8, - 154u8, - 171u8, - 54u8, - 181u8, - 94u8, - 24u8, - 150u8, - 151u8, - 183u8, - 80u8, - 17u8, - 157u8, - 211u8, - 73u8, - 252u8, - 250u8, - 140u8, - 15u8, - 119u8, - 158u8, - 131u8, - 194u8, - 84u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 128usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_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) - }, - new_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) - }, - initial_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) - }, - future_time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for RampA { - const NAME: &'static str = "RampA"; - 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 RemoveLiquidity { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fees: [substreams::scalar::BigInt; 2usize], - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidity { - const TOPIC_ID: [u8; 32] = [ - 124u8, - 54u8, - 56u8, - 84u8, - 204u8, - 247u8, - 150u8, - 35u8, - 65u8, - 31u8, - 137u8, - 149u8, - 179u8, - 98u8, - 188u8, - 229u8, - 237u8, - 223u8, - 241u8, - 140u8, - 146u8, - 126u8, - 220u8, - 111u8, - 93u8, - 187u8, - 181u8, - 224u8, - 88u8, - 25u8, - 168u8, - 44u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .into_int() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + tokens_bought: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidity { - const NAME: &'static str = "RemoveLiquidity"; - 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 RemoveLiquidityImbalance { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fees: [substreams::scalar::BigInt; 2usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityImbalance { - const TOPIC_ID: [u8; 32] = [ - 43u8, - 85u8, - 8u8, - 55u8, - 141u8, - 126u8, - 25u8, - 224u8, - 213u8, - 250u8, - 51u8, - 132u8, - 25u8, - 3u8, - 71u8, - 49u8, - 65u8, - 108u8, - 79u8, - 91u8, - 33u8, - 154u8, - 16u8, - 55u8, - 153u8, - 86u8, - 247u8, - 100u8, - 49u8, - 127u8, - 212u8, - 126u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for TokenExchange { + const NAME: &'static str = "TokenExchange"; + 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 TokenExchangeUnderlying { + pub buyer: Vec, + pub sold_id: substreams::scalar::BigInt, + pub tokens_sold: substreams::scalar::BigInt, + pub bought_id: substreams::scalar::BigInt, + pub tokens_bought: substreams::scalar::BigInt, + } + impl TokenExchangeUnderlying { + const TOPIC_ID: [u8; 32] = [ + 208u8, + 19u8, + 202u8, + 35u8, + 231u8, + 122u8, + 101u8, + 0u8, + 60u8, + 44u8, + 101u8, + 156u8, + 84u8, + 66u8, + 192u8, + 12u8, + 128u8, + 83u8, + 113u8, + 183u8, + 252u8, + 30u8, + 189u8, + 76u8, + 32u8, + 108u8, + 65u8, + 209u8, + 83u8, + 107u8, + 217u8, + 11u8, + ]; + 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::Int(128usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Int(128usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + buyer: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + .map_err(|e| { + format!( + "unable to decode param 'buyer' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + sold_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityImbalance { - const NAME: &'static str = "RemoveLiquidityImbalance"; - 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 RemoveLiquidityOne { - pub provider: Vec, - pub token_amount: substreams::scalar::BigInt, - pub coin_amount: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityOne { - const TOPIC_ID: [u8; 32] = [ - 90u8, - 208u8, - 86u8, - 242u8, - 226u8, - 138u8, - 140u8, - 236u8, - 35u8, - 32u8, - 21u8, - 64u8, - 107u8, - 132u8, - 54u8, - 104u8, - 193u8, - 227u8, - 108u8, - 218u8, - 89u8, - 129u8, - 39u8, - 236u8, - 59u8, - 140u8, - 89u8, - 184u8, - 199u8, - 39u8, - 115u8, - 160u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + tokens_sold: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_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) - }, - coin_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) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityOne { - const NAME: &'static str = "RemoveLiquidityOne"; - 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 StopRampA { - pub a: substreams::scalar::BigInt, - pub t: substreams::scalar::BigInt, - } - impl StopRampA { - const TOPIC_ID: [u8; 32] = [ - 70u8, - 226u8, - 47u8, - 179u8, - 112u8, - 154u8, - 210u8, - 137u8, - 246u8, - 44u8, - 230u8, - 61u8, - 70u8, - 146u8, - 72u8, - 83u8, - 109u8, - 188u8, - 120u8, - 216u8, - 43u8, - 132u8, - 163u8, - 215u8, - 231u8, - 74u8, - 214u8, - 6u8, - 220u8, - 32u8, - 25u8, - 56u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - t: { - let mut v = [0 as u8; 32]; - values - .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 StopRampA { - const NAME: &'static str = "StopRampA"; - 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 TokenExchange { - pub buyer: Vec, - pub sold_id: substreams::scalar::BigInt, - pub tokens_sold: substreams::scalar::BigInt, - pub bought_id: substreams::scalar::BigInt, - pub tokens_bought: substreams::scalar::BigInt, - } - impl TokenExchange { - const TOPIC_ID: [u8; 32] = [ - 139u8, - 62u8, - 150u8, - 242u8, - 184u8, - 137u8, - 250u8, - 119u8, - 28u8, - 83u8, - 201u8, - 129u8, - 180u8, - 13u8, - 175u8, - 0u8, - 95u8, - 99u8, - 246u8, - 55u8, - 241u8, - 134u8, - 159u8, - 112u8, - 112u8, - 82u8, - 209u8, - 90u8, - 61u8, - 217u8, - 113u8, - 64u8, - ]; - 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - buyer: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'buyer' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + bought_id: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_int() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sold_id: { - 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) - }, - tokens_sold: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - bought_id: { - 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) - }, - tokens_bought: { - let mut v = [0 as u8; 32]; - values - .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 TokenExchange { - const NAME: &'static str = "TokenExchange"; - 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 TokenExchangeUnderlying { - pub buyer: Vec, - pub sold_id: substreams::scalar::BigInt, - pub tokens_sold: substreams::scalar::BigInt, - pub bought_id: substreams::scalar::BigInt, - pub tokens_bought: substreams::scalar::BigInt, - } - impl TokenExchangeUnderlying { - const TOPIC_ID: [u8; 32] = [ - 208u8, - 19u8, - 202u8, - 35u8, - 231u8, - 122u8, - 101u8, - 0u8, - 60u8, - 44u8, - 101u8, - 156u8, - 84u8, - 66u8, - 192u8, - 12u8, - 128u8, - 83u8, - 113u8, - 183u8, - 252u8, - 30u8, - 189u8, - 76u8, - 32u8, - 108u8, - 65u8, - 209u8, - 83u8, - 107u8, - 217u8, - 11u8, - ]; - 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - buyer: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'buyer' from topic of type 'address': {:?}", - e - ) - })? + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_signed_bytes_be(&v) + }, + tokens_bought: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sold_id: { - 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) - }, - tokens_sold: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - bought_id: { - 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) - }, - tokens_bought: { - let mut v = [0 as u8; 32]; - values - .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_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for TokenExchangeUnderlying { - const NAME: &'static str = "TokenExchangeUnderlying"; - 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 TokenExchangeUnderlying { + const NAME: &'static str = "TokenExchangeUnderlying"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/abi/curve/registry.rs b/src/abi/curve/registry.rs index 5a2f78b..36e6bca 100644 --- a/src/abi/curve/registry.rs +++ b/src/abi/curve/registry.rs @@ -1,5178 +1,6133 @@ - 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 AddBasePool { - pub u_base_pool: Vec, - pub u_fee_receiver: Vec, - pub u_asset_type: substreams::scalar::BigInt, - pub u_implementations: [Vec; 10usize], + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_base_pool: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct AddBasePool { + pub u_base_pool: Vec, + pub u_fee_receiver: Vec, + pub u_asset_type: substreams::scalar::BigInt, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_fee_receiver: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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(), - u_fee_receiver: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementations: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_fee_receiver), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + .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.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_fee_receiver), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - { - let v = self - .u_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, - } - } + ), + { + let v = self + .u_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 } - 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() + pub fn 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 AddExistingMetapools { - pub u_pools: [Vec; 10usize], + } + 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) } - 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 { - u_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( + 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 u_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( &[ - { - let v = self - .u_pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 10usize, + ), ], - ); - let mut encoded = Vec::with_capacity(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), + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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 + .u_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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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::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 AddExistingMetapools { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[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(), + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for Admin { - 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 BasePoolAssets { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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), + } + 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable for BasePoolAssets { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[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({ + 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("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 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") - } + }, + }) + } + 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(), - ), + } + .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 - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for BasePoolList { - 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 BatchSetPoolAssetType { - pub u_pools: [Vec; 32usize], - pub u_asset_types: [substreams::scalar::BigInt; 32usize], + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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), - ] - }, - u_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( + } + impl substreams_ethereum::rpc::RPCDecodable> for BasePoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct BatchSetPoolAssetType { + pub u_pools: [Vec; 32usize], + pub u_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( &[ - { - let v = self - .u_pools - .iter() - .map(|inner| ethabi::Token::Address( - ethabi::Address::from_slice(&inner), - )) - .collect(); - ethabi::Token::FixedArray(v) - }, - { - let v = self - .u_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) - }, + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Address), + 32usize, + ), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 32usize, + ), ], - ); - 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 u_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 { - u_addr: values + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_pools: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 - } - } - } + .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), + ] + }, + u_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), + ] + }, + }) } - 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) + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + { + let v = self + .u_pools + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) + }, + { + let v = self + .u_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, } - fn encode(&self) -> Vec { - self.encode() + } + } + 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 u_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 { + u_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.u_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::rpc::RPCDecodable for ConvertMetapoolFees { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + 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 + } } } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployGauge { - pub u_pool: Vec, + } + 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) } - 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 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 u_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 { + u_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.u_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 { - u_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 DeployMetapool1 { + pub u_base_pool: Vec, + pub u_name: String, + pub u_symbol: String, + pub u_coin: Vec, + pub u_a: substreams::scalar::BigInt, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_a: { + 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.u_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( + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + 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::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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.u_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 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 DeployMetapool1 { + const NAME: &'static str = "deploy_metapool1"; + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct DeployMetapool1 { - pub u_base_pool: Vec, - pub u_name: String, - pub u_symbol: String, - pub u_coin: Vec, - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_base_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployMetapool1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployMetapool2 { + pub u_base_pool: Vec, + pub u_name: String, + pub u_symbol: String, + pub u_coin: Vec, + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coin: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_name: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_coin: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementation_idx: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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.u_base_pool), - ), - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_coin), + .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.u_base_pool), + ), + ethabi::Token::String(self.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_coin)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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 - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for DeployMetapool2 { + const NAME: &'static str = "deploy_metapool2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for DeployMetapool1 { - 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 DeployMetapool2 { - pub u_base_pool: Vec, - pub u_name: String, - pub u_symbol: String, - pub u_coin: Vec, - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_implementation_idx: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_base_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployMetapool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool1 { + pub u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_fixed_array() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_name: 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), + ] + }, + u_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_coin: values + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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) - }, - u_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) - }, - u_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) + .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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_coins + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_base_pool), - ), - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_coin), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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.u_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") - } + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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 - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for DeployMetapool2 { - 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 DeployPlainPool1 { - pub u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_name: values + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool2 { + pub u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_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), + ] + }, + u_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_coins + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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") - } + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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 - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool1 { - 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 DeployPlainPool2 { - pub u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_asset_type: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_name: values + } + impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool2 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct DeployPlainPool3 { + pub u_name: String, + pub u_symbol: String, + pub u_coins: [Vec; 4usize], + pub u_a: substreams::scalar::BigInt, + pub u_fee: substreams::scalar::BigInt, + pub u_asset_type: substreams::scalar::BigInt, + pub u_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 { + u_name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_symbol: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), + u_coins: { + let mut iter = values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_symbol: values + .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), + ] + }, + u_a: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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) - }, - u_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) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_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) + }, + u_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) + }, + u_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.u_name.clone()), + ethabi::Token::String(self.u_symbol.clone()), + { + let v = self + .u_coins + .iter() + .map(|inner| ethabi::Token::Address( + ethabi::Address::from_slice(&inner), + )) + .collect(); + ethabi::Token::FixedArray(v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::String(self.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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") - } + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .as_slice(), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_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") - } + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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(), - ), + } + .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, + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool2 { - 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 DeployPlainPool3 { - pub u_name: String, - pub u_symbol: String, - pub u_coins: [Vec; 4usize], - pub u_a: substreams::scalar::BigInt, - pub u_fee: substreams::scalar::BigInt, - pub u_asset_type: substreams::scalar::BigInt, - pub u_implementation_idx: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_name: values + } + impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct FindPoolForCoins2 { + pub u_from: Vec, + pub u_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 { + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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_string() - .expect(INTERNAL_ERR), - u_symbol: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), - u_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), - ] - }, - u_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) - }, - u_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) - }, - u_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) - }, - u_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.u_name.clone()), - ethabi::Token::String(self.u_symbol.clone()), - { - let v = self - .u_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.u_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.u_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.u_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.u_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") - } + .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.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - ), + } + .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, + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 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 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::Function for FutureAdmin { + const NAME: &'static str = "future_admin"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for DeployPlainPool3 { - 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() } - #[derive(Debug, Clone, PartialEq)] - pub struct FindPoolForCoins1 { - pub u_from: Vec, - pub u_to: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[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 } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), + } + } + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::Function for GetA { + const NAME: &'static str = "get_A"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins1 { - 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 FindPoolForCoins2 { - pub u_from: Vec, - pub u_to: Vec, - pub i: substreams::scalar::BigInt, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_from: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - i: { + } + impl substreams_ethereum::rpc::RPCDecodable for GetA { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetAdminBalances { + pub u_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 { + u_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.u_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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), - ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 - } + }); + [ + 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for FindPoolForCoins2 { - 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 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(), + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetBalances { + const NAME: &'static str = "get_balances"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for FutureAdmin { - 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 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(), + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for GaugeImplementation { - 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 GetA { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetBasePool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCoinIndices { + pub u_pool: Vec, + pub u_from: Vec, + pub u_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 { + u_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_from: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_pool)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_from)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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({ + .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("one output data should have existed") - .into_uint() + .expect(INTERNAL_ERR) + .into_int() .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, + 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 } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + } + } + 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 u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for GetCoins { + const NAME: &'static str = "get_coins"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetAdminBalances { - pub u_pool: Vec, + 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) } - 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 { - u_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.u_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, + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetDecimals { + pub u_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 { + u_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.u_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 } } - 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 u_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 { + u_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.u_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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]> - for GetAdminBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetFeeReceiver { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetFees { + pub u_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 { + u_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.u_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_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.u_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 + .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("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, + .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 } } - 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 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 u_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 { + u_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.u_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 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::Function for GetGauge { + const NAME: &'static str = "get_gauge"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]> - for GetBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBasePool { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), + } + impl substreams_ethereum::rpc::RPCDecodable> for GetGauge { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetImplementationAddress { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 GetLpToken { + pub arg0: Vec, + } + impl GetLpToken { + 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 { + 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for GetLpToken { + const NAME: &'static str = "get_lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetBasePool { - 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 GetCoinIndices { - pub u_pool: Vec, - pub u_from: Vec, - pub u_to: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_from: values + } + impl substreams_ethereum::rpc::RPCDecodable> for GetLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetMetaNCoins { + pub u_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 { + u_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.u_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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_to: 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_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 match_call(call: &substreams_ethereum::pb::eth::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 + } } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + 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 u_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 { + u_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.u_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::Token::Address( - ethabi::Address::from_slice(&self.u_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_from), + ethabi::ParamType::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 2usize, ), - ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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) - }, - { + 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) - .into_int() + inner + .into_uint() .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 - } + 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 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::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) } - 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 u_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()); + 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 u_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 { + u_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.u_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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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, + } + } + 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 u_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 { + u_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.u_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 } } - 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 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 GetPoolFromLpToken { + pub arg0: Vec, + } + impl GetPoolFromLpToken { + 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 { + 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use 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::Function for GetPoolFromLpToken { + const NAME: &'static str = "get_pool_from_lp_token"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable<[Vec; 4usize]> for GetCoins { - fn output(data: &[u8]) -> Result<[Vec; 4usize], String> { - Self::output(data) - } + 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 GetDecimals { - pub u_pool: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for GetPoolFromLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - 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()); + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPoolName { + pub u_pool: Vec, + } + impl GetPoolName { + 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 { + u_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.u_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 } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_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.u_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, + } + } + impl substreams_ethereum::Function for GetPoolName { + const NAME: &'static str = "get_pool_name"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for GetPoolName { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetToken { + pub u_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 { + u_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.u_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 } } - 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(), } + } + } + 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 GetUnderlyingBalances { + pub u_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 { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable<[substreams::scalar::BigInt; 4usize]> - for GetDecimals { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 4usize], String> { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetFeeReceiver { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), + } + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::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) } - impl substreams_ethereum::rpc::RPCDecodable> for GetFeeReceiver { - 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 GetFees { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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) - }, - { + } + 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 u_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 { + u_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.u_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]; - 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) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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 - } + }); + [ + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.next().expect(INTERNAL_ERR), + iter.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 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 u_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 { - u_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.u_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(), + } + 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 u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 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::Function for Manager { + const NAME: &'static str = "manager"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetGauge { - 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 GetImplementationAddress { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), + } + impl substreams_ethereum::rpc::RPCDecodable> for Manager { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MetapoolImplementations { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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, + ), ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + 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 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::Function for MetapoolImplementations { + const NAME: &'static str = "metapool_implementations"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> - for GetImplementationAddress { - 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 GetLpToken { - pub arg0: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetLpToken { - 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 { - arg0: values + } + 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_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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + .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("one output data should have existed") - .into_address() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + .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 } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use 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 GetLpToken { - const NAME: &'static str = "get_lp_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::Function for PoolCount { + const NAME: &'static str = "pool_count"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetLpToken { - 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 GetMetaNCoins { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_pool: values + } + 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_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.u_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, + .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 } } - 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 u_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 { - u_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.u_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 u_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 { - u_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.u_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 u_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 { - u_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.u_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 PoolList { + const NAME: &'static str = "pool_list"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - 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() - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetPoolAssetType { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn encode(&self) -> Vec { + self.encode() } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPoolFromLpToken { - pub arg0: Vec, + } + impl substreams_ethereum::rpc::RPCDecodable> for PoolList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl GetPoolFromLpToken { - 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 { - 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetFeeReceiver { + pub u_base_pool: Vec, + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_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.u_base_pool), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_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 GetPoolFromLpToken { - const NAME: &'static str = "get_pool_from_lp_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::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 substreams_ethereum::rpc::RPCDecodable> for GetPoolFromLpToken { - 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 GetPoolName { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - impl GetPoolName { - 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 { - u_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.u_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), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetGaugeImplementation { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 GetPoolName { - const NAME: &'static str = "get_pool_name"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::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) } - impl substreams_ethereum::rpc::RPCDecodable for GetPoolName { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetToken { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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(), + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetManager { + pub u_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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_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.u_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 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::Function for SetManager { + const NAME: &'static str = "set_manager"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for GetToken { - 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 GetUnderlyingBalances { - pub u_pool: Vec, + fn encode(&self) -> Vec { + self.encode() } - 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 { - u_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.u_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({ + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetMetapoolImplementations { + pub u_base_pool: Vec, + pub u_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 { + u_base_pool: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + u_implementations: { let mut iter = values .pop() - .expect("one output data should have existed") + .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) + inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() }); [ iter.next().expect(INTERNAL_ERR), @@ -5183,125 +6138,97 @@ iter.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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_base_pool), + ), + { + let v = self + .u_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 } - 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() + pub fn 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<[substreams::scalar::BigInt; 8usize]> - for GetUnderlyingBalances { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 8usize], String> { - Self::output(data) - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoins { - pub u_pool: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_pool: values + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SetPlainImplementations { + pub u_n_coins: substreams::scalar::BigInt, + pub u_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 { + u_n_coins: { + 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.u_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({ + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + u_implementations: { let mut iter = values .pop() - .expect("one output data should have existed") + .expect(INTERNAL_ERR) .into_fixed_array() .expect(INTERNAL_ERR) .into_iter() @@ -5317,2273 +6244,978 @@ iter.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 - } - } - } + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.u_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 + .u_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 } - 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() + pub fn 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<[Vec; 8usize]> - for GetUnderlyingCoins { - fn output(data: &[u8]) -> Result<[Vec; 8usize], String> { - Self::output(data) - } + } + 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) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingDecimals { - pub u_pool: Vec, + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - 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 { - u_pool: values + 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 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() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_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 u_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 { - u_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.u_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 u_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 { - u_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.u_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() + .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({ + [iter.next().expect(INTERNAL_ERR), iter.next().expect(INTERNAL_ERR)] + }, + a: { 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 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( + }, + gamma: { + 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 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 u_base_pool: Vec, - pub u_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 { - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_base_pool), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_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 u_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 { - u_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.u_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 u_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 { - u_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.u_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 u_base_pool: Vec, - pub u_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 { - u_base_pool: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - u_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.u_base_pool), - ), - { - let v = self - .u_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 u_n_coins: substreams::scalar::BigInt, - pub u_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 { - u_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) - }, - u_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.u_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 - .u_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() + .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 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 + .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(), - 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) - }, - deployer: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - 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) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct LiquidityGaugeDeployed1 { - pub pool: Vec, - pub token: Vec, - pub gauge: Vec, - } - impl LiquidityGaugeDeployed1 { - 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 + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for LiquidityGaugeDeployed1 { - const NAME: &'static str = "LiquidityGaugeDeployed1"; - 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 LiquidityGaugeDeployed2 { - pub pool: Vec, - pub gauge: Vec, - } - impl LiquidityGaugeDeployed2 { - 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) + }, + admin_fee: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - gauge: values + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for LiquidityGaugeDeployed2 { - const NAME: &'static str = "LiquidityGaugeDeployed2"; - 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 + .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_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) + }, + deployer: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + 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) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct LiquidityGaugeDeployed1 { + pub pool: Vec, + pub token: Vec, + pub gauge: Vec, + } + impl LiquidityGaugeDeployed1 { + 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 LiquidityGaugeDeployed1 { + const NAME: &'static str = "LiquidityGaugeDeployed1"; + 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 LiquidityGaugeDeployed2 { + pub pool: Vec, + pub gauge: Vec, + } + impl LiquidityGaugeDeployed2 { + 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 LiquidityGaugeDeployed2 { + const NAME: &'static str = "LiquidityGaugeDeployed2"; + 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_address() + .into_uint() .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 + .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_address() + .into_uint() .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_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_address() + .into_fixed_array() .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) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct PoolAdded1 { - pub pool: Vec, - } - impl PoolAdded1 { - const TOPIC_ID: [u8; 32] = [ - 115u8, - 204u8, - 166u8, - 42u8, - 177u8, - 181u8, - 32u8, - 201u8, - 113u8, - 91u8, - 244u8, - 230u8, - 199u8, - 30u8, - 62u8, - 81u8, - 140u8, - 117u8, - 78u8, - 113u8, - 72u8, - 246u8, - 81u8, - 2u8, - 244u8, - 50u8, - 137u8, - 167u8, - 223u8, - 14u8, - 254u8, - 166u8, - ]; - 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 - ) - })? + .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_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - } - impl substreams_ethereum::Event for PoolAdded1 { - const NAME: &'static str = "PoolAdded1"; - 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 PoolAdded2 { - pub pool: Vec, - pub rate_method_id: Vec, - } - impl PoolAdded2 { - const TOPIC_ID: [u8; 32] = [ - 228u8, - 133u8, - 193u8, - 100u8, - 121u8, - 171u8, - 112u8, - 146u8, - 192u8, - 179u8, - 252u8, - 70u8, - 73u8, - 132u8, - 60u8, - 6u8, - 190u8, - 127u8, - 7u8, - 33u8, - 148u8, - 103u8, - 82u8, - 97u8, - 89u8, - 12u8, - 132u8, - 71u8, - 58u8, - 176u8, - 174u8, - 169u8, - ]; - 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::Bytes], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - 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 - ) - })? + .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_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - rate_method_id: values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_bytes() - .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 PoolAdded2 { - const NAME: &'static str = "PoolAdded2"; - 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 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) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PoolAdded1 { + pub pool: Vec, + } + impl PoolAdded1 { + const TOPIC_ID: [u8; 32] = [ + 115u8, + 204u8, + 166u8, + 42u8, + 177u8, + 181u8, + 32u8, + 201u8, + 113u8, + 91u8, + 244u8, + 230u8, + 199u8, + 30u8, + 62u8, + 81u8, + 140u8, + 117u8, + 78u8, + 113u8, + 72u8, + 246u8, + 81u8, + 2u8, + 244u8, + 50u8, + 137u8, + 167u8, + 223u8, + 14u8, + 254u8, + 166u8, + ]; + 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 PoolAdded1 { + const NAME: &'static str = "PoolAdded1"; + 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 PoolAdded2 { + pub pool: Vec, + pub rate_method_id: Vec, + } + impl PoolAdded2 { + const TOPIC_ID: [u8; 32] = [ + 228u8, + 133u8, + 193u8, + 100u8, + 121u8, + 171u8, + 112u8, + 146u8, + 192u8, + 179u8, + 252u8, + 70u8, + 73u8, + 132u8, + 60u8, + 6u8, + 190u8, + 127u8, + 7u8, + 33u8, + 148u8, + 103u8, + 82u8, + 97u8, + 89u8, + 12u8, + 132u8, + 71u8, + 58u8, + 176u8, + 174u8, + 169u8, + ]; + 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::Bytes], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + 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(), + rate_method_id: values + .pop() + .expect(INTERNAL_ERR) + .into_bytes() + .expect(INTERNAL_ERR), + }) } - } \ No newline at end of file + } + impl substreams_ethereum::Event for PoolAdded2 { + const NAME: &'static str = "PoolAdded2"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} \ No newline at end of file diff --git a/src/abi/oracle/curve_calculations.rs b/src/abi/oracle/curve_calculations.rs index f3f8c58..638b5ac 100644 --- a/src/abi/oracle/curve_calculations.rs +++ b/src/abi/oracle/curve_calculations.rs @@ -1,1462 +1,1382 @@ - 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 CurveAddressProviderAddress {} - impl CurveAddressProviderAddress { - const METHOD_ID: [u8; 4] = [76u8, 208u8, 238u8, 101u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } +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 CurveAddressProviderAddress {} + impl CurveAddressProviderAddress { + const METHOD_ID: [u8; 4] = [76u8, 208u8, 238u8, 101u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) } - impl substreams_ethereum::Function for CurveAddressProviderAddress { - const NAME: &'static str = "curveAddressProviderAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> - for CurveAddressProviderAddress { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) } - #[derive(Debug, Clone, PartialEq)] - pub struct CurveMetapoolFactoryAddress {} - impl CurveMetapoolFactoryAddress { - const METHOD_ID: [u8; 4] = [197u8, 237u8, 211u8, 134u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(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(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 CurveMetapoolFactoryAddress { - const NAME: &'static str = "curveMetapoolFactoryAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 CurveAddressProviderAddress { + const NAME: &'static str = "curveAddressProviderAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> - for CurveMetapoolFactoryAddress { - 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 CurveRegistryAddress {} - impl CurveRegistryAddress { - const METHOD_ID: [u8; 4] = [50u8, 202u8, 117u8, 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, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for CurveRegistryAddress { - const NAME: &'static str = "curveRegistryAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::rpc::RPCDecodable> + for CurveAddressProviderAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable> for CurveRegistryAddress { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CurveMetapoolFactoryAddress {} + impl CurveMetapoolFactoryAddress { + const METHOD_ID: [u8; 4] = [197u8, 237u8, 211u8, 134u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetBasePrice { - pub curve_lp_token_address: Vec, - } - impl GetBasePrice { - const METHOD_ID: [u8; 4] = [206u8, 235u8, 10u8, 253u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - curve_lp_token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.curve_lp_token_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 - } - } - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for GetBasePrice { - const NAME: &'static str = "getBasePrice"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) } - impl substreams_ethereum::rpc::RPCDecodable - for GetBasePrice { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetCurvePriceUsdc { - pub curve_lp_token_address: Vec, - } - impl GetCurvePriceUsdc { - const METHOD_ID: [u8; 4] = [39u8, 142u8, 65u8, 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 { - curve_lp_token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.curve_lp_token_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 GetCurvePriceUsdc { - const NAME: &'static str = "getCurvePriceUsdc"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 CurveMetapoolFactoryAddress { + const NAME: &'static str = "curveMetapoolFactoryAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetCurvePriceUsdc { - fn output(data: &[u8]) -> Result { - Self::output(data) + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> + for CurveMetapoolFactoryAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct CurveRegistryAddress {} + impl CurveRegistryAddress { + const METHOD_ID: [u8; 4] = [50u8, 202u8, 117u8, 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, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 GetPool { - pub token_address: Vec, - } - impl GetPool { - const METHOD_ID: [u8; 4] = [187u8, 228u8, 246u8, 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()); + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + } + impl substreams_ethereum::Function for CurveRegistryAddress { + const NAME: &'static str = "curveRegistryAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for CurveRegistryAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetBasePrice { + pub curve_lp_token_address: Vec, + } + impl GetBasePrice { + const METHOD_ID: [u8; 4] = [206u8, 235u8, 10u8, 253u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + curve_lp_token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - 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() - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.curve_lp_token_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for GetPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPriceUsdc { - pub asset_address: Vec, - } - impl GetPriceUsdc { - const METHOD_ID: [u8; 4] = [214u8, 26u8, 120u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - asset_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.asset_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 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 - } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetPriceUsdc { - const NAME: &'static str = "getPriceUsdc"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetBasePrice { + const NAME: &'static str = "getBasePrice"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetPriceUsdc { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetUnderlyingCoinFromPool { - pub pool_address: Vec, - } - impl GetUnderlyingCoinFromPool { - const METHOD_ID: [u8; 4] = [54u8, 100u8, 133u8, 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], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - pool_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetBasePrice { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCurvePriceUsdc { + pub curve_lp_token_address: Vec, + } + impl GetCurvePriceUsdc { + const METHOD_ID: [u8; 4] = [39u8, 142u8, 65u8, 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(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + curve_lp_token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for GetUnderlyingCoinFromPool { - const NAME: &'static str = "getUnderlyingCoinFromPool"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address( + ethabi::Address::from_slice(&self.curve_lp_token_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> - for GetUnderlyingCoinFromPool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetVirtualPrice { - pub curve_lp_token_address: Vec, - } - impl GetVirtualPrice { - const METHOD_ID: [u8; 4] = [241u8, 190u8, 14u8, 186u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - curve_lp_token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.curve_lp_token_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 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 - } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetVirtualPrice { - const NAME: &'static str = "getVirtualPrice"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetCurvePriceUsdc { + const NAME: &'static str = "getCurvePriceUsdc"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetCurvePriceUsdc { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPool { + pub token_address: Vec, + } + impl GetPool { + const METHOD_ID: [u8; 4] = [187u8, 228u8, 246u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) } - impl substreams_ethereum::rpc::RPCDecodable - for GetVirtualPrice { - fn output(data: &[u8]) -> Result { - Self::output(data) + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 IsBasicToken { - pub token_address: Vec, - } - impl IsBasicToken { - const METHOD_ID: [u8; 4] = [181u8, 165u8, 5u8, 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 call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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), + } + } + 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> for GetPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPriceUsdc { + pub asset_address: Vec, + } + impl GetPriceUsdc { + const METHOD_ID: [u8; 4] = [214u8, 26u8, 120u8, 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::Address], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + asset_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.asset_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 IsBasicToken { - const NAME: &'static str = "isBasicToken"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetPriceUsdc { + const NAME: &'static str = "getPriceUsdc"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetPriceUsdc { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable for IsBasicToken { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetUnderlyingCoinFromPool { + pub pool_address: Vec, + } + impl GetUnderlyingCoinFromPool { + const METHOD_ID: [u8; 4] = [54u8, 100u8, 133u8, 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], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + pool_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 IsCurveLpToken { - pub token_address: Vec, - } - impl IsCurveLpToken { - const METHOD_ID: [u8; 4] = [196u8, 230u8, 195u8, 172u8]; - pub fn decode( - call: &substreams_ethereum::pb::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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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), + } + } + impl substreams_ethereum::Function for GetUnderlyingCoinFromPool { + const NAME: &'static str = "getUnderlyingCoinFromPool"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GetUnderlyingCoinFromPool { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetVirtualPrice { + pub curve_lp_token_address: Vec, + } + impl GetVirtualPrice { + const METHOD_ID: [u8; 4] = [241u8, 190u8, 14u8, 186u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + curve_lp_token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.curve_lp_token_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 IsCurveLpToken { - const NAME: &'static str = "isCurveLpToken"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetVirtualPrice { + const NAME: &'static str = "getVirtualPrice"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsCurveLpToken { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct OracleAddress {} - impl OracleAddress { - const METHOD_ID: [u8; 4] = [168u8, 154u8, 228u8, 186u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetVirtualPrice { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsBasicToken { + pub token_address: Vec, + } + impl IsBasicToken { + const METHOD_ID: [u8; 4] = [181u8, 165u8, 5u8, 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::Address], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 OracleAddress { - const NAME: &'static str = "oracleAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IsBasicToken { + const NAME: &'static str = "isBasicToken"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for OracleAddress { - 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 OwnerAddress {} - impl OwnerAddress { - const METHOD_ID: [u8; 4] = [143u8, 132u8, 170u8, 9u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IsBasicToken { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsCurveLpToken { + pub token_address: Vec, + } + impl IsCurveLpToken { + const METHOD_ID: [u8; 4] = [196u8, 230u8, 195u8, 172u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 OwnerAddress { - const NAME: &'static str = "ownerAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) + } + impl substreams_ethereum::Function for IsCurveLpToken { + const NAME: &'static str = "isCurveLpToken"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IsCurveLpToken { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OracleAddress {} + impl OracleAddress { + const METHOD_ID: [u8; 4] = [168u8, 154u8, 228u8, 186u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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() + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(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 OwnerAddress { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + } + impl substreams_ethereum::Function for OracleAddress { + const NAME: &'static str = "oracleAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for OracleAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OwnerAddress {} + impl OwnerAddress { + const METHOD_ID: [u8; 4] = [143u8, 132u8, 170u8, 9u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 UpdateSlot { - pub slot: [u8; 32usize], - pub value: [u8; 32usize], - } - impl UpdateSlot { - const METHOD_ID: [u8; 4] = [145u8, 234u8, 131u8, 232u8]; - pub fn decode( - call: &substreams_ethereum::pb::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(32usize), - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - slot: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - value: { - 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( + } + } + impl substreams_ethereum::Function for OwnerAddress { + const NAME: &'static str = "ownerAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for OwnerAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UpdateSlot { + pub slot: [u8; 32usize], + pub value: [u8; 32usize], + } + impl UpdateSlot { + const METHOD_ID: [u8; 4] = [145u8, 234u8, 131u8, 232u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( &[ - ethabi::Token::FixedBytes(self.slot.as_ref().to_vec()), - ethabi::Token::FixedBytes(self.value.as_ref().to_vec()), + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::FixedBytes(32usize), ], - ); - 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, - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + slot: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + value: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + }) } - impl substreams_ethereum::Function for UpdateSlot { - const NAME: &'static str = "updateSlot"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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.slot.as_ref().to_vec()), + ethabi::Token::FixedBytes(self.value.as_ref().to_vec()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - } \ No newline at end of file + impl substreams_ethereum::Function for UpdateSlot { + const NAME: &'static str = "updateSlot"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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; +} \ No newline at end of file diff --git a/src/abi/oracle/inch.rs b/src/abi/oracle/inch.rs index d6a1b16..d2db1d7 100644 --- a/src/abi/oracle/inch.rs +++ b/src/abi/oracle/inch.rs @@ -1,1655 +1,1584 @@ - 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 AddConnector { - pub connector: Vec, - } - impl AddConnector { - const METHOD_ID: [u8; 4] = [170u8, 22u8, 212u8, 192u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - connector: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.connector), - ), - ], - ); - 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 AddConnector { + pub connector: Vec, + } + impl AddConnector { + const METHOD_ID: [u8; 4] = [170u8, 22u8, 212u8, 192u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + connector: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for AddConnector { - const NAME: &'static str = "addConnector"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address(ethabi::Address::from_slice(&self.connector))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - #[derive(Debug, Clone, PartialEq)] - pub struct AddOracle { - pub oracle: Vec, - pub oracle_kind: substreams::scalar::BigInt, - } - impl AddOracle { - const METHOD_ID: [u8; 4] = [157u8, 77u8, 123u8, 28u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.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(8usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - oracle: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - oracle_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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.oracle), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.oracle_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 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 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 AddOracle { - const NAME: &'static str = "addOracle"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 AddConnector { + const NAME: &'static str = "addConnector"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct Connectors {} - impl Connectors { - const METHOD_ID: [u8; 4] = [101u8, 5u8, 10u8, 104u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::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 - } - } - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - impl substreams_ethereum::Function for Connectors { - const NAME: &'static str = "connectors"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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() } - impl substreams_ethereum::rpc::RPCDecodable>> for Connectors { - fn output(data: &[u8]) -> Result>, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetRate { - pub src_token: Vec, - pub dst_token: Vec, - pub use_wrappers: bool, - } - impl GetRate { - const METHOD_ID: [u8; 4] = [128u8, 36u8, 49u8, 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::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - src_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - dst_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - use_wrappers: 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.src_token), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.dst_token), - ), - ethabi::Token::Bool(self.use_wrappers.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 { - 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 AddOracle { + pub oracle: Vec, + pub oracle_kind: substreams::scalar::BigInt, + } + impl AddOracle { + const METHOD_ID: [u8; 4] = [157u8, 77u8, 123u8, 28u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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(8usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + oracle: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + oracle_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 GetRate { - const NAME: &'static str = "getRate"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.oracle)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.oracle_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 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 GetRate { - fn output(data: &[u8]) -> Result { - Self::output(data) + } + impl substreams_ethereum::Function for AddOracle { + const NAME: &'static str = "addOracle"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Connectors {} + impl Connectors { + const METHOD_ID: [u8; 4] = [101u8, 5u8, 10u8, 104u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct GetRateToEth { - pub src_token: Vec, - pub use_src_wrappers: bool, - } - impl GetRateToEth { - const METHOD_ID: [u8; 4] = [125u8, 228u8, 253u8, 16u8]; - pub fn decode( - call: &substreams_ethereum::pb::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::Address, ethabi::ParamType::Bool], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - src_token: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - use_src_wrappers: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for Connectors { + const NAME: &'static str = "connectors"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable>> for Connectors { + fn output(data: &[u8]) -> Result>, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRate { + pub src_token: Vec, + pub dst_token: Vec, + pub use_wrappers: bool, + } + impl GetRate { + const METHOD_ID: [u8; 4] = [128u8, 36u8, 49u8, 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::Token::Address( - ethabi::Address::from_slice(&self.src_token), - ), - ethabi::Token::Bool(self.use_src_wrappers.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 { - 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(), } + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Bool, ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + src_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + dst_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + use_wrappers: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) } - impl substreams_ethereum::Function for GetRateToEth { - const NAME: &'static str = "getRateToEth"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address(ethabi::Address::from_slice(&self.src_token)), + ethabi::Token::Address(ethabi::Address::from_slice(&self.dst_token)), + ethabi::Token::Bool(self.use_wrappers.clone()), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable - for GetRateToEth { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - #[derive(Debug, Clone, PartialEq)] - pub struct MultiWrapper {} - impl MultiWrapper { - const METHOD_ID: [u8; 4] = [183u8, 121u8, 16u8, 220u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 MultiWrapper { - const NAME: &'static str = "multiWrapper"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetRate { + const NAME: &'static str = "getRate"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for MultiWrapper { - 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 Oracles {} - impl Oracles { - const METHOD_ID: [u8; 4] = [40u8, 87u8, 55u8, 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<(Vec>, Vec), String> { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result<(Vec>, Vec), String> { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Array( - Box::new(ethabi::ParamType::Address), - ), - ethabi::ParamType::Array( - Box::new(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_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(), - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::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 - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for Oracles { - const NAME: &'static str = "oracles"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::rpc::RPCDecodable for GetRate { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable< - (Vec>, Vec), - > for Oracles { - fn output( - data: &[u8], - ) -> Result<(Vec>, Vec), String> { - Self::output(data) - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRateToEth { + pub src_token: Vec, + pub use_src_wrappers: bool, + } + impl GetRateToEth { + const METHOD_ID: [u8; 4] = [125u8, 228u8, 253u8, 16u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.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 { + src_token: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + use_src_wrappers: values + .pop() + .expect(INTERNAL_ERR) + .into_bool() + .expect(INTERNAL_ERR), + }) } - #[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 encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address(ethabi::Address::from_slice(&self.src_token)), + ethabi::Token::Bool(self.use_src_wrappers.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 { + 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 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::Function for GetRateToEth { + const NAME: &'static str = "getRateToEth"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetRateToEth { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct MultiWrapper {} + impl MultiWrapper { + const METHOD_ID: [u8; 4] = [183u8, 121u8, 16u8, 220u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for Owner { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 RemoveConnector { - pub connector: Vec, - } - impl RemoveConnector { - const METHOD_ID: [u8; 4] = [26u8, 108u8, 106u8, 152u8]; - pub fn decode( - call: &substreams_ethereum::pb::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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - connector: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( + } + } + impl substreams_ethereum::Function for MultiWrapper { + const NAME: &'static str = "multiWrapper"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for MultiWrapper { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Oracles {} + impl Oracles { + const METHOD_ID: [u8; 4] = [40u8, 87u8, 55u8, 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<(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::Token::Address( - ethabi::Address::from_slice(&self.connector), + ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), + ethabi::ParamType::Array( + Box::new(ethabi::ParamType::Uint(8usize)), ), ], - ); - 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 RemoveConnector { - const NAME: &'static str = "removeConnector"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 RemoveOracle { - pub oracle: Vec, - pub oracle_kind: substreams::scalar::BigInt, - } - impl RemoveOracle { - const METHOD_ID: [u8; 4] = [240u8, 185u8, 46u8, 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, ethabi::ParamType::Uint(8usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - oracle: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - oracle_kind: { + 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]; - 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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.oracle), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.oracle_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 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, - } - } + }) + .collect(), + )) } - impl substreams_ethereum::Function for RemoveOracle { - const NAME: &'static str = "removeOracle"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 RenounceOwnership {} - impl RenounceOwnership { - const METHOD_ID: [u8; 4] = [113u8, 80u8, 24u8, 166u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 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 RenounceOwnership { - const NAME: &'static str = "renounceOwnership"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Oracles { + const NAME: &'static str = "oracles"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetMultiWrapper { - pub u_multi_wrapper: Vec, - } - impl SetMultiWrapper { - const METHOD_ID: [u8; 4] = [208u8, 98u8, 101u8, 24u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_multi_wrapper: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.u_multi_wrapper), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + 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 Oracles { + fn output( + data: &[u8], + ) -> Result<(Vec>, Vec), String> { + 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for SetMultiWrapper { - const NAME: &'static str = "setMultiWrapper"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 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 RemoveConnector { + pub connector: Vec, + } + impl RemoveConnector { + const METHOD_ID: [u8; 4] = [26u8, 108u8, 106u8, 152u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + connector: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.connector))], + ); + 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 TransferOwnership { - pub new_owner: Vec, - } - impl TransferOwnership { - const METHOD_ID: [u8; 4] = [242u8, 253u8, 227u8, 139u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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_owner: values + } + impl substreams_ethereum::Function for RemoveConnector { + const NAME: &'static str = "removeConnector"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 RemoveOracle { + pub oracle: Vec, + pub oracle_kind: substreams::scalar::BigInt, + } + impl RemoveOracle { + const METHOD_ID: [u8; 4] = [240u8, 185u8, 46u8, 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, ethabi::ParamType::Uint(8usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + oracle: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + oracle_kind: { + 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.new_owner), + .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.oracle)), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.oracle_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 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, - } - } + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for TransferOwnership { - const NAME: &'static str = "transferOwnership"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 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 ConnectorAdded { - pub connector: Vec, - } - impl ConnectorAdded { - const TOPIC_ID: [u8; 32] = [ - 255u8, - 136u8, - 175u8, - 93u8, - 150u8, - 45u8, - 71u8, - 253u8, - 37u8, - 216u8, - 119u8, - 85u8, - 232u8, - 38u8, - 122u8, - 2u8, - 159u8, - 173u8, - 90u8, - 145u8, - 116u8, - 12u8, - 103u8, - 208u8, - 218u8, - 222u8, - 43u8, - 219u8, - 229u8, - 38u8, - 138u8, - 29u8, - ]; - 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 { - connector: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + impl substreams_ethereum::Function for RemoveOracle { + const NAME: &'static str = "removeOracle"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::Event for ConnectorAdded { - const NAME: &'static str = "ConnectorAdded"; - 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) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct ConnectorRemoved { - pub connector: Vec, - } - impl ConnectorRemoved { - const TOPIC_ID: [u8; 32] = [ - 104u8, - 37u8, - 178u8, - 106u8, - 8u8, - 39u8, - 233u8, - 194u8, - 206u8, - 202u8, - 1u8, - 214u8, - 40u8, - 156u8, - 228u8, - 164u8, - 14u8, - 98u8, - 157u8, - 192u8, - 116u8, - 236u8, - 72u8, - 234u8, - 71u8, - 39u8, - 209u8, - 175u8, - 191u8, - 243u8, - 89u8, - 245u8, - ]; - 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 { - connector: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Event for ConnectorRemoved { - const NAME: &'static str = "ConnectorRemoved"; - 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 RenounceOwnership {} + impl RenounceOwnership { + const METHOD_ID: [u8; 4] = [113u8, 80u8, 24u8, 166u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) } - #[derive(Debug, Clone, PartialEq)] - pub struct MultiWrapperUpdated { - pub multi_wrapper: Vec, - } - impl MultiWrapperUpdated { - const TOPIC_ID: [u8; 32] = [ - 16u8, - 48u8, - 21u8, - 47u8, - 226u8, - 6u8, - 43u8, - 87u8, - 74u8, - 131u8, - 14u8, - 107u8, - 159u8, - 19u8, - 198u8, - 89u8, - 149u8, - 153u8, - 13u8, - 243u8, - 30u8, - 77u8, - 199u8, - 8u8, - 209u8, - 66u8, - 83u8, - 59u8, - 179u8, - 173u8, - 15u8, - 82u8, - ]; - 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 { - multi_wrapper: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Event for MultiWrapperUpdated { - const NAME: &'static str = "MultiWrapperUpdated"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) + pub fn 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( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) + } + } + impl substreams_ethereum::Function for RenounceOwnership { + const NAME: &'static str = "renounceOwnership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetMultiWrapper { + pub u_multi_wrapper: Vec, + } + impl SetMultiWrapper { + const METHOD_ID: [u8; 4] = [208u8, 98u8, 101u8, 24u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_multi_wrapper: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.u_multi_wrapper), + ), + ], + ); + 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 OracleAdded { - pub oracle: Vec, - pub oracle_type: substreams::scalar::BigInt, - } - impl OracleAdded { - const TOPIC_ID: [u8; 32] = [ - 88u8, - 116u8, - 178u8, - 7u8, - 47u8, - 243u8, - 117u8, - 98u8, - 223u8, - 84u8, - 6u8, - 61u8, - 215u8, - 0u8, - 197u8, - 157u8, - 69u8, - 243u8, - 17u8, - 189u8, - 246u8, - 249u8, - 202u8, - 187u8, - 90u8, - 21u8, - 240u8, - 255u8, - 178u8, - 233u8, - 246u8, - 34u8, - ]; - 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; + } + impl substreams_ethereum::Function for SetMultiWrapper { + const NAME: &'static str = "setMultiWrapper"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 TransferOwnership { + pub new_owner: Vec, + } + impl TransferOwnership { + const METHOD_ID: [u8; 4] = [242u8, 253u8, 227u8, 139u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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_owner: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.new_owner))], + ); + 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 { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(8usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - oracle: values + } + } + impl substreams_ethereum::Function for TransferOwnership { + const NAME: &'static str = "transferOwnership"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ConnectorAdded { + pub connector: Vec, + } + impl ConnectorAdded { + const TOPIC_ID: [u8; 32] = [ + 255u8, + 136u8, + 175u8, + 93u8, + 150u8, + 45u8, + 71u8, + 253u8, + 37u8, + 216u8, + 119u8, + 85u8, + 232u8, + 38u8, + 122u8, + 2u8, + 159u8, + 173u8, + 90u8, + 145u8, + 116u8, + 12u8, + 103u8, + 208u8, + 218u8, + 222u8, + 43u8, + 219u8, + 229u8, + 38u8, + 138u8, + 29u8, + ]; + 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 { + connector: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for ConnectorAdded { + const NAME: &'static str = "ConnectorAdded"; + 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 ConnectorRemoved { + pub connector: Vec, + } + impl ConnectorRemoved { + const TOPIC_ID: [u8; 32] = [ + 104u8, + 37u8, + 178u8, + 106u8, + 8u8, + 39u8, + 233u8, + 194u8, + 206u8, + 202u8, + 1u8, + 214u8, + 40u8, + 156u8, + 228u8, + 164u8, + 14u8, + 98u8, + 157u8, + 192u8, + 116u8, + 236u8, + 72u8, + 234u8, + 71u8, + 39u8, + 209u8, + 175u8, + 191u8, + 243u8, + 89u8, + 245u8, + ]; + 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 { + connector: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for ConnectorRemoved { + const NAME: &'static str = "ConnectorRemoved"; + 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 MultiWrapperUpdated { + pub multi_wrapper: Vec, + } + impl MultiWrapperUpdated { + const TOPIC_ID: [u8; 32] = [ + 16u8, + 48u8, + 21u8, + 47u8, + 226u8, + 6u8, + 43u8, + 87u8, + 74u8, + 131u8, + 14u8, + 107u8, + 159u8, + 19u8, + 198u8, + 89u8, + 149u8, + 153u8, + 13u8, + 243u8, + 30u8, + 77u8, + 199u8, + 8u8, + 209u8, + 66u8, + 83u8, + 59u8, + 179u8, + 173u8, + 15u8, + 82u8, + ]; + 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 { + multi_wrapper: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for MultiWrapperUpdated { + const NAME: &'static str = "MultiWrapperUpdated"; + 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 OracleAdded { + pub oracle: Vec, + pub oracle_type: substreams::scalar::BigInt, + } + impl OracleAdded { + const TOPIC_ID: [u8; 32] = [ + 88u8, + 116u8, + 178u8, + 7u8, + 47u8, + 243u8, + 117u8, + 98u8, + 223u8, + 84u8, + 6u8, + 61u8, + 215u8, + 0u8, + 197u8, + 157u8, + 69u8, + 243u8, + 17u8, + 189u8, + 246u8, + 249u8, + 202u8, + 187u8, + 90u8, + 21u8, + 240u8, + 255u8, + 178u8, + 233u8, + 246u8, + 34u8, + ]; + 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::Uint(8usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + oracle: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + oracle_type: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - oracle_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) - }, - }) - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for OracleAdded { - const NAME: &'static str = "OracleAdded"; - 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 OracleAdded { + const NAME: &'static str = "OracleAdded"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct OracleRemoved { - pub oracle: Vec, - pub oracle_type: substreams::scalar::BigInt, - } - impl OracleRemoved { - const TOPIC_ID: [u8; 32] = [ - 122u8, - 127u8, - 86u8, - 113u8, - 111u8, - 231u8, - 3u8, - 251u8, - 25u8, - 5u8, - 41u8, - 195u8, - 54u8, - 229u8, - 125u8, - 247u8, - 26u8, - 184u8, - 129u8, - 136u8, - 186u8, - 71u8, - 232u8, - 215u8, - 134u8, - 186u8, - 198u8, - 132u8, - 182u8, - 26u8, - 185u8, - 166u8, - ]; - 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::Uint(8usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - oracle: values + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OracleRemoved { + pub oracle: Vec, + pub oracle_type: substreams::scalar::BigInt, + } + impl OracleRemoved { + const TOPIC_ID: [u8; 32] = [ + 122u8, + 127u8, + 86u8, + 113u8, + 111u8, + 231u8, + 3u8, + 251u8, + 25u8, + 5u8, + 41u8, + 195u8, + 54u8, + 229u8, + 125u8, + 247u8, + 26u8, + 184u8, + 129u8, + 136u8, + 186u8, + 71u8, + 232u8, + 215u8, + 134u8, + 186u8, + 198u8, + 132u8, + 182u8, + 26u8, + 185u8, + 166u8, + ]; + 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::Uint(8usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + oracle: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + oracle_type: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - oracle_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) - }, - }) - } + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } - impl substreams_ethereum::Event for OracleRemoved { - const NAME: &'static str = "OracleRemoved"; - 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 OracleRemoved { + const NAME: &'static str = "OracleRemoved"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - #[derive(Debug, Clone, PartialEq)] - pub struct OwnershipTransferred { - pub previous_owner: Vec, - pub new_owner: Vec, - } - impl OwnershipTransferred { - const TOPIC_ID: [u8; 32] = [ - 139u8, - 224u8, - 7u8, - 156u8, - 83u8, - 22u8, - 89u8, - 20u8, - 19u8, - 68u8, - 205u8, - 31u8, - 208u8, - 164u8, - 242u8, - 132u8, - 25u8, - 73u8, - 127u8, - 151u8, - 34u8, - 163u8, - 218u8, - 175u8, - 227u8, - 180u8, - 24u8, - 111u8, - 107u8, - 100u8, - 87u8, - 224u8, - ]; - 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 { - previous_owner: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct OwnershipTransferred { + pub previous_owner: Vec, + pub new_owner: Vec, + } + impl OwnershipTransferred { + const TOPIC_ID: [u8; 32] = [ + 139u8, + 224u8, + 7u8, + 156u8, + 83u8, + 22u8, + 89u8, + 20u8, + 19u8, + 68u8, + 205u8, + 31u8, + 208u8, + 164u8, + 242u8, + 132u8, + 25u8, + 73u8, + 127u8, + 151u8, + 34u8, + 163u8, + 218u8, + 175u8, + 227u8, + 180u8, + 24u8, + 111u8, + 107u8, + 100u8, + 87u8, + 224u8, + ]; + 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 { + previous_owner: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'previous_owner' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'previous_owner' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - new_owner: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + new_owner: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'new_owner' from topic of type 'address': {:?}", + e ) - .map_err(|e| { - format!( - "unable to decode param 'new_owner' 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 OwnershipTransferred { - const NAME: &'static str = "OwnershipTransferred"; - 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 OwnershipTransferred { + const NAME: &'static str = "OwnershipTransferred"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/abi/oracle/sushiswap.rs b/src/abi/oracle/sushiswap.rs index 9fcb4c7..d05d7b5 100644 --- a/src/abi/oracle/sushiswap.rs +++ b/src/abi/oracle/sushiswap.rs @@ -1,1370 +1,1293 @@ - 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 GetLpTokenPriceUsdc { - pub token_address: Vec, - } - impl GetLpTokenPriceUsdc { - const METHOD_ID: [u8; 4] = [88u8, 56u8, 80u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 - } - } - } +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 GetLpTokenPriceUsdc { + pub token_address: Vec, + } + impl GetLpTokenPriceUsdc { + const METHOD_ID: [u8; 4] = [88u8, 56u8, 80u8, 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::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for GetLpTokenPriceUsdc { - const NAME: &'static str = "getLpTokenPriceUsdc"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address( + ethabi::Address::from_slice(&self.token_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable - for GetLpTokenPriceUsdc { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetLpTokenTotalLiquidityUsdc { - pub token_address: Vec, - } - impl GetLpTokenTotalLiquidityUsdc { - const METHOD_ID: [u8; 4] = [151u8, 58u8, 174u8, 253u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 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 - } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetLpTokenTotalLiquidityUsdc { - const NAME: &'static str = "getLpTokenTotalLiquidityUsdc"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetLpTokenPriceUsdc { + const NAME: &'static str = "getLpTokenPriceUsdc"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetLpTokenTotalLiquidityUsdc { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPriceFromRouter { - pub token0_address: Vec, - pub token1_address: Vec, - } - impl GetPriceFromRouter { - const METHOD_ID: [u8; 4] = [54u8, 158u8, 228u8, 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::Address, ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - token0_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token1_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.token0_address), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.token1_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 - } - } - } + fn encode(&self) -> Vec { + self.encode() } - impl substreams_ethereum::Function for GetPriceFromRouter { - const NAME: &'static str = "getPriceFromRouter"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetLpTokenPriceUsdc { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable - for GetPriceFromRouter { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetLpTokenTotalLiquidityUsdc { + pub token_address: Vec, + } + impl GetLpTokenTotalLiquidityUsdc { + const METHOD_ID: [u8; 4] = [151u8, 58u8, 174u8, 253u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let 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_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPriceFromRouterUsdc { - pub token_address: Vec, - } - impl GetPriceFromRouterUsdc { - const METHOD_ID: [u8; 4] = [188u8, 82u8, 241u8, 49u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 - } - } - } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.token_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::Function for GetPriceFromRouterUsdc { - const NAME: &'static str = "getPriceFromRouterUsdc"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - impl substreams_ethereum::rpc::RPCDecodable - for GetPriceFromRouterUsdc { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + 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) + }) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPriceUsdc { - pub token_address: Vec, - } - impl GetPriceUsdc { - const METHOD_ID: [u8; 4] = [214u8, 26u8, 120u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 match_call(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(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 - } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for GetPriceUsdc { - const NAME: &'static str = "getPriceUsdc"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetLpTokenTotalLiquidityUsdc { + const NAME: &'static str = "getLpTokenTotalLiquidityUsdc"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable - for GetPriceUsdc { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct GetRouterForLpToken { - pub token_address: Vec, - } - impl GetRouterForLpToken { - const METHOD_ID: [u8; 4] = [234u8, 164u8, 87u8, 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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetLpTokenTotalLiquidityUsdc { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPriceFromRouter { + pub token0_address: Vec, + pub token1_address: Vec, + } + impl GetPriceFromRouter { + const METHOD_ID: [u8; 4] = [54u8, 158u8, 228u8, 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::Address, ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token0_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token1_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for GetRouterForLpToken { - const NAME: &'static str = "getRouterForLpToken"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address( + ethabi::Address::from_slice(&self.token0_address), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.token1_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for GetRouterForLpToken { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - #[derive(Debug, Clone, PartialEq)] - pub struct IsLpToken { - pub token_address: Vec, - } - impl IsLpToken { - const METHOD_ID: [u8; 4] = [15u8, 36u8, 202u8, 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 { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 IsLpToken { - const NAME: &'static str = "isLpToken"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetPriceFromRouter { + const NAME: &'static str = "getPriceFromRouter"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable for IsLpToken { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) } - #[derive(Debug, Clone, PartialEq)] - pub struct PrimaryFactoryAddress {} - impl PrimaryFactoryAddress { - const METHOD_ID: [u8; 4] = [230u8, 166u8, 141u8, 0u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetPriceFromRouter { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPriceFromRouterUsdc { + pub token_address: Vec, + } + impl GetPriceFromRouterUsdc { + const METHOD_ID: [u8; 4] = [188u8, 82u8, 241u8, 49u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for PrimaryFactoryAddress { - const NAME: &'static str = "primaryFactoryAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address( + ethabi::Address::from_slice(&self.token_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for PrimaryFactoryAddress { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - #[derive(Debug, Clone, PartialEq)] - pub struct PrimaryRouterAddress {} - impl PrimaryRouterAddress { - const METHOD_ID: [u8; 4] = [108u8, 115u8, 148u8, 16u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 PrimaryRouterAddress { - const NAME: &'static str = "primaryRouterAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetPriceFromRouterUsdc { + const NAME: &'static str = "getPriceFromRouterUsdc"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for PrimaryRouterAddress { - 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 SecondaryFactoryAddress {} - impl SecondaryFactoryAddress { - const METHOD_ID: [u8; 4] = [35u8, 55u8, 60u8, 122u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetPriceFromRouterUsdc { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPriceUsdc { + pub token_address: Vec, + } + impl GetPriceUsdc { + const METHOD_ID: [u8; 4] = [214u8, 26u8, 120u8, 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::Address], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 SecondaryFactoryAddress { - const NAME: &'static str = "secondaryFactoryAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetPriceUsdc { + const NAME: &'static str = "getPriceUsdc"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> - for SecondaryFactoryAddress { - 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 SecondaryRouterAddress {} - impl SecondaryRouterAddress { - const METHOD_ID: [u8; 4] = [37u8, 211u8, 102u8, 241u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetPriceUsdc { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetRouterForLpToken { + pub token_address: Vec, + } + impl GetRouterForLpToken { + const METHOD_ID: [u8; 4] = [234u8, 164u8, 87u8, 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::Address], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 SecondaryRouterAddress { - const NAME: &'static str = "secondaryRouterAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetRouterForLpToken { + const NAME: &'static str = "getRouterForLpToken"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for SecondaryRouterAddress { - 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 UsdcAddress {} - impl UsdcAddress { - const METHOD_ID: [u8; 4] = [2u8, 212u8, 84u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for GetRouterForLpToken { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct IsLpToken { + pub token_address: Vec, + } + impl IsLpToken { + const METHOD_ID: [u8; 4] = [15u8, 36u8, 202u8, 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 { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 UsdcAddress { - const NAME: &'static str = "usdcAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 IsLpToken { + const NAME: &'static str = "isLpToken"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable for IsLpToken { + fn output(data: &[u8]) -> Result { + Self::output(data) } - impl substreams_ethereum::rpc::RPCDecodable> for UsdcAddress { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + } + #[derive(Debug, Clone, PartialEq)] + pub struct PrimaryFactoryAddress {} + impl PrimaryFactoryAddress { + const METHOD_ID: [u8; 4] = [230u8, 166u8, 141u8, 0u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 WethAddress {} - impl WethAddress { - const METHOD_ID: [u8; 4] = [79u8, 14u8, 14u8, 243u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + } + } + impl substreams_ethereum::Function for PrimaryFactoryAddress { + const NAME: &'static str = "primaryFactoryAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for PrimaryFactoryAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct PrimaryRouterAddress {} + impl PrimaryRouterAddress { + const METHOD_ID: [u8; 4] = [108u8, 115u8, 148u8, 16u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(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; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) + } + } + impl substreams_ethereum::Function for PrimaryRouterAddress { + const NAME: &'static str = "primaryRouterAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for PrimaryRouterAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SecondaryFactoryAddress {} + impl SecondaryFactoryAddress { + const METHOD_ID: [u8; 4] = [35u8, 55u8, 60u8, 122u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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 SecondaryFactoryAddress { + const NAME: &'static str = "secondaryFactoryAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for SecondaryFactoryAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SecondaryRouterAddress {} + impl SecondaryRouterAddress { + const METHOD_ID: [u8; 4] = [37u8, 211u8, 102u8, 241u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for WethAddress { - const NAME: &'static str = "wethAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + } + impl substreams_ethereum::Function for SecondaryRouterAddress { + const NAME: &'static str = "secondaryRouterAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for SecondaryRouterAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct UsdcAddress {} + impl UsdcAddress { + const METHOD_ID: [u8; 4] = [2u8, 212u8, 84u8, 87u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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) + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } } - fn encode(&self) -> Vec { - self.encode() + } + } + impl substreams_ethereum::Function for UsdcAddress { + const NAME: &'static str = "usdcAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for UsdcAddress { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct WethAddress {} + impl WethAddress { + const METHOD_ID: [u8; 4] = [79u8, 14u8, 14u8, 243u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 WethAddress { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } } } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - } \ No newline at end of file + impl substreams_ethereum::Function for WethAddress { + const NAME: &'static str = "wethAddress"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for WethAddress { + 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; +} \ No newline at end of file diff --git a/src/abi/oracle/yearn_lens.rs b/src/abi/oracle/yearn_lens.rs index 97af8ed..f8b0bd4 100644 --- a/src/abi/oracle/yearn_lens.rs +++ b/src/abi/oracle/yearn_lens.rs @@ -1,1301 +1,1252 @@ - 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 AddTokenAlias { - pub token_address: Vec, - pub token_alias_address: Vec, - } - impl AddTokenAlias { - const METHOD_ID: [u8; 4] = [106u8, 76u8, 179u8, 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 { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_alias_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.token_alias_address), - ), - ], - ); - 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 AddTokenAlias { + pub token_address: Vec, + pub token_alias_address: Vec, + } + impl AddTokenAlias { + const METHOD_ID: [u8; 4] = [106u8, 76u8, 179u8, 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 { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_alias_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for AddTokenAlias { - const NAME: &'static str = "addTokenAlias"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address( + ethabi::Address::from_slice(&self.token_address), + ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.token_alias_address), + ), + ], + ); + 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 AddTokenAliases { - pub u_token_aliases: Vec<(Vec, Vec)>, - } - impl AddTokenAliases { - const METHOD_ID: [u8; 4] = [136u8, 222u8, 165u8, 42u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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::Address, ethabi::ParamType::Address], - ), + } + impl substreams_ethereum::Function for AddTokenAlias { + const NAME: &'static str = "addTokenAlias"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 AddTokenAliases { + pub u_token_aliases: Vec<(Vec, Vec)>, + } + impl AddTokenAliases { + const METHOD_ID: [u8; 4] = [136u8, 222u8, 165u8, 42u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = 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::Address, ethabi::ParamType::Address], ), ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_token_aliases: 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(), - tuple_elements[1usize] - .clone() - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - }) - .collect(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_token_aliases - .iter() - .map(|inner| ethabi::Token::Tuple( - vec![ - ethabi::Token::Address(ethabi::Address::from_slice(& inner - .0)), ethabi::Token::Address(ethabi::Address::from_slice(& - inner.1)) - ], - )) - .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, - } - } + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + u_token_aliases: 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(), + tuple_elements[1usize] + .clone() + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + }) + .collect(), + }) } - impl substreams_ethereum::Function for AddTokenAliases { - const NAME: &'static str = "addTokenAliases"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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( + &[ + { + let v = self + .u_token_aliases + .iter() + .map(|inner| ethabi::Token::Tuple( + vec![ + ethabi::Token::Address(ethabi::Address::from_slice(& inner + .0)), ethabi::Token::Address(ethabi::Address::from_slice(& + inner.1)) + ], + )) + .collect(); + ethabi::Token::Array(v) + }, + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - #[derive(Debug, Clone, PartialEq)] - pub struct Calculations {} - impl Calculations { - const METHOD_ID: [u8; 4] = [61u8, 113u8, 71u8, 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 match_call(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 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(), + } + } + impl substreams_ethereum::Function for AddTokenAliases { + const NAME: &'static str = "addTokenAliases"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 Calculations {} + impl Calculations { + const METHOD_ID: [u8; 4] = [61u8, 113u8, 71u8, 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::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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option>> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 Calculations { - const NAME: &'static str = "calculations"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 Calculations { + const NAME: &'static str = "calculations"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable>> for Calculations { - 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 GetNormalizedValueUsdc1 { - pub token_address: Vec, - pub amount: substreams::scalar::BigInt, - } - impl GetNormalizedValueUsdc1 { - const METHOD_ID: [u8; 4] = [138u8, 127u8, 102u8, 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_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.token_address), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable>> for Calculations { + fn output(data: &[u8]) -> Result>, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNormalizedValueUsdc1 { + pub token_address: Vec, + pub amount: substreams::scalar::BigInt, + } + impl GetNormalizedValueUsdc1 { + const METHOD_ID: [u8; 4] = [138u8, 127u8, 102u8, 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_address: 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("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 GetNormalizedValueUsdc1 { - const NAME: &'static str = "getNormalizedValueUsdc1"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address( + ethabi::Address::from_slice(&self.token_address), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - impl substreams_ethereum::rpc::RPCDecodable - for GetNormalizedValueUsdc1 { - fn output(data: &[u8]) -> Result { - Self::output(data) + 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 GetNormalizedValueUsdc2 { - pub token_address: Vec, - pub amount: substreams::scalar::BigInt, - pub price_usdc: substreams::scalar::BigInt, - } - impl GetNormalizedValueUsdc2 { - const METHOD_ID: [u8; 4] = [208u8, 45u8, 32u8, 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()); + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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, - 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 { - token_address: 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) - }, - price_usdc: { - let mut v = [0 as u8; 32]; - values - .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( + } + } + impl substreams_ethereum::Function for GetNormalizedValueUsdc1 { + const NAME: &'static str = "getNormalizedValueUsdc1"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetNormalizedValueUsdc1 { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetNormalizedValueUsdc2 { + pub token_address: Vec, + pub amount: substreams::scalar::BigInt, + pub price_usdc: substreams::scalar::BigInt, + } + impl GetNormalizedValueUsdc2 { + const METHOD_ID: [u8; 4] = [208u8, 45u8, 32u8, 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::Token::Address( - ethabi::Address::from_slice(&self.token_address), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.price_usdc.clone().to_bytes_be() { - (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::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - ); - let mut encoded = Vec::with_capacity(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({ + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_address: 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("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 GetNormalizedValueUsdc2 { - const NAME: &'static str = "getNormalizedValueUsdc2"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for GetNormalizedValueUsdc2 { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetPriceUsdcRecommended { - pub token_address: Vec, - } - impl GetPriceUsdcRecommended { - const METHOD_ID: [u8; 4] = [72u8, 43u8, 163u8, 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 { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - let mut encoded = Vec::with_capacity(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({ + }, + price_usdc: { 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 GetPriceUsdcRecommended { - const NAME: &'static str = "getPriceUsdcRecommended"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address( + ethabi::Address::from_slice(&self.token_address), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.amount.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.price_usdc.clone().to_bytes_be() { + (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 } - impl substreams_ethereum::rpc::RPCDecodable - for GetPriceUsdcRecommended { - fn output(data: &[u8]) -> Result { - Self::output(data) - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - #[derive(Debug, Clone, PartialEq)] - pub struct ManagementList {} - impl ManagementList { - const METHOD_ID: [u8; 4] = [88u8, 68u8, 58u8, 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 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 ManagementList { - const NAME: &'static str = "managementList"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetNormalizedValueUsdc2 { + const NAME: &'static str = "getNormalizedValueUsdc2"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for ManagementList { - 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 RemoveTokenAlias { - pub token_address: Vec, - } - impl RemoveTokenAlias { - const METHOD_ID: [u8; 4] = [243u8, 174u8, 48u8, 119u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let 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_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .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_address), - ), - ], - ); - 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 RemoveTokenAlias { - const NAME: &'static str = "removeTokenAlias"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetNormalizedValueUsdc2 { + fn output(data: &[u8]) -> Result { + Self::output(data) } - #[derive(Debug, Clone, PartialEq)] - pub struct SetCalculations { - pub calculation_addresses: Vec>, - } - impl SetCalculations { - const METHOD_ID: [u8; 4] = [37u8, 90u8, 172u8, 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::Array( - Box::new(ethabi::ParamType::Address), - ), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - calculation_addresses: 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( - &[ - { - let v = self - .calculation_addresses - .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 + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetPriceUsdcRecommended { + pub token_address: Vec, + } + impl GetPriceUsdcRecommended { + const METHOD_ID: [u8; 4] = [72u8, 43u8, 163u8, 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 { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .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_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None } } } - impl substreams_ethereum::Function for SetCalculations { - const NAME: &'static str = "setCalculations"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 GetPriceUsdcRecommended { + const NAME: &'static str = "getPriceUsdcRecommended"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GetPriceUsdcRecommended { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct ManagementList {} + impl ManagementList { + const METHOD_ID: [u8; 4] = [88u8, 68u8, 58u8, 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, } } - #[derive(Debug, Clone, PartialEq)] - pub struct TokenAliases { - pub param0: Vec, - } - impl TokenAliases { - const METHOD_ID: [u8; 4] = [65u8, 57u8, 76u8, 237u8]; - pub fn decode( - call: &substreams_ethereum::pb::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::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - param0: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.param0))], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + } + impl substreams_ethereum::Function for ManagementList { + const NAME: &'static str = "managementList"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for ManagementList { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct RemoveTokenAlias { + pub token_address: Vec, + } + impl RemoveTokenAlias { + const METHOD_ID: [u8; 4] = [243u8, 174u8, 48u8, 119u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) } - impl substreams_ethereum::Function for TokenAliases { - const NAME: &'static str = "tokenAliases"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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::Address( + ethabi::Address::from_slice(&self.token_address), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded } - impl substreams_ethereum::rpc::RPCDecodable> for TokenAliases { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) + pub fn 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 UsdcAddress {} - impl UsdcAddress { - const METHOD_ID: [u8; 4] = [2u8, 212u8, 84u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), + } + impl substreams_ethereum::Function for RemoveTokenAlias { + const NAME: &'static str = "removeTokenAlias"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 SetCalculations { + pub calculation_addresses: Vec>, + } + impl SetCalculations { + const METHOD_ID: [u8; 4] = [37u8, 90u8, 172u8, 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::Array(Box::new(ethabi::ParamType::Address))], + maybe_data.unwrap(), ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + calculation_addresses: 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( + &[ + { + let v = self + .calculation_addresses + .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, } - pub fn 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 SetCalculations { + const NAME: &'static str = "setCalculations"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 TokenAliases { + pub param0: Vec, + } + impl TokenAliases { + const METHOD_ID: [u8; 4] = [65u8, 57u8, 76u8, 237u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + param0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.param0))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => 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 UsdcAddress { - const NAME: &'static str = "usdcAddress"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_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 TokenAliases { + const NAME: &'static str = "tokenAliases"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) } - impl substreams_ethereum::rpc::RPCDecodable> for UsdcAddress { - 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() } } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct TokenAliasAdded { - pub token_address: Vec, - pub token_alias_address: Vec, - } - impl TokenAliasAdded { - const TOPIC_ID: [u8; 32] = [ - 169u8, - 142u8, - 6u8, - 241u8, - 104u8, - 103u8, - 71u8, - 107u8, - 187u8, - 39u8, - 100u8, - 88u8, - 114u8, - 146u8, - 251u8, - 132u8, - 219u8, - 208u8, - 155u8, - 85u8, - 2u8, - 0u8, - 17u8, - 19u8, - 188u8, - 18u8, - 184u8, - 53u8, - 156u8, - 185u8, - 84u8, - 241u8, - ]; - 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 { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_alias_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } + impl substreams_ethereum::rpc::RPCDecodable> for TokenAliases { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) } - impl substreams_ethereum::Event for TokenAliasAdded { - const NAME: &'static str = "TokenAliasAdded"; - 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 UsdcAddress {} + impl UsdcAddress { + const METHOD_ID: [u8; 4] = [2u8, 212u8, 84u8, 87u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn 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 TokenAliasRemoved { - pub token_address: Vec, - } - impl TokenAliasRemoved { - const TOPIC_ID: [u8; 32] = [ - 18u8, - 98u8, - 170u8, - 61u8, - 15u8, - 12u8, - 101u8, - 47u8, - 26u8, - 85u8, - 136u8, - 141u8, - 148u8, - 108u8, - 99u8, - 31u8, - 26u8, - 35u8, - 79u8, - 88u8, - 125u8, - 158u8, - 62u8, - 159u8, - 142u8, - 227u8, - 153u8, - 116u8, - 182u8, - 40u8, - 254u8, - 127u8, - ]; - 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; + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses.get(0).expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => 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], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - token_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) } } - impl substreams_ethereum::Event for TokenAliasRemoved { - const NAME: &'static str = "TokenAliasRemoved"; - 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 UsdcAddress { + const NAME: &'static str = "usdcAddress"; + 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 UsdcAddress { + 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 TokenAliasAdded { + pub token_address: Vec, + pub token_alias_address: Vec, + } + impl TokenAliasAdded { + const TOPIC_ID: [u8; 32] = [ + 169u8, + 142u8, + 6u8, + 241u8, + 104u8, + 103u8, + 71u8, + 107u8, + 187u8, + 39u8, + 100u8, + 88u8, + 114u8, + 146u8, + 251u8, + 132u8, + 219u8, + 208u8, + 155u8, + 85u8, + 2u8, + 0u8, + 17u8, + 19u8, + 188u8, + 18u8, + 184u8, + 53u8, + 156u8, + 185u8, + 84u8, + 241u8, + ]; + 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 { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_alias_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for TokenAliasAdded { + const NAME: &'static str = "TokenAliasAdded"; + 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 TokenAliasRemoved { + pub token_address: Vec, + } + impl TokenAliasRemoved { + const TOPIC_ID: [u8; 32] = [ + 18u8, + 98u8, + 170u8, + 61u8, + 15u8, + 12u8, + 101u8, + 47u8, + 26u8, + 85u8, + 136u8, + 141u8, + 148u8, + 108u8, + 99u8, + 31u8, + 26u8, + 35u8, + 79u8, + 88u8, + 125u8, + 158u8, + 62u8, + 159u8, + 142u8, + 227u8, + 153u8, + 116u8, + 182u8, + 40u8, + 254u8, + 127u8, + ]; + 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 { + token_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + } + impl substreams_ethereum::Event for TokenAliasRemoved { + const NAME: &'static str = "TokenAliasRemoved"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { + Self::decode(log) + } + } +} \ No newline at end of file diff --git a/src/modules/5_map_extract_pool_events.rs b/src/modules/5_map_extract_pool_events.rs index 6a67437..5e865e3 100644 --- a/src/modules/5_map_extract_pool_events.rs +++ b/src/modules/5_map_extract_pool_events.rs @@ -23,6 +23,7 @@ use crate::{ TokenExchangeUnderlying, }, common::{event_extraction, pool_utils::is_metapool, prices::get_token_usd_price}, + constants::ETH_ADDRESS, key_management::store_key_manager::StoreKey, pb::{ curve::types::v1::{ @@ -1212,7 +1213,7 @@ fn extract_withdraw_one_event( pool_address )); - let token_transfer = event_extraction::extract_specific_transfer_event( + let mut token_transfer = event_extraction::extract_specific_transfer_event( trx, None, Some(&pool.address_vec()), @@ -1223,24 +1224,49 @@ fn extract_withdraw_one_event( // If we cannot get the `Transfer` event from the initial condition, the transfer may originate // from a zap and we should try again without specifying the `to` address. - let token_transfer = match token_transfer { - Ok(token_transfer) => Some(token_transfer), - Err(_) => event_extraction::extract_specific_transfer_event( + if token_transfer.is_err() { + token_transfer = event_extraction::extract_specific_transfer_event( trx, None, Some(&pool.address_vec()), None, Some(&coin_amount), log.index, - ) - .ok(), - }; + ); + } + + let mut is_eth_transfer = false; + + // Check if this transaction involves native ETH transfers (no token event). + if token_transfer.is_err() { + // let coin_amount_bytes_be = coin_amount.to_signed_bytes_be(); + trx.calls().for_each(|call| { + if let Some(value) = &call.call.value { + let eth_value: BigInt = value.into(); + if eth_value == coin_amount { + is_eth_transfer = true; + } + } + }); + } let input_tokens = pool .input_tokens_ordered .iter() .map(|address| { - if let Some(transfer) = &token_transfer { + if is_eth_transfer && address == &Hex::encode(Ð_ADDRESS) { + if let Some(token) = pool.input_tokens.iter().find(|t| &t.address == address) { + let token_price = + get_token_usd_price(token, &uniswap_prices, &chainlink_prices); + return TokenAmount { + token_address: address.clone(), + amount: coin_amount.clone().into(), + amount_usd: (coin_amount.to_decimal(token.decimals) * token_price) + .to_string(), + source: TokenSource::Default as i32, + }; + } + } else if let Ok(transfer) = &token_transfer { if &Hex::encode(&transfer.token_address) == address { if let Some(token) = pool.input_tokens.iter().find(|t| &t.address == address) { let token_price = From 6cf69a700204764957d1cac18a433ae27f19b8d6 Mon Sep 17 00:00:00 2001 From: jmulq Date: Mon, 22 Apr 2024 19:04:30 +0100 Subject: [PATCH 2/5] fix: add missing RemoveLiquidityOne event --- abi/curve/Pool.abi.json | 27 + src/abi/curve/pool.rs | 124 + src/abi/curve/pools/metapool_old.abi.json | 6217 --------------------- src/abi/mod.rs | 2 +- src/modules/5_map_extract_pool_events.rs | 48 +- 5 files changed, 193 insertions(+), 6225 deletions(-) delete mode 100644 src/abi/curve/pools/metapool_old.abi.json mode change 100755 => 100644 src/abi/mod.rs diff --git a/abi/curve/Pool.abi.json b/abi/curve/Pool.abi.json index e0f2550..3235fb1 100644 --- a/abi/curve/Pool.abi.json +++ b/abi/curve/Pool.abi.json @@ -621,6 +621,33 @@ "anonymous": false, "type": "event" }, + { + "name": "RemoveLiquidityOne", + "inputs": [ + { + "name": "provider", + "type": "address", + "indexed": true + }, + { + "name": "token_amount", + "type": "uint256", + "indexed": false + }, + { + "name": "coin_index", + "type": "uint256", + "indexed": false + }, + { + "name": "coin_amount", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, { "name": "RemoveLiquidityImbalance", "inputs": [ diff --git a/src/abi/curve/pool.rs b/src/abi/curve/pool.rs index 8d02812..ba261a5 100644 --- a/src/abi/curve/pool.rs +++ b/src/abi/curve/pool.rs @@ -11447,6 +11447,130 @@ pub mod events { } } #[derive(Debug, Clone, PartialEq)] + pub struct RemoveLiquidityOne5 { + pub provider: Vec, + pub token_amount: substreams::scalar::BigInt, + pub coin_index: substreams::scalar::BigInt, + pub coin_amount: substreams::scalar::BigInt, + } + impl RemoveLiquidityOne5 { + const TOPIC_ID: [u8; 32] = [ + 90u8, + 208u8, + 86u8, + 242u8, + 226u8, + 138u8, + 140u8, + 236u8, + 35u8, + 32u8, + 21u8, + 64u8, + 107u8, + 132u8, + 54u8, + 104u8, + 193u8, + 227u8, + 108u8, + 218u8, + 89u8, + 129u8, + 39u8, + 236u8, + 59u8, + 140u8, + 89u8, + 184u8, + 199u8, + 39u8, + 115u8, + 160u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_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) + }, + coin_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) + }, + coin_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 RemoveLiquidityOne5 { + const NAME: &'static str = "RemoveLiquidityOne5"; + 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 StopRampA { pub current_a: substreams::scalar::BigInt, pub current_gamma: substreams::scalar::BigInt, diff --git a/src/abi/curve/pools/metapool_old.abi.json b/src/abi/curve/pools/metapool_old.abi.json deleted file mode 100644 index 7bb7323..0000000 --- a/src/abi/curve/pools/metapool_old.abi.json +++ /dev/null @@ -1,6217 +0,0 @@ - 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 A {} - impl A { - const METHOD_ID: [u8; 4] = [244u8, 70u8, 193u8, 208u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - 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 A { - const NAME: &'static str = "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 A { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct APrecise {} - impl APrecise { - const METHOD_ID: [u8; 4] = [118u8, 162u8, 240u8, 240u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 APrecise { - const NAME: &'static str = "A_precise"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for APrecise { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AddLiquidity { - pub u_amounts: [substreams::scalar::BigInt; 2usize], - pub u_min_mint_amount: substreams::scalar::BigInt, - } - impl AddLiquidity { - const METHOD_ID: [u8; 4] = [11u8, 76u8, 126u8, 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - u_min_mint_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_min_mint_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::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 AddLiquidity { - const NAME: &'static str = "add_liquidity"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for AddLiquidity { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminActionsDeadline {} - impl AdminActionsDeadline { - const METHOD_ID: [u8; 4] = [64u8, 94u8, 40u8, 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 { - 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 AdminActionsDeadline { - const NAME: &'static str = "admin_actions_deadline"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for AdminActionsDeadline { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminBalances { - pub i: substreams::scalar::BigInt, - } - impl AdminBalances { - const METHOD_ID: [u8; 4] = [226u8, 231u8, 210u8, 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::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - 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::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 { - 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 AdminBalances { - const NAME: &'static str = "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 AdminBalances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct AdminFee {} - impl AdminFee { - const METHOD_ID: [u8; 4] = [254u8, 227u8, 247u8, 249u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 AdminFee { - const NAME: &'static str = "admin_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for AdminFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ApplyNewFee {} - impl ApplyNewFee { - const METHOD_ID: [u8; 4] = [79u8, 18u8, 254u8, 151u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 ApplyNewFee { - const NAME: &'static str = "apply_new_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 ApplyTransferOwnership {} - impl ApplyTransferOwnership { - const METHOD_ID: [u8; 4] = [106u8, 28u8, 5u8, 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 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 ApplyTransferOwnership { - const NAME: &'static str = "apply_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 Balances { - pub arg0: substreams::scalar::BigInt, - } - impl Balances { - const METHOD_ID: [u8; 4] = [73u8, 3u8, 176u8, 209u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::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 { - 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 Balances { - const NAME: &'static str = "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 Balances { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BaseCacheUpdated {} - impl BaseCacheUpdated { - const METHOD_ID: [u8; 4] = [130u8, 150u8, 248u8, 79u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 BaseCacheUpdated { - const NAME: &'static str = "base_cache_updated"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for BaseCacheUpdated { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BaseCoins { - pub arg0: substreams::scalar::BigInt, - } - impl BaseCoins { - const METHOD_ID: [u8; 4] = [135u8, 203u8, 79u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 BaseCoins { - const NAME: &'static str = "base_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 BaseCoins { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BasePool {} - impl BasePool { - const METHOD_ID: [u8; 4] = [93u8, 99u8, 98u8, 187u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for BasePool { - const NAME: &'static str = "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 BasePool { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct BaseVirtualPrice {} - impl BaseVirtualPrice { - const METHOD_ID: [u8; 4] = [149u8, 204u8, 192u8, 47u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 BaseVirtualPrice { - const NAME: &'static str = "base_virtual_price"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for BaseVirtualPrice { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CalcTokenAmount { - pub u_amounts: [substreams::scalar::BigInt; 2usize], - pub u_is_deposit: bool, - } - impl CalcTokenAmount { - const METHOD_ID: [u8; 4] = [237u8, 142u8, 132u8, 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Bool, - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - u_is_deposit: values - .pop() - .expect(INTERNAL_ERR) - .into_bool() - .expect(INTERNAL_ERR), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Bool(self.u_is_deposit.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 { - 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 CalcTokenAmount { - const NAME: &'static str = "calc_token_amount"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for CalcTokenAmount { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CalcWithdrawOneCoin { - pub u_token_amount: substreams::scalar::BigInt, - pub i: substreams::scalar::BigInt, - } - impl CalcWithdrawOneCoin { - const METHOD_ID: [u8; 4] = [204u8, 43u8, 39u8, 215u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_token_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) - }, - i: { - 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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_token_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - { - let non_full_signed_bytes = self.i.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()), - ) - }, - ], - ); - let mut encoded = Vec::with_capacity(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 CalcWithdrawOneCoin { - const NAME: &'static str = "calc_withdraw_one_coin"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for CalcWithdrawOneCoin { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Coins { - pub arg0: substreams::scalar::BigInt, - } - impl Coins { - const METHOD_ID: [u8; 4] = [198u8, 97u8, 6u8, 87u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 Coins { - const NAME: &'static str = "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 Coins { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct CommitNewFee { - pub u_new_fee: substreams::scalar::BigInt, - pub u_new_admin_fee: substreams::scalar::BigInt, - } - impl CommitNewFee { - const METHOD_ID: [u8; 4] = [91u8, 90u8, 20u8, 103u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = 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 { - u_new_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) - }, - u_new_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) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_new_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.u_new_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(), - ), - ), - ], - ); - 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 CommitNewFee { - const NAME: &'static str = "commit_new_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 u_owner: 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 { - u_owner: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.u_owner))], - ); - 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 DonateAdminFees {} - impl DonateAdminFees { - const METHOD_ID: [u8; 4] = [82u8, 76u8, 57u8, 1u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 DonateAdminFees { - const NAME: &'static str = "donate_admin_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Exchange { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub u_dx: substreams::scalar::BigInt, - pub u_min_dy: substreams::scalar::BigInt, - } - impl Exchange { - const METHOD_ID: [u8; 4] = [61u8, 240u8, 33u8, 36u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - 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 { - i: { - 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) - }, - j: { - 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) - }, - u_dx: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_min_dy: { - let mut v = [0 as u8; 32]; - values - .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( - &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_dx.clone().to_bytes_be() { - (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.u_min_dy.clone().to_bytes_be() { - (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 Exchange { - const NAME: &'static str = "exchange"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for Exchange { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct ExchangeUnderlying { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub u_dx: substreams::scalar::BigInt, - pub u_min_dy: substreams::scalar::BigInt, - } - impl ExchangeUnderlying { - const METHOD_ID: [u8; 4] = [166u8, 65u8, 126u8, 214u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - 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 { - i: { - 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) - }, - j: { - 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) - }, - u_dx: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - u_min_dy: { - let mut v = [0 as u8; 32]; - values - .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( - &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_dx.clone().to_bytes_be() { - (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.u_min_dy.clone().to_bytes_be() { - (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 ExchangeUnderlying { - const NAME: &'static str = "exchange_underlying"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for ExchangeUnderlying { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Fee {} - impl Fee { - const METHOD_ID: [u8; 4] = [221u8, 202u8, 63u8, 67u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 Fee { - const NAME: &'static str = "fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable for Fee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureA {} - impl FutureA { - const METHOD_ID: [u8; 4] = [180u8, 181u8, 119u8, 173u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 FutureA { - const NAME: &'static str = "future_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 FutureA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureATime {} - impl FutureATime { - const METHOD_ID: [u8; 4] = [20u8, 5u8, 34u8, 136u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 FutureATime { - const NAME: &'static str = "future_A_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureATime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureAdminFee {} - impl FutureAdminFee { - const METHOD_ID: [u8; 4] = [227u8, 130u8, 68u8, 98u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 FutureAdminFee { - const NAME: &'static str = "future_admin_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureAdminFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureFee {} - impl FutureFee { - const METHOD_ID: [u8; 4] = [88u8, 104u8, 13u8, 11u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 FutureFee { - const NAME: &'static str = "future_fee"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for FutureFee { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct FutureOwner {} - impl FutureOwner { - const METHOD_ID: [u8; 4] = [30u8, 192u8, 205u8, 193u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for FutureOwner { - const NAME: &'static str = "future_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 FutureOwner { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDy { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub u_dx: substreams::scalar::BigInt, - } - impl GetDy { - const METHOD_ID: [u8; 4] = [94u8, 13u8, 68u8, 63u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - i: { - 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) - }, - j: { - 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) - }, - u_dx: { - let mut v = [0 as u8; 32]; - values - .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( - &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_dx.clone().to_bytes_be() { - (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 GetDy { - const NAME: &'static str = "get_dy"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for GetDy { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetDyUnderlying { - pub i: substreams::scalar::BigInt, - pub j: substreams::scalar::BigInt, - pub u_dx: substreams::scalar::BigInt, - } - impl GetDyUnderlying { - const METHOD_ID: [u8; 4] = [7u8, 33u8, 30u8, 247u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - i: { - 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) - }, - j: { - 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) - }, - u_dx: { - let mut v = [0 as u8; 32]; - values - .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( - &[ - { - let non_full_signed_bytes = self.i.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()), - ) - }, - { - let non_full_signed_bytes = self.j.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_dx.clone().to_bytes_be() { - (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 GetDyUnderlying { - const NAME: &'static str = "get_dy_underlying"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for GetDyUnderlying { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct GetVirtualPrice {} - impl GetVirtualPrice { - const METHOD_ID: [u8; 4] = [187u8, 123u8, 139u8, 128u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 GetVirtualPrice { - const NAME: &'static str = "get_virtual_price"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for GetVirtualPrice { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct InitialA {} - impl InitialA { - const METHOD_ID: [u8; 4] = [84u8, 9u8, 73u8, 26u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 InitialA { - const NAME: &'static str = "initial_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 InitialA { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct InitialATime {} - impl InitialATime { - const METHOD_ID: [u8; 4] = [32u8, 129u8, 6u8, 108u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 InitialATime { - const NAME: &'static str = "initial_A_time"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for InitialATime { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct KillMe {} - impl KillMe { - const METHOD_ID: [u8; 4] = [227u8, 105u8, 136u8, 83u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 KillMe { - const NAME: &'static str = "kill_me"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 LpToken {} - impl LpToken { - const METHOD_ID: [u8; 4] = [130u8, 198u8, 48u8, 102u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for LpToken { - const NAME: &'static str = "lp_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 LpToken { - fn output(data: &[u8]) -> Result, String> { - 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 RampA { - pub u_future_a: substreams::scalar::BigInt, - pub u_future_time: substreams::scalar::BigInt, - } - impl RampA { - const METHOD_ID: [u8; 4] = [60u8, 21u8, 126u8, 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_future_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) - }, - u_future_time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_future_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.u_future_time.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - } - impl substreams_ethereum::Function for RampA { - const NAME: &'static str = "ramp_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidity { - pub u_amount: substreams::scalar::BigInt, - pub u_min_amounts: [substreams::scalar::BigInt; 2usize], - } - impl RemoveLiquidity { - const METHOD_ID: [u8; 4] = [91u8, 54u8, 56u8, 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::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 { - u_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) - }, - u_min_amounts: { - 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::Uint( - ethabi::Uint::from_big_endian( - match self.u_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - { - let v = self - .u_min_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::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<[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 RemoveLiquidity { - const NAME: &'static str = "remove_liquidity"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - 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 RemoveLiquidity { - fn output( - data: &[u8], - ) -> Result<[substreams::scalar::BigInt; 2usize], String> { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidityImbalance { - pub u_amounts: [substreams::scalar::BigInt; 2usize], - pub u_max_burn_amount: substreams::scalar::BigInt, - } - impl RemoveLiquidityImbalance { - const METHOD_ID: [u8; 4] = [227u8, 16u8, 50u8, 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_amounts: { - 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), - ] - }, - u_max_burn_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .u_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::FixedArray(v) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_max_burn_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::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 RemoveLiquidityImbalance { - const NAME: &'static str = "remove_liquidity_imbalance"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for RemoveLiquidityImbalance { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RemoveLiquidityOneCoin { - pub u_token_amount: substreams::scalar::BigInt, - pub i: substreams::scalar::BigInt, - pub u_min_amount: substreams::scalar::BigInt, - } - impl RemoveLiquidityOneCoin { - const METHOD_ID: [u8; 4] = [26u8, 77u8, 1u8, 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::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - u_token_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) - }, - i: { - 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) - }, - u_min_amount: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_token_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - { - let non_full_signed_bytes = self.i.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()), - ) - }, - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.u_min_amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::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 RemoveLiquidityOneCoin { - const NAME: &'static str = "remove_liquidity_one_coin"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for RemoveLiquidityOneCoin { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct RevertNewParameters {} - impl RevertNewParameters { - const METHOD_ID: [u8; 4] = [34u8, 104u8, 64u8, 251u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 RevertNewParameters { - const NAME: &'static str = "revert_new_parameters"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 RevertTransferOwnership {} - impl RevertTransferOwnership { - const METHOD_ID: [u8; 4] = [134u8, 251u8, 241u8, 147u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 RevertTransferOwnership { - const NAME: &'static str = "revert_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 StopRampA {} - impl StopRampA { - const METHOD_ID: [u8; 4] = [85u8, 26u8, 101u8, 136u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 StopRampA { - const NAME: &'static str = "stop_ramp_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() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferOwnershipDeadline {} - impl TransferOwnershipDeadline { - const METHOD_ID: [u8; 4] = [224u8, 160u8, 181u8, 134u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(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 TransferOwnershipDeadline { - const NAME: &'static str = "transfer_ownership_deadline"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for TransferOwnershipDeadline { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct UnkillMe {} - impl UnkillMe { - const METHOD_ID: [u8; 4] = [48u8, 70u8, 249u8, 114u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 UnkillMe { - const NAME: &'static str = "unkill_me"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> 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 WithdrawAdminFees {} - impl WithdrawAdminFees { - const METHOD_ID: [u8; 4] = [48u8, 197u8, 64u8, 133u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - 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 WithdrawAdminFees { - const NAME: &'static str = "withdraw_admin_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() - } - } - } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; - #[derive(Debug, Clone, PartialEq)] - pub struct AddLiquidity { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fees: [substreams::scalar::BigInt; 2usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl AddLiquidity { - const TOPIC_ID: [u8; 32] = [ - 38u8, - 245u8, - 90u8, - 133u8, - 8u8, - 29u8, - 36u8, - 151u8, - 78u8, - 133u8, - 198u8, - 192u8, - 0u8, - 69u8, - 208u8, - 240u8, - 69u8, - 57u8, - 145u8, - 233u8, - 88u8, - 115u8, - 245u8, - 43u8, - 255u8, - 13u8, - 33u8, - 175u8, - 64u8, - 121u8, - 167u8, - 104u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - 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 { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 AddLiquidity { - const NAME: &'static str = "AddLiquidity"; - 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 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 CommitNewFee { - pub deadline: substreams::scalar::BigInt, - pub fee: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - } - impl CommitNewFee { - const TOPIC_ID: [u8; 32] = [ - 53u8, - 31u8, - 197u8, - 218u8, - 47u8, - 191u8, - 72u8, - 15u8, - 34u8, - 37u8, - 222u8, - 191u8, - 54u8, - 100u8, - 164u8, - 188u8, - 144u8, - 250u8, - 153u8, - 35u8, - 116u8, - 58u8, - 173u8, - 88u8, - 180u8, - 96u8, - 63u8, - 100u8, - 142u8, - 147u8, - 31u8, - 224u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - 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) - }, - 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) - }, - 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) - }, - }) - } - } - impl substreams_ethereum::Event for CommitNewFee { - const NAME: &'static str = "CommitNewFee"; - 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) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct NewFee { - pub fee: substreams::scalar::BigInt, - pub admin_fee: substreams::scalar::BigInt, - } - impl NewFee { - const TOPIC_ID: [u8; 32] = [ - 190u8, - 18u8, - 133u8, - 155u8, - 99u8, - 106u8, - 237u8, - 96u8, - 125u8, - 82u8, - 48u8, - 178u8, - 204u8, - 39u8, - 17u8, - 246u8, - 141u8, - 112u8, - 229u8, - 16u8, - 96u8, - 230u8, - 204u8, - 161u8, - 245u8, - 117u8, - 239u8, - 93u8, - 47u8, - 204u8, - 149u8, - 209u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - 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) - }, - }) - } - } - impl substreams_ethereum::Event for NewFee { - const NAME: &'static str = "NewFee"; - 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 RampA { - pub old_a: substreams::scalar::BigInt, - pub new_a: substreams::scalar::BigInt, - pub initial_time: substreams::scalar::BigInt, - pub future_time: substreams::scalar::BigInt, - } - impl RampA { - const TOPIC_ID: [u8; 32] = [ - 162u8, - 183u8, - 30u8, - 198u8, - 223u8, - 148u8, - 147u8, - 0u8, - 181u8, - 154u8, - 171u8, - 54u8, - 181u8, - 94u8, - 24u8, - 150u8, - 151u8, - 183u8, - 80u8, - 17u8, - 157u8, - 211u8, - 73u8, - 252u8, - 250u8, - 140u8, - 15u8, - 119u8, - 158u8, - 131u8, - 194u8, - 84u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { - return false; - } - if log.data.len() != 128usize { - return false; - } - return log.topics.get(0).expect("bounds already checked").as_ref() - == Self::TOPIC_ID; - } - pub fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - old_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) - }, - new_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) - }, - initial_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) - }, - future_time: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - } - impl substreams_ethereum::Event for RampA { - const NAME: &'static str = "RampA"; - 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 RemoveLiquidity { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fees: [substreams::scalar::BigInt; 2usize], - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidity { - const TOPIC_ID: [u8; 32] = [ - 124u8, - 54u8, - 56u8, - 84u8, - 204u8, - 247u8, - 150u8, - 35u8, - 65u8, - 31u8, - 137u8, - 149u8, - 179u8, - 98u8, - 188u8, - 229u8, - 237u8, - 223u8, - 241u8, - 140u8, - 146u8, - 126u8, - 220u8, - 111u8, - 93u8, - 187u8, - 181u8, - 224u8, - 88u8, - 25u8, - 168u8, - 44u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidity { - const NAME: &'static str = "RemoveLiquidity"; - 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 RemoveLiquidityImbalance { - pub provider: Vec, - pub token_amounts: [substreams::scalar::BigInt; 2usize], - pub fees: [substreams::scalar::BigInt; 2usize], - pub invariant: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityImbalance { - const TOPIC_ID: [u8; 32] = [ - 43u8, - 85u8, - 8u8, - 55u8, - 141u8, - 126u8, - 25u8, - 224u8, - 213u8, - 250u8, - 51u8, - 132u8, - 25u8, - 3u8, - 71u8, - 49u8, - 65u8, - 108u8, - 79u8, - 91u8, - 33u8, - 154u8, - 16u8, - 55u8, - 153u8, - 86u8, - 247u8, - 100u8, - 49u8, - 127u8, - 212u8, - 126u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - ethabi::ParamType::FixedArray( - Box::new(ethabi::ParamType::Uint(256usize)), - 2usize, - ), - 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 { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_amounts: { - 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), - ] - }, - fees: { - 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), - ] - }, - invariant: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityImbalance { - const NAME: &'static str = "RemoveLiquidityImbalance"; - 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 RemoveLiquidityOne { - pub provider: Vec, - pub token_amount: substreams::scalar::BigInt, - pub coin_amount: substreams::scalar::BigInt, - pub token_supply: substreams::scalar::BigInt, - } - impl RemoveLiquidityOne { - const TOPIC_ID: [u8; 32] = [ - 90u8, - 208u8, - 86u8, - 242u8, - 226u8, - 138u8, - 140u8, - 236u8, - 35u8, - 32u8, - 21u8, - 64u8, - 107u8, - 132u8, - 54u8, - 104u8, - 193u8, - 227u8, - 108u8, - 218u8, - 89u8, - 129u8, - 39u8, - 236u8, - 59u8, - 140u8, - 89u8, - 184u8, - 199u8, - 39u8, - 115u8, - 160u8, - ]; - pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - provider: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'provider' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - token_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) - }, - coin_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) - }, - token_supply: { - let mut v = [0 as u8; 32]; - values - .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 RemoveLiquidityOne { - const NAME: &'static str = "RemoveLiquidityOne"; - 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 StopRampA { - pub a: substreams::scalar::BigInt, - pub t: substreams::scalar::BigInt, - } - impl StopRampA { - const TOPIC_ID: [u8; 32] = [ - 70u8, - 226u8, - 47u8, - 179u8, - 112u8, - 154u8, - 210u8, - 137u8, - 246u8, - 44u8, - 230u8, - 61u8, - 70u8, - 146u8, - 72u8, - 83u8, - 109u8, - 188u8, - 120u8, - 216u8, - 43u8, - 132u8, - 163u8, - 215u8, - 231u8, - 74u8, - 214u8, - 6u8, - 220u8, - 32u8, - 25u8, - 56u8, - ]; - 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::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - 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) - }, - t: { - let mut v = [0 as u8; 32]; - values - .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 StopRampA { - const NAME: &'static str = "StopRampA"; - 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 TokenExchange { - pub buyer: Vec, - pub sold_id: substreams::scalar::BigInt, - pub tokens_sold: substreams::scalar::BigInt, - pub bought_id: substreams::scalar::BigInt, - pub tokens_bought: substreams::scalar::BigInt, - } - impl TokenExchange { - const TOPIC_ID: [u8; 32] = [ - 139u8, - 62u8, - 150u8, - 242u8, - 184u8, - 137u8, - 250u8, - 119u8, - 28u8, - 83u8, - 201u8, - 129u8, - 180u8, - 13u8, - 175u8, - 0u8, - 95u8, - 99u8, - 246u8, - 55u8, - 241u8, - 134u8, - 159u8, - 112u8, - 112u8, - 82u8, - 209u8, - 90u8, - 61u8, - 217u8, - 113u8, - 64u8, - ]; - 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - buyer: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'buyer' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sold_id: { - 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) - }, - tokens_sold: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - bought_id: { - 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) - }, - tokens_bought: { - let mut v = [0 as u8; 32]; - values - .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 TokenExchange { - const NAME: &'static str = "TokenExchange"; - 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 TokenExchangeUnderlying { - pub buyer: Vec, - pub sold_id: substreams::scalar::BigInt, - pub tokens_sold: substreams::scalar::BigInt, - pub bought_id: substreams::scalar::BigInt, - pub tokens_bought: substreams::scalar::BigInt, - } - impl TokenExchangeUnderlying { - const TOPIC_ID: [u8; 32] = [ - 208u8, - 19u8, - 202u8, - 35u8, - 231u8, - 122u8, - 101u8, - 0u8, - 60u8, - 44u8, - 101u8, - 156u8, - 84u8, - 66u8, - 192u8, - 12u8, - 128u8, - 83u8, - 113u8, - 183u8, - 252u8, - 30u8, - 189u8, - 76u8, - 32u8, - 108u8, - 65u8, - 209u8, - 83u8, - 107u8, - 217u8, - 11u8, - ]; - 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::Int(128usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Int(128usize), - ethabi::ParamType::Uint(256usize), - ], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); - Ok(Self { - buyer: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'buyer' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - sold_id: { - 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) - }, - tokens_sold: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - bought_id: { - 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) - }, - tokens_bought: { - let mut v = [0 as u8; 32]; - values - .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 TokenExchangeUnderlying { - const NAME: &'static str = "TokenExchangeUnderlying"; - fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - Self::match_log(log) - } - fn decode( - log: &substreams_ethereum::pb::eth::v2::Log, - ) -> Result { - Self::decode(log) - } - } - } \ No newline at end of file diff --git a/src/abi/mod.rs b/src/abi/mod.rs old mode 100755 new mode 100644 index 7bb8c81..df161cf --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -1,3 +1,3 @@ pub mod common; pub mod curve; -pub mod oracle; +pub mod oracle; \ No newline at end of file diff --git a/src/modules/5_map_extract_pool_events.rs b/src/modules/5_map_extract_pool_events.rs index 5e865e3..c4c4ee1 100644 --- a/src/modules/5_map_extract_pool_events.rs +++ b/src/modules/5_map_extract_pool_events.rs @@ -19,7 +19,7 @@ use crate::{ RemoveLiquidity3, RemoveLiquidity4, RemoveLiquidity5, RemoveLiquidity6, RemoveLiquidityImbalance1, RemoveLiquidityImbalance2, RemoveLiquidityImbalance3, RemoveLiquidityImbalance4, RemoveLiquidityOne1, RemoveLiquidityOne2, RemoveLiquidityOne3, - RemoveLiquidityOne4, TokenExchange1, TokenExchange2, TokenExchange3, + RemoveLiquidityOne4, RemoveLiquidityOne5, TokenExchange1, TokenExchange2, TokenExchange3, TokenExchangeUnderlying, }, common::{event_extraction, pool_utils::is_metapool, prices::get_token_usd_price}, @@ -362,7 +362,6 @@ pub fn map_extract_pool_events( &chainlink_prices, ); } else if let Some(withdraw) = RemoveLiquidityOne1::match_and_decode(&log) { - substreams::log::debug!("RemoveLiquidityOne1\n"); extract_withdraw_one_event( &mut pool_events, &blk, @@ -376,7 +375,44 @@ pub fn map_extract_pool_events( &chainlink_prices, ); } else if let Some(withdraw) = RemoveLiquidityOne2::match_and_decode(&log) { - substreams::log::debug!("RemoveLiquidityOne2\n"); + // TODO: This is a hacky work around for the issue caused by the similarity between `RemoveLiquidityOne2` and `RemoveLiquidityOne5`. + // If a `RemoveLiquidityOne5` event is emitted, it matches against `RemoveLiquidityOne2` due to them having the same event parameter types. + // I have messaged SF regarding this, and will be looking into it. If the issue is not fixed we will have to look at removing the reliance on + // a merged ABI for the Pools. This workaround should suffice for now. In essence, for `RemoveLiquidityOne5` events, the `token_supply` is being + // used as the `coin_amount` for the `RemoveLiquidityOne5` event. + + // If the `coin_amount` is less than 10, we can assume it is `RemoveLiquidityOne5` event, as this parameter slot is used for the `coin_index`. + // It is incredibly unlikely that a `coin_amount` less than 10 will part of a withdrawal as this would be an incredibly low token amount. + if &withdraw.coin_amount < &BigInt::from(10) { + extract_withdraw_one_event( + &mut pool_events, + &blk, + trx, + log, + &pool, + withdraw.provider, + withdraw.token_amount, + // Using `token_supply` as `coin_amount` for `RemoveLiquidityOne5` + withdraw.token_supply, + &uniswap_prices, + &chainlink_prices, + ); + } else { + // Extracting using the normal `RemoveLiquidityOne2` event params + extract_withdraw_one_event( + &mut pool_events, + &blk, + trx, + log, + &pool, + withdraw.provider, + withdraw.token_amount, + withdraw.coin_amount, + &uniswap_prices, + &chainlink_prices, + ); + } + } else if let Some(withdraw) = RemoveLiquidityOne3::match_and_decode(&log) { extract_withdraw_one_event( &mut pool_events, &blk, @@ -389,8 +425,7 @@ pub fn map_extract_pool_events( &uniswap_prices, &chainlink_prices, ); - } else if let Some(withdraw) = RemoveLiquidityOne3::match_and_decode(&log) { - substreams::log::debug!("RemoveLiquidityOne3\n"); + } else if let Some(withdraw) = RemoveLiquidityOne4::match_and_decode(&log) { extract_withdraw_one_event( &mut pool_events, &blk, @@ -403,8 +438,7 @@ pub fn map_extract_pool_events( &uniswap_prices, &chainlink_prices, ); - } else if let Some(withdraw) = RemoveLiquidityOne4::match_and_decode(&log) { - substreams::log::debug!("RemoveLiquidityOne4\n"); + } else if let Some(withdraw) = RemoveLiquidityOne5::match_and_decode(&log) { extract_withdraw_one_event( &mut pool_events, &blk, From 78effcba5d905a2461abbb423f35266b0c8e050b Mon Sep 17 00:00:00 2001 From: jmulq Date: Tue, 23 Apr 2024 19:05:52 +0200 Subject: [PATCH 3/5] fix: add tricrypto variant add liquidity event --- abi/curve/Pool.abi.json | 32 +++++ src/abi/curve/pool.rs | 150 +++++++++++++++++++++++ src/modules/5_map_extract_pool_events.rs | 16 ++- 3 files changed, 197 insertions(+), 1 deletion(-) diff --git a/abi/curve/Pool.abi.json b/abi/curve/Pool.abi.json index 3235fb1..ead3899 100644 --- a/abi/curve/Pool.abi.json +++ b/abi/curve/Pool.abi.json @@ -351,6 +351,38 @@ "anonymous": false, "type": "event" }, + { + "name": "AddLiquidity", + "inputs": [ + { + "name": "provider", + "type": "address", + "indexed": true + }, + { + "name": "token_amounts", + "type": "uint256[3]", + "indexed": false + }, + { + "name": "fee", + "type": "uint256", + "indexed": false + }, + { + "name": "token_supply", + "type": "uint256", + "indexed": false + }, + { + "name": "packed_price_scale", + "type": "uint256", + "indexed": false + } + ], + "anonymous": false, + "type": "event" + }, { "name": "RemoveLiquidity", "inputs": [ diff --git a/src/abi/curve/pool.rs b/src/abi/curve/pool.rs index ba261a5..467a18a 100644 --- a/src/abi/curve/pool.rs +++ b/src/abi/curve/pool.rs @@ -7919,6 +7919,156 @@ pub mod events { } } #[derive(Debug, Clone, PartialEq)] + pub struct AddLiquidity8 { + pub provider: Vec, + pub token_amounts: [substreams::scalar::BigInt; 3usize], + pub fee: substreams::scalar::BigInt, + pub token_supply: substreams::scalar::BigInt, + pub packed_price_scale: substreams::scalar::BigInt, + } + impl AddLiquidity8 { + const TOPIC_ID: [u8; 32] = [ + 225u8, + 182u8, + 4u8, + 85u8, + 189u8, + 158u8, + 51u8, + 114u8, + 11u8, + 84u8, + 127u8, + 96u8, + 228u8, + 224u8, + 207u8, + 191u8, + 18u8, + 82u8, + 208u8, + 242u8, + 238u8, + 1u8, + 71u8, + 213u8, + 48u8, + 41u8, + 148u8, + 95u8, + 57u8, + 254u8, + 60u8, + 26u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + 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::FixedArray( + Box::new(ethabi::ParamType::Uint(256usize)), + 3usize, + ), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + provider: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'provider' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_amounts: { + 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), + ] + }, + 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) + }, + token_supply: { + let mut v = [0 as u8; 32]; + values + .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_price_scale: { + let mut v = [0 as u8; 32]; + values + .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 AddLiquidity8 { + const NAME: &'static str = "AddLiquidity8"; + 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 ApplyNewFee1 { pub fee: substreams::scalar::BigInt, } diff --git a/src/modules/5_map_extract_pool_events.rs b/src/modules/5_map_extract_pool_events.rs index c4c4ee1..f9d02e9 100644 --- a/src/modules/5_map_extract_pool_events.rs +++ b/src/modules/5_map_extract_pool_events.rs @@ -14,7 +14,7 @@ use substreams_ethereum::{ use crate::{ abi::curve::pool::events::{ AddLiquidity1, AddLiquidity2, AddLiquidity3, AddLiquidity4, AddLiquidity5, AddLiquidity6, - AddLiquidity7, ApplyNewFee1, ApplyNewFee2, NewFee1, NewFee2, NewParameters1, + AddLiquidity7, AddLiquidity8, ApplyNewFee1, ApplyNewFee2, NewFee1, NewFee2, NewParameters1, NewParameters2, NewParameters3, NewParameters4, RemoveLiquidity1, RemoveLiquidity2, RemoveLiquidity3, RemoveLiquidity4, RemoveLiquidity5, RemoveLiquidity6, RemoveLiquidityImbalance1, RemoveLiquidityImbalance2, RemoveLiquidityImbalance3, @@ -223,6 +223,20 @@ pub fn map_extract_pool_events( &uniswap_prices, &chainlink_prices, ); + } else if let Some(deposit) = AddLiquidity8::match_and_decode(&log) { + let fees = vec![deposit.fee.into()]; + extract_deposit_event( + &mut pool_events, + &blk, + trx, + log, + &pool, + deposit.token_amounts.to_vec(), + fees, + deposit.provider, + &uniswap_prices, + &chainlink_prices, + ); } else if let Some(withdraw) = RemoveLiquidity1::match_and_decode(&log) { extract_withdraw_event( &mut pool_events, From 6850032418850d0f588048292c467dc2860088d7 Mon Sep 17 00:00:00 2001 From: jmulq Date: Wed, 24 Apr 2024 17:36:11 +0200 Subject: [PATCH 4/5] fix: token price fields --- proto/curve/v1/curve.proto | 12 ++ src/common/prices.rs | 42 +++++-- src/modules/10_store_pool_volume_usd.rs | 6 +- src/modules/12_store_pool_tvl.rs | 2 +- src/modules/23_store_pool_rewards.rs | 4 +- src/modules/420_graph_out.rs | 57 ++++++---- src/modules/5_map_extract_pool_events.rs | 107 ++++++++++++------ src/pb/curve.types.v1.rs | 45 ++++++++ .../snapshot/snapshot_creator.rs | 2 +- 9 files changed, 201 insertions(+), 76 deletions(-) diff --git a/proto/curve/v1/curve.proto b/proto/curve/v1/curve.proto index f26a34c..cf69606 100755 --- a/proto/curve/v1/curve.proto +++ b/proto/curve/v1/curve.proto @@ -272,6 +272,8 @@ message Events { string amount = 2; // BigInt in token's native amount string amount_usd = 3; TokenSource source = 4; + string token_price = 5; + PriceSource price_source = 6; } enum TokenSource { @@ -285,6 +287,16 @@ message Events { LENDING_PROTCOL = 4; } + enum PriceSource { + CHAINLINK = 0; + UNISWAP_V2 = 1; + YEARN = 2; + SUSHI = 3; + CURVE_CALC = 4; + STABLECOIN = 5; + UNKNOWN = 6; + } + message LpTokenChange { string token_address = 1; string amount = 2; diff --git a/src/common/prices.rs b/src/common/prices.rs index 2da555a..b003384 100644 --- a/src/common/prices.rs +++ b/src/common/prices.rs @@ -10,7 +10,10 @@ use crate::{ constants::{one_usd_value, BLACKLISTED_TOKENS}, key_management::store_key_manager::StoreKey, network_config::HARDCODED_STABLES, - pb::{curve::types::v1::Token, uniswap_pricing::v1::Erc20Price}, + pb::{ + curve::types::v1::{events::pool_event::PriceSource, Token}, + uniswap_pricing::v1::Erc20Price, + }, rpc::oracle::{ get_usd_price_from_curve_calc, get_usd_price_from_sushi, get_usd_price_from_yearn, }, @@ -20,27 +23,40 @@ pub fn get_token_usd_price( token: &Token, uniswap_prices: &StoreGetProto, chainlink_prices: &StoreGetBigDecimal, -) -> BigDecimal { +) -> (BigDecimal, PriceSource) { if BLACKLISTED_TOKENS.contains(&token.address.as_str()) { - return BigDecimal::zero(); + return (BigDecimal::zero(), PriceSource::Unknown); } if HARDCODED_STABLES .iter() .any(|&addr| Hex::encode(addr) == token.address) { - return one_usd_value(); + return (one_usd_value(), PriceSource::Stablecoin); } - get_usd_price_from_chainlink(token, chainlink_prices) - .or_else(|| get_usd_price_from_uniswap(token, uniswap_prices)) - .or_else(|| get_usd_price_from_yearn(token.address_vec())) - .or_else(|| get_usd_price_from_sushi(token.address_vec())) - .or_else(|| get_usd_price_from_curve_calc(token.address_vec())) + let price = get_usd_price_from_chainlink(token, chainlink_prices) + .map(|price| (price, PriceSource::Chainlink)) + .or_else(|| { + get_usd_price_from_uniswap(token, uniswap_prices) + .map(|price| (price, PriceSource::UniswapV2)) + }) + .or_else(|| { + get_usd_price_from_yearn(token.address_vec()).map(|price| (price, PriceSource::Yearn)) + }) + .or_else(|| { + get_usd_price_from_sushi(token.address_vec()).map(|price| (price, PriceSource::Sushi)) + }) + .or_else(|| { + get_usd_price_from_curve_calc(token.address_vec()) + .map(|price| (price, PriceSource::CurveCalc)) + }) .unwrap_or_else(|| { substreams::log::debug!("Failed to get price for token: {}", token.address); - BigDecimal::zero() - }) + (BigDecimal::zero(), PriceSource::Unknown) + }); + + price } fn get_usd_price_from_chainlink( @@ -59,5 +75,7 @@ fn get_usd_price_from_uniswap( .or_else(|| { uniswap_prices.get_last(StoreKey::uniswap_price_by_token_symbol_key(&token.symbol)) }) - .and_then(|price| BigDecimal::from_str(&price.price_usd).ok()) + .and_then(|price| { + BigDecimal::from_str(&price.price_usd).ok() + }) } diff --git a/src/modules/10_store_pool_volume_usd.rs b/src/modules/10_store_pool_volume_usd.rs index 214583b..d3ca6e3 100644 --- a/src/modules/10_store_pool_volume_usd.rs +++ b/src/modules/10_store_pool_volume_usd.rs @@ -80,9 +80,9 @@ pub fn store_pool_volume_usd( let token_in = token_in.unwrap(); let token_out = token_out.unwrap(); - let token_in_price = + let (token_in_price, _) = get_token_usd_price(&token_in, &uniswap_prices, &chainlink_prices); - let token_out_price = + let (token_out_price, _) = get_token_usd_price(&token_out, &uniswap_prices, &chainlink_prices); let token_in_amount_usd = @@ -151,7 +151,7 @@ pub fn store_pool_volume_usd( }; if let Some(meta_token) = meta_token_opt { - let meta_token_price = get_token_usd_price( + let (meta_token_price, _) = get_token_usd_price( &meta_token, &uniswap_prices, &chainlink_prices, diff --git a/src/modules/12_store_pool_tvl.rs b/src/modules/12_store_pool_tvl.rs index 15ce056..4b234fa 100644 --- a/src/modules/12_store_pool_tvl.rs +++ b/src/modules/12_store_pool_tvl.rs @@ -51,7 +51,7 @@ pub fn store_pool_tvl( // TODO: We may be able to optimise here by getting the token price upstream when the balances change. // Check if we get the price in any other modules that use the balances store, and if so, we can // minimise the amount of store calls by getting it once and setting it alongside the balance changes. - let price_usd = get_token_usd_price(&token, &uniswap_prices, &chainlink_prices); + let (price_usd, _) = get_token_usd_price(&token, &uniswap_prices, &chainlink_prices); let token_tvl = balance.to_decimal(token.decimals) * price_usd; // Store Input Token TVL for a specific Pool diff --git a/src/modules/23_store_pool_rewards.rs b/src/modules/23_store_pool_rewards.rs index 440e9c3..40a7b65 100644 --- a/src/modules/23_store_pool_rewards.rs +++ b/src/modules/23_store_pool_rewards.rs @@ -58,7 +58,7 @@ pub fn store_pool_rewards( .to_bigint(); reward_token_emissions_native.push(crv_emissions_native.to_string()); - let price_usd = prices::get_token_usd_price( + let (price_usd, _) = prices::get_token_usd_price( &curve_token(), &uniswap_prices, &chainlink_prices, @@ -90,7 +90,7 @@ pub fn store_pool_rewards( reward_token_emissions_native .push(token_emissions_native.to_string()); - let price_usd = prices::get_token_usd_price( + let (price_usd, _) = prices::get_token_usd_price( &reward_token, &uniswap_prices, &chainlink_prices, diff --git a/src/modules/420_graph_out.rs b/src/modules/420_graph_out.rs index ff2c77e..f92ea00 100644 --- a/src/modules/420_graph_out.rs +++ b/src/modules/420_graph_out.rs @@ -103,7 +103,7 @@ pub fn graph_out( if let Some(reward_token) = reward_tokens_store.get_last( StoreKey::liquidity_gauge_reward_token_key(&event.gauge, &(index + 1)), ) { - let price_usd = prices::get_token_usd_price( + let (price_usd, _) = prices::get_token_usd_price( &reward_token, &uniswap_prices, &chainlink_prices, @@ -267,6 +267,7 @@ pub fn graph_out( // Create entities related to Pool events create_pool_events_entities( + &clock, &mut tables, pool_events.pool_events, &pools_store, @@ -447,6 +448,7 @@ fn create_pool_token_entities( } fn create_pool_events_entities( + clock: &Clock, tables: &mut Tables, pool_events: Vec, pools_store: &StoreGetProto, @@ -504,6 +506,12 @@ fn create_pool_events_entities( input_token_balances_store, pool_tvl_store, ); + if let Some(token_in) = &swap.token_in { + update_token_price(tables, clock, token_in); + } + if let Some(token_out) = &swap.token_out { + update_token_price(tables, clock, token_out); + } } } Type::SwapUnderlyingMetaEvent(swap_underlying) => { @@ -523,6 +531,12 @@ fn create_pool_events_entities( input_token_balances_store, pool_tvl_store, ); + if let Some(token_in) = &swap_underlying.token_in { + update_token_price(tables, clock, token_in); + } + if let Some(token_out) = &swap_underlying.token_out { + update_token_price(tables, clock, token_out); + } } } Type::SwapUnderlyingLendingEvent(swap_underlying) => { @@ -542,6 +556,12 @@ fn create_pool_events_entities( input_token_balances_store, pool_tvl_store, ); + if let Some(token_in) = &swap_underlying.token_in { + update_token_price(tables, clock, token_in); + } + if let Some(token_out) = &swap_underlying.token_out { + update_token_price(tables, clock, token_out); + } } } } @@ -578,6 +598,15 @@ fn update_pool_output_token_supply( .set("outputTokenSupply", output_token_supply); } +fn update_token_price(tables: &mut Tables, clock: &Clock, token_amount: &TokenAmount) { + let price = BigDecimal::from_str(&token_amount.token_price).unwrap_or(BigDecimal::zero()); + tables + .update_row("Token", EntityKey::token_key(&token_amount.token_address)) + .set("lastPriceUSD", price) + .set("lastPriceBlockNumber", BigInt::from(clock.number)) + .set("oracleType", token_amount.price_source().as_str_name()); +} + fn update_input_token_balances( tables: &mut Tables, event: &PoolEvent, @@ -610,7 +639,7 @@ fn update_output_token_price( uniswap_prices: &StoreGetProto, chainlink_prices: &StoreGetBigDecimal, ) { - let output_token_price = + let (output_token_price, _) = get_token_usd_price(pool.output_token_ref(), uniswap_prices, chainlink_prices); tables .update_row( @@ -741,33 +770,13 @@ fn create_swap_entity(tables: &mut Tables, event: &PoolEvent, swap: &SwapEvent) "tokenIn", format::format_address_string(&swap.token_in.as_ref().unwrap().token_address), ) - .set( - "amountIn", - BigInt::from( - swap.token_in - .as_ref() - .unwrap() - .amount - .parse::() - .unwrap_or_default(), - ), - ) + .set("amountIn", swap.token_in_ref().amount_big()) .set("amountInUSD", swap.token_in_ref().amount_usd_decimal()) .set( "tokenOut", format::format_address_string(&swap.token_out.as_ref().unwrap().token_address), ) - .set( - "amountOut", - BigInt::from( - swap.token_out - .as_ref() - .unwrap() - .amount - .parse::() - .unwrap_or_default(), - ), - ) + .set("amountOut", swap.token_out_ref().amount_big()) .set("amountOutUSD", swap.token_out_ref().amount_usd_decimal()) .set("pool", format::format_address_string(&event.pool_address)); } diff --git a/src/modules/5_map_extract_pool_events.rs b/src/modules/5_map_extract_pool_events.rs index f9d02e9..8799aa2 100644 --- a/src/modules/5_map_extract_pool_events.rs +++ b/src/modules/5_map_extract_pool_events.rs @@ -29,7 +29,7 @@ use crate::{ curve::types::v1::{ events::{ pool_event::{ - DepositEvent, LpTokenChange, LpTokenChangeType, SwapEvent, + DepositEvent, LpTokenChange, LpTokenChangeType, PriceSource, SwapEvent, SwapUnderlyingLendingEvent, SwapUnderlyingMetaEvent, TokenAmount, TokenSource, Type, WithdrawEvent, }, @@ -613,21 +613,29 @@ fn extract_swap_event( .find(|t| t.address == out_address) .unwrap(); - let token_in_price = get_token_usd_price(token_in, &uniswap_prices, &chainlink_prices); - let token_out_price = get_token_usd_price(token_out, &uniswap_prices, &chainlink_prices); + let (token_in_price, token_in_price_source) = + get_token_usd_price(token_in, &uniswap_prices, &chainlink_prices); + let (token_out_price, token_out_price_source) = + get_token_usd_price(token_out, &uniswap_prices, &chainlink_prices); let token_amount_in = TokenAmount { token_address: pool.input_tokens_ordered[in_address_index].clone(), amount: tokens_sold.into(), - amount_usd: (tokens_sold.to_decimal(token_in.decimals) * token_in_price).to_string(), + amount_usd: (tokens_sold.to_decimal(token_in.decimals) * token_in_price.clone()) + .to_string(), source: TokenSource::Default as i32, + token_price: token_in_price.to_string(), + price_source: token_in_price_source as i32, }; let token_amount_out = TokenAmount { token_address: pool.input_tokens_ordered[out_address_index].clone(), amount: tokens_bought.into(), - amount_usd: (tokens_bought.to_decimal(token_out.decimals) * token_out_price).to_string(), + amount_usd: (tokens_bought.to_decimal(token_out.decimals) * token_out_price.clone()) + .to_string(), source: TokenSource::Default as i32, + token_price: token_out_price.to_string(), + price_source: token_out_price_source as i32, }; let swap_event = SwapEvent { @@ -776,9 +784,9 @@ fn extract_swap_underlying_event( ); if let (Some(token_in), Some(token_out)) = (token_in, token_out) { - let token_in_price = + let (token_in_price, token_in_price_source) = get_token_usd_price(token_in, &uniswap_prices, &chainlink_prices); - let token_out_price = + let (token_out_price, token_out_price_source) = get_token_usd_price(token_out, &uniswap_prices, &chainlink_prices); let skip_mint_for_token_in = should_skip_token_action(lending_pool_type, sold_id); @@ -788,25 +796,31 @@ fn extract_swap_underlying_event( let token_amount_in = TokenAmount { token_address: token_in.address.clone(), amount: tokens_sold.into(), - amount_usd: (tokens_sold.to_decimal(token_in.decimals) * token_in_price) - .to_string(), + amount_usd: (tokens_sold.to_decimal(token_in.decimals) + * token_in_price.clone()) + .to_string(), source: if skip_mint_for_token_in { TokenSource::LendingPool as i32 } else { TokenSource::LendingProtcol as i32 }, + token_price: token_in_price.to_string(), + price_source: token_in_price_source as i32, }; let token_amount_out = TokenAmount { token_address: token_out.address.clone(), amount: tokens_bought.into(), - amount_usd: (tokens_bought.to_decimal(token_out.decimals) * token_out_price) - .to_string(), + amount_usd: (tokens_bought.to_decimal(token_out.decimals) + * token_out_price.clone()) + .to_string(), source: if skip_burn_for_token_out { TokenSource::LendingPool as i32 } else { TokenSource::LendingProtcol as i32 }, + token_price: token_out_price.to_string(), + price_source: token_out_price_source as i32, }; let interest_token_in_address = @@ -923,21 +937,29 @@ fn determine_underlying_exchange_tokens( let (token_in, token_in_source) = get_token_info(sold_id, &pool)?; let (token_out, token_out_source) = get_token_info(bought_id, &pool)?; - let token_in_price = get_token_usd_price(&token_in, &uniswap_prices, &chainlink_prices); - let token_out_price = get_token_usd_price(&token_out, &uniswap_prices, &chainlink_prices); + let (token_in_price, token_in_price_source) = + get_token_usd_price(&token_in, &uniswap_prices, &chainlink_prices); + let (token_out_price, token_out_price_source) = + get_token_usd_price(&token_out, &uniswap_prices, &chainlink_prices); let token_in = TokenAmount { token_address: token_in.address, amount: tokens_sold.to_string(), - amount_usd: (tokens_sold.to_decimal(token_in.decimals) * token_in_price).to_string(), + amount_usd: (tokens_sold.to_decimal(token_in.decimals) * token_in_price.clone()) + .to_string(), source: token_in_source as i32, + token_price: token_in_price.to_string(), + price_source: token_in_price_source as i32, }; let token_out = TokenAmount { token_address: token_out.address, amount: tokens_bought.to_string(), - amount_usd: (tokens_bought.to_decimal(token_out.decimals) * token_out_price).to_string(), + amount_usd: (tokens_bought.to_decimal(token_out.decimals) * token_out_price.clone()) + .to_string(), source: token_out_source as i32, + token_price: token_out_price.to_string(), + price_source: token_out_price_source as i32, }; Ok((token_in, token_out)) @@ -1083,13 +1105,16 @@ fn extract_deposit_event( .ok() .and_then(|index| token_amounts.get(index)) .map(|amount| { - let token_price = + let (token_price, price_source) = get_token_usd_price(token, &uniswap_prices, &chainlink_prices); TokenAmount { token_address: token.address.clone(), amount: amount.into(), - amount_usd: (amount.to_decimal(token.decimals) * token_price).to_string(), + amount_usd: (amount.to_decimal(token.decimals) * token_price.clone()) + .to_string(), source: TokenSource::Default as i32, + token_price: token_price.to_string(), + price_source: price_source as i32, } }) }) @@ -1121,7 +1146,7 @@ fn extract_deposit_event( substreams::log::debug!("Error in `map_extract_pool_events`: {:?}", e); BigInt::zero() }); - let output_token_price = + let (output_token_price, output_token_price_source) = get_token_usd_price(pool.output_token_ref(), &uniswap_prices, &chainlink_prices); let deposit_event = DepositEvent { @@ -1130,9 +1155,11 @@ fn extract_deposit_event( token_address: pool.output_token_ref().address.clone(), amount: output_token_amount.clone().into(), amount_usd: (output_token_amount.to_decimal(pool.output_token_ref().decimals) - * output_token_price) - .to_string(), + * output_token_price.clone()) + .to_string(), source: TokenSource::Default as i32, + token_price: output_token_price.to_string(), + price_source: output_token_price_source as i32, }), fees, }; @@ -1186,13 +1213,16 @@ fn extract_withdraw_event( .ok() .and_then(|index| token_amounts.get(index)) .map(|amount| { - let token_price = + let (token_price, price_source) = get_token_usd_price(token, &uniswap_prices, &chainlink_prices); TokenAmount { token_address: token.address.clone(), amount: amount.into(), - amount_usd: (amount.to_decimal(token.decimals) * token_price).to_string(), + amount_usd: (amount.to_decimal(token.decimals) * token_price.clone()) + .to_string(), source: TokenSource::Default as i32, + token_price: token_price.to_string(), + price_source: price_source as i32, } }) }) @@ -1212,7 +1242,7 @@ fn extract_withdraw_event( BigInt::zero() } }; - let output_token_price = + let (output_token_price, output_token_price_source) = get_token_usd_price(pool.output_token_ref(), &uniswap_prices, &chainlink_prices); let withdraw_event = WithdrawEvent { @@ -1221,9 +1251,11 @@ fn extract_withdraw_event( token_address: pool.output_token_ref().address.clone(), amount: output_token_amount.clone().into(), amount_usd: (output_token_amount.to_decimal(pool.output_token_ref().decimals) - * output_token_price) - .to_string(), + * output_token_price.clone()) + .to_string(), source: TokenSource::Default as i32, + token_price: output_token_price.to_string(), + price_source: output_token_price_source as i32, }), fees, }; @@ -1304,28 +1336,33 @@ fn extract_withdraw_one_event( .map(|address| { if is_eth_transfer && address == &Hex::encode(Ð_ADDRESS) { if let Some(token) = pool.input_tokens.iter().find(|t| &t.address == address) { - let token_price = + let (token_price, price_source) = get_token_usd_price(token, &uniswap_prices, &chainlink_prices); return TokenAmount { token_address: address.clone(), amount: coin_amount.clone().into(), - amount_usd: (coin_amount.to_decimal(token.decimals) * token_price) + amount_usd: (coin_amount.to_decimal(token.decimals) * token_price.clone()) .to_string(), source: TokenSource::Default as i32, + token_price: token_price.to_string(), + price_source: price_source as i32, }; } } else if let Ok(transfer) = &token_transfer { if &Hex::encode(&transfer.token_address) == address { if let Some(token) = pool.input_tokens.iter().find(|t| &t.address == address) { - let token_price = + let (token_price, price_source) = get_token_usd_price(token, &uniswap_prices, &chainlink_prices); return TokenAmount { token_address: address.clone(), amount: coin_amount.clone().into(), - amount_usd: (coin_amount.to_decimal(token.decimals) * token_price) - .to_string(), + amount_usd: (coin_amount.to_decimal(token.decimals) + * token_price.clone()) + .to_string(), source: TokenSource::Default as i32, + token_price: token_price.to_string(), + price_source: price_source as i32, }; } } @@ -1335,11 +1372,13 @@ fn extract_withdraw_one_event( amount: BigInt::zero().into(), amount_usd: "0".to_string(), source: TokenSource::Default as i32, + token_price: "0".to_string(), + price_source: PriceSource::Unknown as i32, } }) .collect(); - let output_token_price = + let (output_token_price, output_token_price_source) = get_token_usd_price(pool.output_token_ref(), &uniswap_prices, &chainlink_prices); let withdraw_event = WithdrawEvent { @@ -1348,9 +1387,11 @@ fn extract_withdraw_one_event( token_address: pool.output_token_ref().address.clone(), amount: token_amount.clone().into(), amount_usd: (token_amount.to_decimal(pool.output_token_ref().decimals) - * output_token_price) - .to_string(), + * output_token_price.clone()) + .to_string(), source: TokenSource::Default as i32, + token_price: output_token_price.to_string(), + price_source: output_token_price_source as i32, }), fees: Vec::new(), }; diff --git a/src/pb/curve.types.v1.rs b/src/pb/curve.types.v1.rs index 61529b4..a2919dd 100644 --- a/src/pb/curve.types.v1.rs +++ b/src/pb/curve.types.v1.rs @@ -430,6 +430,10 @@ pub mod events { pub amount_usd: ::prost::alloc::string::String, #[prost(enumeration="TokenSource", tag="4")] pub source: i32, + #[prost(string, tag="5")] + pub token_price: ::prost::alloc::string::String, + #[prost(enumeration="PriceSource", tag="6")] + pub price_source: i32, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -482,6 +486,47 @@ pub mod events { } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] + pub enum PriceSource { + Chainlink = 0, + UniswapV2 = 1, + Yearn = 2, + Sushi = 3, + CurveCalc = 4, + Stablecoin = 5, + Unknown = 6, + } + impl PriceSource { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + PriceSource::Chainlink => "CHAINLINK", + PriceSource::UniswapV2 => "UNISWAP_V2", + PriceSource::Yearn => "YEARN", + PriceSource::Sushi => "SUSHI", + PriceSource::CurveCalc => "CURVE_CALC", + PriceSource::Stablecoin => "STABLECOIN", + PriceSource::Unknown => "UNKNOWN", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "CHAINLINK" => Some(Self::Chainlink), + "UNISWAP_V2" => Some(Self::UniswapV2), + "YEARN" => Some(Self::Yearn), + "SUSHI" => Some(Self::Sushi), + "CURVE_CALC" => Some(Self::CurveCalc), + "STABLECOIN" => Some(Self::Stablecoin), + "UNKNOWN" => Some(Self::Unknown), + _ => None, + } + } + } + #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] + #[repr(i32)] pub enum LpTokenChangeType { Mint = 0, Burn = 1, diff --git a/src/timeframe_management/snapshot/snapshot_creator.rs b/src/timeframe_management/snapshot/snapshot_creator.rs index 20137c6..df681d7 100644 --- a/src/timeframe_management/snapshot/snapshot_creator.rs +++ b/src/timeframe_management/snapshot/snapshot_creator.rs @@ -346,7 +346,7 @@ impl<'a> SnapshotCreator<'a> { .get_last(StoreKey::output_token_supply_key(&pool_address)) .unwrap_or_else(|| BigInt::zero()); - let output_token_price = get_token_usd_price( + let (output_token_price, _) = get_token_usd_price( pool.output_token_ref(), &self.uniswap_prices, &self.chainlink_prices, From 073beaf92940a051491e28f9f8c81c7e57c8d1b3 Mon Sep 17 00:00:00 2001 From: jmulq Date: Wed, 24 Apr 2024 17:36:58 +0200 Subject: [PATCH 5/5] build: bump version v0.1.20-alpha --- subgraph.yaml | 2 +- substreams.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/subgraph.yaml b/subgraph.yaml index 178ec63..c63bde1 100755 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -11,7 +11,7 @@ dataSources: source: package: moduleName: graph_out - file: curve-sps-v0.1.19-alpha.spkg + file: curve-sps-v0.1.20-alpha.spkg mapping: kind: substreams/graph-entities apiVersion: 0.0.5 diff --git a/substreams.yaml b/substreams.yaml index 780e13a..507a8be 100755 --- a/substreams.yaml +++ b/substreams.yaml @@ -1,7 +1,7 @@ specVersion: v0.1.0 package: name: curve_sps - version: v0.1.19-alpha + version: v0.1.20-alpha imports: graph: https://github.com/streamingfast/substreams-sink-subgraph/releases/download/v0.1.0/substreams-sink-subgraph-protodefs-v0.1.0.spkg