const INTERNAL_ERR: &'static str = "`ethabi_derive` internal error"; /// Contract's functions. #[allow(dead_code, unused_imports, unused_variables)] pub mod functions { use super::INTERNAL_ERR; #[derive(Debug, Clone, PartialEq)] pub struct Create { pub name: String, pub symbol: String, pub tokens: Vec>, pub weights: Vec, pub swap_fee_percentage: substreams::scalar::BigInt, pub oracle_enabled: bool, pub owner: Vec, } impl Create { const METHOD_ID: [u8; 4] = [21u8, 150u8, 1u8, 155u8]; pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::String, ethabi::ParamType::String, ethabi::ParamType::Array(Box::new(ethabi::ParamType::Address)), ethabi::ParamType::Array(Box::new(ethabi::ParamType::Uint(256usize))), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Bool, ethabi::ParamType::Address, ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { name: values .pop() .expect(INTERNAL_ERR) .into_string() .expect(INTERNAL_ERR), symbol: values .pop() .expect(INTERNAL_ERR) .into_string() .expect(INTERNAL_ERR), tokens: values .pop() .expect(INTERNAL_ERR) .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { inner .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec() }) .collect(), weights: values .pop() .expect(INTERNAL_ERR) .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) .collect(), swap_fee_percentage: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, oracle_enabled: values .pop() .expect(INTERNAL_ERR) .into_bool() .expect(INTERNAL_ERR), owner: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), }) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[ ethabi::Token::String(self.name.clone()), ethabi::Token::String(self.symbol.clone()), { let v = self .tokens .iter() .map(|inner| ethabi::Token::Address(ethabi::Address::from_slice(&inner))) .collect(); ethabi::Token::Array(v) }, { let v = self .weights .iter() .map(|inner| { ethabi::Token::Uint(ethabi::Uint::from_big_endian( match inner.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), )) }) .collect(); ethabi::Token::Array(v) }, ethabi::Token::Uint(ethabi::Uint::from_big_endian( match self .swap_fee_percentage .clone() .to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), )), ethabi::Token::Bool(self.oracle_enabled.clone()), ethabi::Token::Address(ethabi::Address::from_slice(&self.owner)), ]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result, String> { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result, String> { let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok(values .pop() .expect("one output data should have existed") .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec()) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Create { const NAME: &'static str = "create"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable> for Create { fn output(data: &[u8]) -> Result, String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetPauseConfiguration {} impl GetPauseConfiguration { const METHOD_ID: [u8; 4] = [45u8, 164u8, 124u8, 64u8]; pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); Ok(( { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, )) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call( &self, address: Vec, ) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt)> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetPauseConfiguration { const NAME: &'static str = "getPauseConfiguration"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable<( substreams::scalar::BigInt, substreams::scalar::BigInt, )> for GetPauseConfiguration { fn output( data: &[u8], ) -> Result<(substreams::scalar::BigInt, substreams::scalar::BigInt), String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct GetVault {} impl GetVault { const METHOD_ID: [u8; 4] = [141u8, 146u8, 138u8, 248u8]; pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result, String> { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result, String> { let mut values = ethabi::decode(&[ethabi::ParamType::Address], data.as_ref()) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok(values .pop() .expect("one output data should have existed") .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec()) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for GetVault { const NAME: &'static str = "getVault"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable> for GetVault { fn output(data: &[u8]) -> Result, String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct IsPoolFromFactory { pub pool: Vec, } impl IsPoolFromFactory { const METHOD_ID: [u8; 4] = [102u8, 52u8, 183u8, 83u8]; pub fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode(&[ethabi::ParamType::Address], maybe_data.unwrap()) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { pool: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), }) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[ethabi::Token::Address(ethabi::Address::from_slice(&self.pool))]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode(&[ethabi::ParamType::Bool], data.as_ref()) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok(values .pop() .expect("one output data should have existed") .into_bool() .expect(INTERNAL_ERR)) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![rpc::RpcCall { to_addr: address, data: self.encode() }], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for IsPoolFromFactory { const NAME: &'static str = "isPoolFromFactory"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode(call: &substreams_ethereum::pb::eth::v2::Call) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for IsPoolFromFactory { fn output(data: &[u8]) -> Result { Self::output(data) } } } /// Contract's events. #[allow(dead_code, unused_imports, unused_variables)] pub mod events { use super::INTERNAL_ERR; #[derive(Debug, Clone, PartialEq)] pub struct PoolCreated { pub pool: Vec, } impl PoolCreated { const TOPIC_ID: [u8; 32] = [ 131u8, 164u8, 143u8, 188u8, 252u8, 153u8, 19u8, 53u8, 49u8, 78u8, 116u8, 208u8, 73u8, 106u8, 171u8, 106u8, 25u8, 135u8, 233u8, 146u8, 221u8, 200u8, 93u8, 221u8, 188u8, 196u8, 214u8, 221u8, 110u8, 242u8, 233u8, 252u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 2usize { return false; } if log.data.len() != 0usize { return false; } return log .topics .get(0) .expect("bounds already checked") .as_ref() == Self::TOPIC_ID; } pub fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { Ok(Self { pool: ethabi::decode(&[ethabi::ParamType::Address], log.topics[1usize].as_ref()) .map_err(|e| { format!( "unable to decode param 'pool' from topic of type 'address': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), }) } } impl substreams_ethereum::Event for PoolCreated { const NAME: &'static str = "PoolCreated"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode(log: &substreams_ethereum::pb::eth::v2::Log) -> Result { Self::decode(log) } } }