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 Allowance { pub owner: Vec, pub spender: Vec, } impl Allowance { const METHOD_ID: [u8; 4] = [221u8, 98u8, 237u8, 62u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::Address, ethabi::ParamType::Address], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { owner: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), spender: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), ethabi::Token::Address(ethabi::Address::from_slice(&self.spender)), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Allowance { const NAME: &'static str = "allowance"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for Allowance { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Approve { pub spender: Vec, pub amount: substreams::scalar::BigInt, } impl Approve { const METHOD_ID: [u8; 4] = [9u8, 94u8, 167u8, 179u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { spender: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), amount: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Address(ethabi::Address::from_slice(&self.spender)), ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.amount.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok( values .pop() .expect("one output data should have existed") .into_bool() .expect(INTERNAL_ERR), ) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Approve { const NAME: &'static str = "approve"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for Approve { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct BalanceOf { pub account: Vec, } impl BalanceOf { const METHOD_ID: [u8; 4] = [112u8, 160u8, 130u8, 49u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::Address], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { account: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ethabi::Token::Address(ethabi::Address::from_slice(&self.account))], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for BalanceOf { const NAME: &'static str = "balanceOf"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for BalanceOf { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct ComputeBalance { pub balances_live_scaled18: Vec, pub token_in_index: substreams::scalar::BigInt, pub invariant_ratio: substreams::scalar::BigInt, } impl ComputeBalance { const METHOD_ID: [u8; 4] = [22u8, 160u8, 179u8, 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::Array( Box::new(ethabi::ParamType::Uint(256usize)), ), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { balances_live_scaled18: 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(), token_in_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) }, invariant_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( &[ { let v = self .balances_live_scaled18 .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.token_in_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::Uint( ethabi::Uint::from_big_endian( match self.invariant_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 output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for ComputeBalance { const NAME: &'static str = "computeBalance"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for ComputeBalance { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct ComputeInvariant { pub balances_live_scaled18: Vec, pub rounding: substreams::scalar::BigInt, } impl ComputeInvariant { const METHOD_ID: [u8; 4] = [152u8, 77u8, 233u8, 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::ParamType::Array( Box::new(ethabi::ParamType::Uint(256usize)), ), ethabi::ParamType::Uint(8usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { balances_live_scaled18: 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(), rounding: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .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 .balances_live_scaled18 .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.rounding.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for ComputeInvariant { const NAME: &'static str = "computeInvariant"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for ComputeInvariant { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Decimals {} impl Decimals { const METHOD_ID: [u8; 4] = [49u8, 60u8, 229u8, 103u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(8usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Decimals { const NAME: &'static str = "decimals"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for Decimals { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct DomainSeparator {} impl DomainSeparator { const METHOD_ID: [u8; 4] = [54u8, 68u8, 229u8, 21u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result<[u8; 32usize], String> { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { let mut values = ethabi::decode( &[ethabi::ParamType::FixedBytes(32usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut result = [0u8; 32]; let v = values .pop() .expect("one output data should have existed") .into_fixed_bytes() .expect(INTERNAL_ERR); result.copy_from_slice(&v); result }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for DomainSeparator { const NAME: &'static str = "DOMAIN_SEPARATOR"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for DomainSeparator { fn output(data: &[u8]) -> Result<[u8; 32usize], String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Eip712Domain {} impl Eip712Domain { const METHOD_ID: [u8; 4] = [132u8, 176u8, 25u8, 110u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(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; 1usize], String, String, substreams::scalar::BigInt, Vec, [u8; 32usize], Vec, ), String, > { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result< ( [u8; 1usize], String, String, substreams::scalar::BigInt, Vec, [u8; 32usize], Vec, ), String, > { let mut values = ethabi::decode( &[ ethabi::ParamType::FixedBytes(1usize), ethabi::ParamType::String, ethabi::ParamType::String, ethabi::ParamType::Uint(256usize), ethabi::ParamType::Address, ethabi::ParamType::FixedBytes(32usize), ethabi::ParamType::Array( Box::new(ethabi::ParamType::Uint(256usize)), ), ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); Ok(( { let mut result = [0u8; 1]; let v = values .pop() .expect(INTERNAL_ERR) .into_fixed_bytes() .expect(INTERNAL_ERR); result.copy_from_slice(&v); result }, values.pop().expect(INTERNAL_ERR).into_string().expect(INTERNAL_ERR), values.pop().expect(INTERNAL_ERR).into_string().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) }, values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), { let mut result = [0u8; 32]; let v = values .pop() .expect(INTERNAL_ERR) .into_fixed_bytes() .expect(INTERNAL_ERR); result.copy_from_slice(&v); result }, 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< ( [u8; 1usize], String, String, substreams::scalar::BigInt, Vec, [u8; 32usize], 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 Eip712Domain { const NAME: &'static str = "eip712Domain"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } 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; 1usize], String, String, substreams::scalar::BigInt, Vec, [u8; 32usize], Vec, ), > for Eip712Domain { fn output( data: &[u8], ) -> Result< ( [u8; 1usize], String, String, substreams::scalar::BigInt, Vec, [u8; 32usize], Vec, ), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct EmitApproval { pub owner: Vec, pub spender: Vec, pub amount: substreams::scalar::BigInt, } impl EmitApproval { const METHOD_ID: [u8; 4] = [86u8, 135u8, 242u8, 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, ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize), ], 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(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_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.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(), ), ), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } } impl substreams_ethereum::Function for EmitApproval { const NAME: &'static str = "emitApproval"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } #[derive(Debug, Clone, PartialEq)] pub struct EmitTransfer { pub from: Vec, pub to: Vec, pub amount: substreams::scalar::BigInt, } impl EmitTransfer { const METHOD_ID: [u8; 4] = [35u8, 222u8, 102u8, 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::Address, ethabi::ParamType::Uint(256usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { from: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), to: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), 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.from)), ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } } impl substreams_ethereum::Function for EmitTransfer { const NAME: &'static str = "emitTransfer"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } #[derive(Debug, Clone, PartialEq)] pub struct GetAggregateFeePercentages {} impl GetAggregateFeePercentages { const METHOD_ID: [u8; 4] = [129u8, 250u8, 128u8, 124u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); 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 GetAggregateFeePercentages { const NAME: &'static str = "getAggregateFeePercentages"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } 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 GetAggregateFeePercentages { fn output( data: &[u8], ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetCurrentLiveBalances {} impl GetCurrentLiveBalances { const METHOD_ID: [u8; 4] = [177u8, 86u8, 170u8, 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::Array( Box::new(ethabi::ParamType::Uint(256usize)), ), ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok( values .pop() .expect("one output data should have existed") .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) .collect(), ) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetCurrentLiveBalances { const NAME: &'static str = "getCurrentLiveBalances"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable> for GetCurrentLiveBalances { fn output(data: &[u8]) -> Result, String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetMaximumInvariantRatio {} impl GetMaximumInvariantRatio { const METHOD_ID: [u8; 4] = [39u8, 60u8, 26u8, 223u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetMaximumInvariantRatio { const NAME: &'static str = "getMaximumInvariantRatio"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for GetMaximumInvariantRatio { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetMaximumSwapFeePercentage {} impl GetMaximumSwapFeePercentage { const METHOD_ID: [u8; 4] = [101u8, 76u8, 241u8, 93u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetMaximumSwapFeePercentage { const NAME: &'static str = "getMaximumSwapFeePercentage"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for GetMaximumSwapFeePercentage { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetMinimumInvariantRatio {} impl GetMinimumInvariantRatio { const METHOD_ID: [u8; 4] = [182u8, 119u8, 250u8, 86u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetMinimumInvariantRatio { const NAME: &'static str = "getMinimumInvariantRatio"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for GetMinimumInvariantRatio { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetMinimumSwapFeePercentage {} impl GetMinimumSwapFeePercentage { const METHOD_ID: [u8; 4] = [206u8, 32u8, 236u8, 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 { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetMinimumSwapFeePercentage { const NAME: &'static str = "getMinimumSwapFeePercentage"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for GetMinimumSwapFeePercentage { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetNormalizedWeights {} impl GetNormalizedWeights { const METHOD_ID: [u8; 4] = [248u8, 159u8, 39u8, 237u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result, String> { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result, String> { let mut values = ethabi::decode( &[ ethabi::ParamType::Array( Box::new(ethabi::ParamType::Uint(256usize)), ), ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok( values .pop() .expect("one output data should have existed") .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) .collect(), ) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetNormalizedWeights { const NAME: &'static str = "getNormalizedWeights"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable> for GetNormalizedWeights { fn output(data: &[u8]) -> Result, String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetRate {} impl GetRate { const METHOD_ID: [u8; 4] = [103u8, 154u8, 239u8, 206u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetRate { const NAME: &'static str = "getRate"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for GetRate { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetStaticSwapFeePercentage {} impl GetStaticSwapFeePercentage { const METHOD_ID: [u8; 4] = [211u8, 53u8, 176u8, 207u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetStaticSwapFeePercentage { const NAME: &'static str = "getStaticSwapFeePercentage"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for GetStaticSwapFeePercentage { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetTokenInfo {} impl GetTokenInfo { const METHOD_ID: [u8; 4] = [171u8, 177u8, 220u8, 68u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(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, Vec, bool)>, Vec, Vec, ), String, > { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result< ( Vec>, Vec<(substreams::scalar::BigInt, Vec, bool)>, Vec, Vec, ), String, > { let mut values = ethabi::decode( &[ ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), ethabi::ParamType::Array( Box::new( ethabi::ParamType::Tuple( vec![ ethabi::ParamType::Uint(8usize), ethabi::ParamType::Address, ethabi::ParamType::Bool ], ), ), ), ethabi::ParamType::Array( Box::new(ethabi::ParamType::Uint(256usize)), ), ethabi::ParamType::Array( Box::new(ethabi::ParamType::Uint(256usize)), ), ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); Ok(( values .pop() .expect(INTERNAL_ERR) .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { 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 tuple_elements = inner.into_tuple().expect(INTERNAL_ERR); ( { let mut v = [0 as u8; 32]; tuple_elements[0usize] .clone() .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, tuple_elements[1usize] .clone() .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), tuple_elements[2usize] .clone() .into_bool() .expect(INTERNAL_ERR), ) }) .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(), 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<(substreams::scalar::BigInt, Vec, bool)>, 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 GetTokenInfo { const NAME: &'static str = "getTokenInfo"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } 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, Vec, bool)>, Vec, Vec, ), > for GetTokenInfo { fn output( data: &[u8], ) -> Result< ( Vec>, Vec<(substreams::scalar::BigInt, Vec, bool)>, Vec, Vec, ), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetTokens {} impl GetTokens { const METHOD_ID: [u8; 4] = [170u8, 108u8, 168u8, 8u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::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 GetTokens { const NAME: &'static str = "getTokens"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable>> for GetTokens { fn output(data: &[u8]) -> Result>, String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetVault {} impl GetVault { const METHOD_ID: [u8; 4] = [141u8, 146u8, 138u8, 248u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result, String> { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result, String> { let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok( values .pop() .expect("one output data should have existed") .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), ) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetVault { const NAME: &'static str = "getVault"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable> for GetVault { fn output(data: &[u8]) -> Result, String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetWeightedPoolDynamicData {} impl GetWeightedPoolDynamicData { const METHOD_ID: [u8; 4] = [192u8, 188u8, 111u8, 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< ( Vec, Vec, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, bool, bool, ), String, > { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result< ( Vec, Vec, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, bool, bool, ), String, > { let mut values = ethabi::decode( &[ ethabi::ParamType::Tuple( vec![ 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), ethabi::ParamType::Bool, ethabi::ParamType::Bool, ethabi::ParamType::Bool ], ), ], 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_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) .collect(), tuple_elements[1usize] .clone() .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) .collect(), { let mut v = [0 as u8; 32]; tuple_elements[2usize] .clone() .into_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_bool().expect(INTERNAL_ERR), tuple_elements[5usize].clone().into_bool().expect(INTERNAL_ERR), tuple_elements[6usize].clone().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< ( Vec, Vec, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, bool, 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 GetWeightedPoolDynamicData { const NAME: &'static str = "getWeightedPoolDynamicData"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } 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, bool, bool, bool, ), > for GetWeightedPoolDynamicData { fn output( data: &[u8], ) -> Result< ( Vec, Vec, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, bool, bool, ), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetWeightedPoolImmutableData {} impl GetWeightedPoolImmutableData { const METHOD_ID: [u8; 4] = [83u8, 183u8, 155u8, 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< ( Vec>, Vec, Vec, ), String, > { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result< ( Vec>, Vec, Vec, ), String, > { let mut values = ethabi::decode( &[ ethabi::ParamType::Tuple( vec![ ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))), ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))) ], ), ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let tuple_elements = values .pop() .expect("one output data should have existed") .into_tuple() .expect(INTERNAL_ERR); ( tuple_elements[0usize] .clone() .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { inner.into_address().expect(INTERNAL_ERR).as_bytes().to_vec() }) .collect(), tuple_elements[1usize] .clone() .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) .collect(), tuple_elements[2usize] .clone() .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 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, 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 GetWeightedPoolImmutableData { const NAME: &'static str = "getWeightedPoolImmutableData"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } 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, Vec), > for GetWeightedPoolImmutableData { fn output( data: &[u8], ) -> Result< ( Vec>, Vec, Vec, ), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct IncrementNonce {} impl IncrementNonce { const METHOD_ID: [u8; 4] = [98u8, 124u8, 220u8, 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 match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } } impl substreams_ethereum::Function for IncrementNonce { const NAME: &'static str = "incrementNonce"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } #[derive(Debug, Clone, PartialEq)] pub struct Name {} impl Name { const METHOD_ID: [u8; 4] = [6u8, 253u8, 222u8, 3u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok( values .pop() .expect("one output data should have existed") .into_string() .expect(INTERNAL_ERR), ) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Name { const NAME: &'static str = "name"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for Name { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Nonces { pub owner: Vec, } impl Nonces { const METHOD_ID: [u8; 4] = [126u8, 206u8, 190u8, 0u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::Address], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { owner: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ethabi::Token::Address(ethabi::Address::from_slice(&self.owner))], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Nonces { const NAME: &'static str = "nonces"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for Nonces { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct OnSwap { pub request: ( substreams::scalar::BigInt, substreams::scalar::BigInt, Vec, substreams::scalar::BigInt, substreams::scalar::BigInt, Vec, Vec, ), } impl OnSwap { const METHOD_ID: [u8; 4] = [114u8, 201u8, 129u8, 134u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::Tuple( vec![ ethabi::ParamType::Uint(8usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Address, ethabi::ParamType::Bytes ], ), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { request: { let tuple_elements = values .pop() .expect(INTERNAL_ERR) .into_tuple() .expect(INTERNAL_ERR); ( { let mut v = [0 as u8; 32]; tuple_elements[0usize] .clone() .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; tuple_elements[1usize] .clone() .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, tuple_elements[2usize] .clone() .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) .collect(), { let mut v = [0 as u8; 32]; tuple_elements[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) }, tuple_elements[5usize] .clone() .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), tuple_elements[6usize].clone().into_bytes().expect(INTERNAL_ERR), ) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Tuple( vec![ ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self .request.0.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") }, } .as_slice(),),), ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self .request.1.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") }, } .as_slice(),),), { let v = self.request.2.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 .request.3.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") }, } .as_slice(),),), ethabi::Token::Uint(ethabi::Uint::from_big_endian(match self .request.4.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") }, } .as_slice(),),), ethabi::Token::Address(ethabi::Address::from_slice(& self .request.5)), ethabi::Token::Bytes(self.request.6.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 OnSwap { const NAME: &'static str = "onSwap"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for OnSwap { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Permit { pub owner: Vec, pub spender: Vec, pub amount: substreams::scalar::BigInt, pub deadline: substreams::scalar::BigInt, pub v: substreams::scalar::BigInt, pub r: [u8; 32usize], pub s: [u8; 32usize], } impl Permit { const METHOD_ID: [u8; 4] = [213u8, 5u8, 172u8, 207u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::Address, ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(8usize), ethabi::ParamType::FixedBytes(32usize), ethabi::ParamType::FixedBytes(32usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { owner: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), spender: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), 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) }, deadline: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, v: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, r: { let mut result = [0u8; 32]; let v = values .pop() .expect(INTERNAL_ERR) .into_fixed_bytes() .expect(INTERNAL_ERR); result.copy_from_slice(&v); result }, s: { let mut result = [0u8; 32]; let v = values .pop() .expect(INTERNAL_ERR) .into_fixed_bytes() .expect(INTERNAL_ERR); result.copy_from_slice(&v); result }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), ethabi::Token::Address(ethabi::Address::from_slice(&self.spender)), ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.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.deadline.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.v.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ethabi::Token::FixedBytes(self.r.as_ref().to_vec()), ethabi::Token::FixedBytes(self.s.as_ref().to_vec()), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } } impl substreams_ethereum::Function for Permit { const NAME: &'static str = "permit"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } #[derive(Debug, Clone, PartialEq)] pub struct PermitTypehash {} impl PermitTypehash { const METHOD_ID: [u8; 4] = [48u8, 173u8, 248u8, 31u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(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 PermitTypehash { const NAME: &'static str = "PERMIT_TYPEHASH"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } 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 PermitTypehash { fn output(data: &[u8]) -> Result<[u8; 32usize], String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct SupportsInterface { pub interface_id: [u8; 4usize], } impl SupportsInterface { const METHOD_ID: [u8; 4] = [1u8, 255u8, 201u8, 167u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::FixedBytes(4usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { interface_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 }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ethabi::Token::FixedBytes(self.interface_id.as_ref().to_vec())], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { 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 SupportsInterface { const NAME: &'static str = "supportsInterface"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for SupportsInterface { 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 } } } } 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 to: 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 { to: 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.to)), 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 from: Vec, pub to: 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 { from: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), to: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), 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.from)), ethabi::Token::Address(ethabi::Address::from_slice(&self.to)), 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 Version {} impl Version { const METHOD_ID: [u8; 4] = [84u8, 253u8, 77u8, 80u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode(&[ethabi::ParamType::String], data.as_ref()) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok( values .pop() .expect("one output data should have existed") .into_string() .expect(INTERNAL_ERR), ) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr : address, data : self.encode(), }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses.get(0).expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Version { const NAME: &'static str = "version"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for Version { fn output(data: &[u8]) -> Result { Self::output(data) } } } /// Contract's events. #[allow(dead_code, unused_imports, unused_variables)] pub mod events { use super::INTERNAL_ERR; #[derive(Debug, Clone, PartialEq)] pub struct 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 Eip712DomainChanged {} impl Eip712DomainChanged { const TOPIC_ID: [u8; 32] = [ 10u8, 99u8, 135u8, 201u8, 234u8, 54u8, 40u8, 184u8, 138u8, 99u8, 59u8, 180u8, 243u8, 177u8, 81u8, 119u8, 15u8, 112u8, 8u8, 81u8, 23u8, 161u8, 95u8, 155u8, 243u8, 120u8, 124u8, 218u8, 83u8, 241u8, 61u8, 49u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 1usize { return false; } if log.data.len() != 0usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { Ok(Self {}) } } impl substreams_ethereum::Event for Eip712DomainChanged { const NAME: &'static str = "EIP712DomainChanged"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] pub struct Transfer { pub from: Vec, pub to: Vec, pub value: substreams::scalar::BigInt, } impl Transfer { const TOPIC_ID: [u8; 32] = [ 221u8, 242u8, 82u8, 173u8, 27u8, 226u8, 200u8, 155u8, 105u8, 194u8, 176u8, 104u8, 252u8, 55u8, 141u8, 170u8, 149u8, 43u8, 167u8, 241u8, 99u8, 196u8, 161u8, 22u8, 40u8, 245u8, 90u8, 77u8, 245u8, 35u8, 179u8, 239u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 3usize { return false; } if log.data.len() != 32usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { from: ethabi::decode( &[ethabi::ParamType::Address], log.topics[1usize].as_ref(), ) .map_err(|e| { format!( "unable to decode param 'from' from topic of type 'address': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), to: ethabi::decode( &[ethabi::ParamType::Address], log.topics[2usize].as_ref(), ) .map_err(|e| { format!( "unable to decode param 'to' from topic of type 'address': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), value: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } } impl substreams_ethereum::Event for Transfer { const NAME: &'static str = "Transfer"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { Self::decode(log) } } }