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 Burn { pub tick_lower: substreams::scalar::BigInt, pub tick_upper: substreams::scalar::BigInt, pub amount: substreams::scalar::BigInt, } impl Burn { const METHOD_ID: [u8; 4] = [163u8, 65u8, 35u8, 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::Int(24usize), ethabi::ParamType::Int(24usize), ethabi::ParamType::Uint(128usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { tick_lower: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, tick_upper: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, amount: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ { let non_full_signed_bytes = self .tick_lower .to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, { let non_full_signed_bytes = self .tick_upper .to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.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< (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 Burn { const NAME: &'static str = "burn"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable< (substreams::scalar::BigInt, substreams::scalar::BigInt), > for Burn { fn output( data: &[u8], ) -> Result< (substreams::scalar::BigInt, substreams::scalar::BigInt), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Collect { pub recipient: Vec, pub tick_lower: substreams::scalar::BigInt, pub tick_upper: substreams::scalar::BigInt, pub amount0_requested: substreams::scalar::BigInt, pub amount1_requested: substreams::scalar::BigInt, } impl Collect { const METHOD_ID: [u8; 4] = [79u8, 30u8, 179u8, 216u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::Address, ethabi::ParamType::Int(24usize), ethabi::ParamType::Int(24usize), ethabi::ParamType::Uint(128usize), ethabi::ParamType::Uint(128usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { recipient: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), tick_lower: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, tick_upper: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, amount0_requested: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, amount1_requested: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Address( ethabi::Address::from_slice(&self.recipient), ), { let non_full_signed_bytes = self .tick_lower .to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, { let non_full_signed_bytes = self .tick_upper .to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.amount0_requested.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.amount1_requested.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); 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(128usize), ethabi::ParamType::Uint(128usize), ], 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 Collect { const NAME: &'static str = "collect"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } 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 Collect { fn output( data: &[u8], ) -> Result< (substreams::scalar::BigInt, substreams::scalar::BigInt), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct CollectProtocol { pub recipient: Vec, pub amount0_requested: substreams::scalar::BigInt, pub amount1_requested: substreams::scalar::BigInt, } impl CollectProtocol { const METHOD_ID: [u8; 4] = [133u8, 182u8, 103u8, 41u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::Address, ethabi::ParamType::Uint(128usize), ethabi::ParamType::Uint(128usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { recipient: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), amount0_requested: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, amount1_requested: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Address( ethabi::Address::from_slice(&self.recipient), ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.amount0_requested.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.amount1_requested.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); 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(128usize), ethabi::ParamType::Uint(128usize), ], 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 CollectProtocol { const NAME: &'static str = "collectProtocol"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } 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 CollectProtocol { fn output( data: &[u8], ) -> Result< (substreams::scalar::BigInt, substreams::scalar::BigInt), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Factory {} impl Factory { const METHOD_ID: [u8; 4] = [196u8, 90u8, 1u8, 85u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result, String> { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result, String> { let mut values = ethabi::decode( &[ethabi::ParamType::Address], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok( values .pop() .expect("one output data should have existed") .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), ) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Factory { const NAME: &'static str = "factory"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable> for Factory { fn output(data: &[u8]) -> Result, String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Fee {} impl Fee { const METHOD_ID: [u8; 4] = [221u8, 202u8, 63u8, 67u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(24usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Fee { const NAME: &'static str = "fee"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for Fee { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct FeeGrowthGlobal0X128 {} impl FeeGrowthGlobal0X128 { const METHOD_ID: [u8; 4] = [243u8, 5u8, 131u8, 153u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for FeeGrowthGlobal0X128 { const NAME: &'static str = "feeGrowthGlobal0X128"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for FeeGrowthGlobal0X128 { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct FeeGrowthGlobal1X128 {} impl FeeGrowthGlobal1X128 { const METHOD_ID: [u8; 4] = [70u8, 20u8, 19u8, 25u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for FeeGrowthGlobal1X128 { const NAME: &'static str = "feeGrowthGlobal1X128"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for FeeGrowthGlobal1X128 { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Flash { pub recipient: Vec, pub amount0: substreams::scalar::BigInt, pub amount1: substreams::scalar::BigInt, pub data: Vec, } impl Flash { const METHOD_ID: [u8; 4] = [73u8, 14u8, 108u8, 188u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Bytes, ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { recipient: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), amount0: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, amount1: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, data: values .pop() .expect(INTERNAL_ERR) .into_bytes() .expect(INTERNAL_ERR), }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Address( ethabi::Address::from_slice(&self.recipient), ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.amount0.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.amount1.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ethabi::Token::Bytes(self.data.clone()), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } } impl substreams_ethereum::Function for Flash { const NAME: &'static str = "flash"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } #[derive(Debug, Clone, PartialEq)] pub struct IncreaseObservationCardinalityNext { pub observation_cardinality_next: substreams::scalar::BigInt, } impl IncreaseObservationCardinalityNext { const METHOD_ID: [u8; 4] = [50u8, 20u8, 143u8, 103u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::Uint(16usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { observation_cardinality_next: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self .observation_cardinality_next .clone() .to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are 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 IncreaseObservationCardinalityNext { const NAME: &'static str = "increaseObservationCardinalityNext"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } #[derive(Debug, Clone, PartialEq)] pub struct Initialize { pub sqrt_price_x96: substreams::scalar::BigInt, } impl Initialize { const METHOD_ID: [u8; 4] = [246u8, 55u8, 115u8, 29u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::Uint(160usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { sqrt_price_x96: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.sqrt_price_x96.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are 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 Initialize { const NAME: &'static str = "initialize"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } #[derive(Debug, Clone, PartialEq)] pub struct Liquidity {} impl Liquidity { const METHOD_ID: [u8; 4] = [26u8, 104u8, 101u8, 2u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(128usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Liquidity { const NAME: &'static str = "liquidity"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for Liquidity { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct MaxLiquidityPerTick {} impl MaxLiquidityPerTick { const METHOD_ID: [u8; 4] = [112u8, 207u8, 117u8, 74u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(128usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for MaxLiquidityPerTick { const NAME: &'static str = "maxLiquidityPerTick"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for MaxLiquidityPerTick { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Mint { pub recipient: Vec, pub tick_lower: substreams::scalar::BigInt, pub tick_upper: substreams::scalar::BigInt, pub amount: substreams::scalar::BigInt, pub data: Vec, } impl Mint { const METHOD_ID: [u8; 4] = [60u8, 138u8, 125u8, 141u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::Address, ethabi::ParamType::Int(24usize), ethabi::ParamType::Int(24usize), ethabi::ParamType::Uint(128usize), ethabi::ParamType::Bytes, ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { recipient: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), tick_lower: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, tick_upper: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, 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) }, data: values .pop() .expect(INTERNAL_ERR) .into_bytes() .expect(INTERNAL_ERR), }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Address( ethabi::Address::from_slice(&self.recipient), ), { let non_full_signed_bytes = self .tick_lower .to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, { let non_full_signed_bytes = self .tick_upper .to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.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::Bytes(self.data.clone()), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result< (substreams::scalar::BigInt, 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 Mint { const NAME: &'static str = "mint"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable< (substreams::scalar::BigInt, substreams::scalar::BigInt), > for Mint { fn output( data: &[u8], ) -> Result< (substreams::scalar::BigInt, substreams::scalar::BigInt), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Observations { pub index: substreams::scalar::BigInt, } impl Observations { const METHOD_ID: [u8; 4] = [37u8, 44u8, 9u8, 215u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { index: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.index.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), String, > { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), String, > { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(32usize), ethabi::ParamType::Int(56usize), ethabi::ParamType::Uint(160usize), ethabi::ParamType::Bool, ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); Ok(( { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_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_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, values.pop().expect(INTERNAL_ERR).into_bool().expect(INTERNAL_ERR), )) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call( &self, address: Vec, ) -> Option< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, 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 Observations { const NAME: &'static str = "observations"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), > for Observations { fn output( data: &[u8], ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Observe { pub seconds_agos: Vec, } impl Observe { const METHOD_ID: [u8; 4] = [136u8, 59u8, 219u8, 253u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::Array( Box::new(ethabi::ParamType::Uint(32usize)), ), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { seconds_agos: 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 encode(&self) -> Vec { let data = ethabi::encode( &[ { let v = self .seconds_agos .iter() .map(|inner| ethabi::Token::Uint( ethabi::Uint::from_big_endian( match inner.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), )) .collect(); ethabi::Token::Array(v) }, ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result< (Vec, Vec), String, > { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result< (Vec, Vec), String, > { let mut values = ethabi::decode( &[ ethabi::ParamType::Array( Box::new(ethabi::ParamType::Int(56usize)), ), ethabi::ParamType::Array( Box::new(ethabi::ParamType::Uint(160usize)), ), ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); Ok(( values .pop() .expect(INTERNAL_ERR) .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }) .collect(), values .pop() .expect(INTERNAL_ERR) .into_array() .expect(INTERNAL_ERR) .into_iter() .map(|inner| { let mut v = [0 as u8; 32]; inner .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) .collect(), )) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call( &self, address: Vec, ) -> Option< (Vec, Vec), > { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Observe { const NAME: &'static str = "observe"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable< (Vec, Vec), > for Observe { fn output( data: &[u8], ) -> Result< (Vec, Vec), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Positions { pub key: [u8; 32usize], } impl Positions { const METHOD_ID: [u8; 4] = [81u8, 78u8, 164u8, 191u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::FixedBytes(32usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { key: { let mut result = [0u8; 32]; let v = values .pop() .expect(INTERNAL_ERR) .into_fixed_bytes() .expect(INTERNAL_ERR); result.copy_from_slice(&v); result }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ethabi::Token::FixedBytes(self.key.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< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, ), String, > { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, ), String, > { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(128usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(128usize), ethabi::ParamType::Uint(128usize), ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); Ok(( { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, )) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call( &self, address: Vec, ) -> Option< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, ), > { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Positions { const NAME: &'static str = "positions"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, ), > for Positions { fn output( data: &[u8], ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, ), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct ProtocolFees {} impl ProtocolFees { const METHOD_ID: [u8; 4] = [26u8, 216u8, 176u8, 59u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result< (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(128usize), ethabi::ParamType::Uint(128usize), ], 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 ProtocolFees { const NAME: &'static str = "protocolFees"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } 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 ProtocolFees { fn output( data: &[u8], ) -> Result< (substreams::scalar::BigInt, substreams::scalar::BigInt), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct SetFeeProtocol { pub fee_protocol0: substreams::scalar::BigInt, pub fee_protocol1: substreams::scalar::BigInt, } impl SetFeeProtocol { const METHOD_ID: [u8; 4] = [130u8, 6u8, 164u8, 209u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(8usize), ethabi::ParamType::Uint(8usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { fee_protocol0: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, fee_protocol1: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.fee_protocol0.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.fee_protocol1.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are 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 SetFeeProtocol { const NAME: &'static str = "setFeeProtocol"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } #[derive(Debug, Clone, PartialEq)] pub struct Slot0 {} impl Slot0 { const METHOD_ID: [u8; 4] = [56u8, 80u8, 199u8, 189u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), String, > { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), String, > { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(160usize), ethabi::ParamType::Int(24usize), ethabi::ParamType::Uint(16usize), ethabi::ParamType::Uint(16usize), ethabi::ParamType::Uint(16usize), ethabi::ParamType::Uint(8usize), ethabi::ParamType::Bool, ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); Ok(( { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_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_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, values.pop().expect(INTERNAL_ERR).into_bool().expect(INTERNAL_ERR), )) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call( &self, address: Vec, ) -> Option< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), > { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Slot0 { const NAME: &'static str = "slot0"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), > for Slot0 { fn output( data: &[u8], ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct SnapshotCumulativesInside { pub tick_lower: substreams::scalar::BigInt, pub tick_upper: substreams::scalar::BigInt, } impl SnapshotCumulativesInside { const METHOD_ID: [u8; 4] = [163u8, 136u8, 7u8, 242u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::Int(24usize), ethabi::ParamType::Int(24usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { tick_lower: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, tick_upper: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ { let non_full_signed_bytes = self .tick_lower .to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, { let non_full_signed_bytes = self .tick_upper .to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, ), String, > { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, ), String, > { let mut values = ethabi::decode( &[ ethabi::ParamType::Int(56usize), ethabi::ParamType::Uint(160usize), ethabi::ParamType::Uint(32usize), ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); Ok(( { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, )) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call( &self, address: Vec, ) -> Option< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, ), > { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for SnapshotCumulativesInside { const NAME: &'static str = "snapshotCumulativesInside"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, ), > for SnapshotCumulativesInside { fn output( data: &[u8], ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, ), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Swap { pub recipient: Vec, pub zero_for_one: bool, pub amount_specified: substreams::scalar::BigInt, pub sqrt_price_limit_x96: substreams::scalar::BigInt, pub data: Vec, } impl Swap { const METHOD_ID: [u8; 4] = [18u8, 138u8, 203u8, 8u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ ethabi::ParamType::Address, ethabi::ParamType::Bool, ethabi::ParamType::Int(256usize), ethabi::ParamType::Uint(160usize), ethabi::ParamType::Bytes, ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { recipient: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), zero_for_one: values .pop() .expect(INTERNAL_ERR) .into_bool() .expect(INTERNAL_ERR), amount_specified: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, sqrt_price_limit_x96: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, data: values .pop() .expect(INTERNAL_ERR) .into_bytes() .expect(INTERNAL_ERR), }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Address( ethabi::Address::from_slice(&self.recipient), ), ethabi::Token::Bool(self.zero_for_one.clone()), { let non_full_signed_bytes = self .amount_specified .to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, ethabi::Token::Uint( ethabi::Uint::from_big_endian( match self.sqrt_price_limit_x96.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { panic!("negative numbers are not supported") } } .as_slice(), ), ), ethabi::Token::Bytes(self.data.clone()), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result< (substreams::scalar::BigInt, 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::Int(256usize), ethabi::ParamType::Int(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_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, )) } pub fn match_call(call: &substreams_ethereum::pb::eth::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 Swap { const NAME: &'static str = "swap"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable< (substreams::scalar::BigInt, substreams::scalar::BigInt), > for Swap { fn output( data: &[u8], ) -> Result< (substreams::scalar::BigInt, substreams::scalar::BigInt), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct TickBitmap { pub word_position: substreams::scalar::BigInt, } impl TickBitmap { const METHOD_ID: [u8; 4] = [83u8, 57u8, 194u8, 150u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::Int(16usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { word_position: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ { let non_full_signed_bytes = self .word_position .to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for TickBitmap { const NAME: &'static str = "tickBitmap"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for TickBitmap { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct TickSpacing {} impl TickSpacing { const METHOD_ID: [u8; 4] = [208u8, 201u8, 58u8, 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 { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( &[ethabi::ParamType::Int(24usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok({ let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for TickSpacing { const NAME: &'static str = "tickSpacing"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable for TickSpacing { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Ticks { pub tick: substreams::scalar::BigInt, } impl Ticks { const METHOD_ID: [u8; 4] = [243u8, 13u8, 186u8, 147u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { let maybe_data = call.input.get(4..); if maybe_data.is_none() { return Err("no data to decode".to_string()); } let mut values = ethabi::decode( &[ethabi::ParamType::Int(24usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { tick: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ { let non_full_signed_bytes = self.tick.to_signed_bytes_be(); let full_signed_bytes_init = if non_full_signed_bytes[0] & 0x80 == 0x80 { 0xff } else { 0x00 }; let mut full_signed_bytes = [full_signed_bytes_init as u8; 32]; non_full_signed_bytes .into_iter() .rev() .enumerate() .for_each(|(i, byte)| full_signed_bytes[31 - i] = byte); ethabi::Token::Int( ethabi::Int::from_big_endian(full_signed_bytes.as_ref()), ) }, ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), String, > { Self::output(call.return_data.as_ref()) } pub fn output( data: &[u8], ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), String, > { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(128usize), ethabi::ParamType::Int(128usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Int(56usize), ethabi::ParamType::Uint(160usize), ethabi::ParamType::Uint(32usize), ethabi::ParamType::Bool, ], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); Ok(( { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_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_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, values.pop().expect(INTERNAL_ERR).into_bool().expect(INTERNAL_ERR), )) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call( &self, address: Vec, ) -> Option< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), > { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Ticks { const NAME: &'static str = "ticks"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), > for Ticks { fn output( data: &[u8], ) -> Result< ( substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, substreams::scalar::BigInt, bool, ), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Token0 {} impl Token0 { const METHOD_ID: [u8; 4] = [13u8, 254u8, 22u8, 129u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result, String> { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result, String> { let mut values = ethabi::decode( &[ethabi::ParamType::Address], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok( values .pop() .expect("one output data should have existed") .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), ) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Token0 { const NAME: &'static str = "token0"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable> for Token0 { fn output(data: &[u8]) -> Result, String> { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] pub struct Token1 {} impl Token1 { const METHOD_ID: [u8; 4] = [210u8, 18u8, 32u8, 167u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Ok(Self {}) } pub fn encode(&self) -> Vec { let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result, String> { Self::output(call.return_data.as_ref()) } pub fn output(data: &[u8]) -> Result, String> { let mut values = ethabi::decode( &[ethabi::ParamType::Address], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; Ok( values .pop() .expect("one output data should have existed") .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), ) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } pub fn call(&self, address: Vec) -> Option> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ rpc::RpcCall { to_addr : address, data : self.encode(), } ], }; let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; let response = responses .get(0) .expect("one response should have existed"); if response.failed { return None; } match Self::output(response.raw.as_ref()) { Ok(data) => Some(data), Err(err) => { use substreams_ethereum::Function; substreams::log::info!( "Call output for function `{}` failed to decode with error: {}", Self::NAME, err ); None } } } } impl substreams_ethereum::Function for Token1 { const NAME: &'static str = "token1"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { Self::decode(call) } fn encode(&self) -> Vec { self.encode() } } impl substreams_ethereum::rpc::RPCDecodable> for Token1 { fn output(data: &[u8]) -> Result, String> { Self::output(data) } } } /// Contract's events. #[allow(dead_code, unused_imports, unused_variables)] pub mod events { use super::INTERNAL_ERR; #[derive(Debug, Clone, PartialEq)] pub struct Burn { pub owner: Vec, pub tick_lower: substreams::scalar::BigInt, pub tick_upper: substreams::scalar::BigInt, pub amount: substreams::scalar::BigInt, pub amount0: substreams::scalar::BigInt, pub amount1: substreams::scalar::BigInt, } impl Burn { const TOPIC_ID: [u8; 32] = [ 12u8, 57u8, 108u8, 217u8, 137u8, 163u8, 159u8, 68u8, 89u8, 181u8, 250u8, 26u8, 237u8, 106u8, 154u8, 141u8, 205u8, 188u8, 69u8, 144u8, 138u8, 207u8, 214u8, 126u8, 2u8, 140u8, 213u8, 104u8, 218u8, 152u8, 152u8, 44u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 4usize { return false; } if log.data.len() != 96usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(128usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { 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(), tick_lower: substreams::scalar::BigInt::from_signed_bytes_be( log.topics[2usize].as_ref(), ), tick_upper: substreams::scalar::BigInt::from_signed_bytes_be( log.topics[3usize].as_ref(), ), 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) }, amount0: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, amount1: { let mut v = [0 as u8; 32]; values .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 Burn { const NAME: &'static str = "Burn"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] pub struct Collect { pub owner: Vec, pub recipient: Vec, pub tick_lower: substreams::scalar::BigInt, pub tick_upper: substreams::scalar::BigInt, pub amount0: substreams::scalar::BigInt, pub amount1: substreams::scalar::BigInt, } impl Collect { const TOPIC_ID: [u8; 32] = [ 112u8, 147u8, 83u8, 56u8, 230u8, 151u8, 117u8, 69u8, 106u8, 133u8, 221u8, 239u8, 34u8, 108u8, 57u8, 95u8, 182u8, 104u8, 182u8, 63u8, 160u8, 17u8, 95u8, 95u8, 32u8, 97u8, 11u8, 56u8, 142u8, 108u8, 169u8, 192u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 4usize { return false; } if log.data.len() != 96usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( &[ ethabi::ParamType::Address, ethabi::ParamType::Uint(128usize), ethabi::ParamType::Uint(128usize), ], 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(), tick_lower: substreams::scalar::BigInt::from_signed_bytes_be( log.topics[2usize].as_ref(), ), tick_upper: substreams::scalar::BigInt::from_signed_bytes_be( log.topics[3usize].as_ref(), ), recipient: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), amount0: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, amount1: { let mut v = [0 as u8; 32]; values .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 Collect { const NAME: &'static str = "Collect"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] pub struct CollectProtocol { pub sender: Vec, pub recipient: Vec, pub amount0: substreams::scalar::BigInt, pub amount1: substreams::scalar::BigInt, } impl CollectProtocol { const TOPIC_ID: [u8; 32] = [ 89u8, 107u8, 87u8, 57u8, 6u8, 33u8, 141u8, 52u8, 17u8, 133u8, 11u8, 38u8, 166u8, 180u8, 55u8, 214u8, 196u8, 82u8, 47u8, 219u8, 67u8, 210u8, 210u8, 56u8, 98u8, 99u8, 248u8, 109u8, 80u8, 184u8, 177u8, 81u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 3usize { return false; } if log.data.len() != 64usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(128usize), ethabi::ParamType::Uint(128usize), ], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { sender: ethabi::decode( &[ethabi::ParamType::Address], log.topics[1usize].as_ref(), ) .map_err(|e| { format!( "unable to decode param 'sender' from topic of type 'address': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), recipient: ethabi::decode( &[ethabi::ParamType::Address], log.topics[2usize].as_ref(), ) .map_err(|e| { format!( "unable to decode param 'recipient' from topic of type 'address': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), amount0: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, amount1: { let mut v = [0 as u8; 32]; values .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 CollectProtocol { const NAME: &'static str = "CollectProtocol"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] pub struct Flash { pub sender: Vec, pub recipient: Vec, pub amount0: substreams::scalar::BigInt, pub amount1: substreams::scalar::BigInt, pub paid0: substreams::scalar::BigInt, pub paid1: substreams::scalar::BigInt, } impl Flash { const TOPIC_ID: [u8; 32] = [ 189u8, 189u8, 183u8, 29u8, 120u8, 96u8, 55u8, 107u8, 165u8, 43u8, 37u8, 165u8, 2u8, 139u8, 238u8, 162u8, 53u8, 129u8, 54u8, 74u8, 64u8, 82u8, 47u8, 107u8, 207u8, 184u8, 107u8, 177u8, 242u8, 220u8, 166u8, 51u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 3usize { return false; } if log.data.len() != 128usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { sender: ethabi::decode( &[ethabi::ParamType::Address], log.topics[1usize].as_ref(), ) .map_err(|e| { format!( "unable to decode param 'sender' from topic of type 'address': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), recipient: ethabi::decode( &[ethabi::ParamType::Address], log.topics[2usize].as_ref(), ) .map_err(|e| { format!( "unable to decode param 'recipient' from topic of type 'address': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), amount0: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, amount1: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, paid0: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, paid1: { let mut v = [0 as u8; 32]; values .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 Flash { const NAME: &'static str = "Flash"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] pub struct IncreaseObservationCardinalityNext { pub observation_cardinality_next_old: substreams::scalar::BigInt, pub observation_cardinality_next_new: substreams::scalar::BigInt, } impl IncreaseObservationCardinalityNext { const TOPIC_ID: [u8; 32] = [ 172u8, 73u8, 229u8, 24u8, 249u8, 10u8, 53u8, 143u8, 101u8, 46u8, 68u8, 0u8, 22u8, 79u8, 5u8, 165u8, 216u8, 247u8, 227u8, 94u8, 119u8, 71u8, 39u8, 155u8, 195u8, 169u8, 61u8, 191u8, 88u8, 78u8, 18u8, 90u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 1usize { return false; } if log.data.len() != 64usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(16usize), ethabi::ParamType::Uint(16usize), ], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { observation_cardinality_next_old: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, observation_cardinality_next_new: { let mut v = [0 as u8; 32]; values .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 IncreaseObservationCardinalityNext { const NAME: &'static str = "IncreaseObservationCardinalityNext"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] pub struct Initialize { pub sqrt_price_x96: substreams::scalar::BigInt, pub tick: substreams::scalar::BigInt, } impl Initialize { const TOPIC_ID: [u8; 32] = [ 152u8, 99u8, 96u8, 54u8, 203u8, 102u8, 169u8, 193u8, 154u8, 55u8, 67u8, 94u8, 252u8, 30u8, 144u8, 20u8, 33u8, 144u8, 33u8, 78u8, 138u8, 190u8, 184u8, 33u8, 189u8, 186u8, 63u8, 41u8, 144u8, 221u8, 76u8, 149u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 1usize { return false; } if log.data.len() != 64usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(160usize), ethabi::ParamType::Int(24usize), ], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { sqrt_price_x96: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, tick: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, }) } } impl substreams_ethereum::Event for Initialize { const NAME: &'static str = "Initialize"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] pub struct Mint { pub sender: Vec, pub owner: Vec, pub tick_lower: substreams::scalar::BigInt, pub tick_upper: substreams::scalar::BigInt, pub amount: substreams::scalar::BigInt, pub amount0: substreams::scalar::BigInt, pub amount1: substreams::scalar::BigInt, } impl Mint { const TOPIC_ID: [u8; 32] = [ 122u8, 83u8, 8u8, 11u8, 164u8, 20u8, 21u8, 139u8, 231u8, 236u8, 105u8, 185u8, 135u8, 181u8, 251u8, 125u8, 7u8, 222u8, 225u8, 1u8, 254u8, 133u8, 72u8, 143u8, 8u8, 83u8, 174u8, 22u8, 35u8, 157u8, 11u8, 222u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 4usize { return false; } if log.data.len() != 128usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( &[ ethabi::ParamType::Address, ethabi::ParamType::Uint(128usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { 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(), tick_lower: substreams::scalar::BigInt::from_signed_bytes_be( log.topics[2usize].as_ref(), ), tick_upper: substreams::scalar::BigInt::from_signed_bytes_be( log.topics[3usize].as_ref(), ), sender: 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) }, amount0: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, amount1: { let mut v = [0 as u8; 32]; values .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 Mint { const NAME: &'static str = "Mint"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] pub struct SetFeeProtocol { pub fee_protocol0_old: substreams::scalar::BigInt, pub fee_protocol1_old: substreams::scalar::BigInt, pub fee_protocol0_new: substreams::scalar::BigInt, pub fee_protocol1_new: substreams::scalar::BigInt, } impl SetFeeProtocol { const TOPIC_ID: [u8; 32] = [ 151u8, 61u8, 141u8, 146u8, 187u8, 41u8, 159u8, 74u8, 246u8, 206u8, 73u8, 181u8, 42u8, 138u8, 219u8, 133u8, 174u8, 70u8, 185u8, 242u8, 20u8, 196u8, 196u8, 252u8, 6u8, 172u8, 119u8, 64u8, 18u8, 55u8, 177u8, 51u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 1usize { return false; } if log.data.len() != 128usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(8usize), ethabi::ParamType::Uint(8usize), ethabi::ParamType::Uint(8usize), ethabi::ParamType::Uint(8usize), ], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { fee_protocol0_old: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, fee_protocol1_old: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, fee_protocol0_new: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, fee_protocol1_new: { let mut v = [0 as u8; 32]; values .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 SetFeeProtocol { const NAME: &'static str = "SetFeeProtocol"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] pub struct Swap { pub sender: Vec, pub recipient: Vec, pub amount0: substreams::scalar::BigInt, pub amount1: substreams::scalar::BigInt, pub sqrt_price_x96: substreams::scalar::BigInt, pub liquidity: substreams::scalar::BigInt, pub tick: substreams::scalar::BigInt, } impl Swap { const TOPIC_ID: [u8; 32] = [ 196u8, 32u8, 121u8, 249u8, 74u8, 99u8, 80u8, 215u8, 230u8, 35u8, 95u8, 41u8, 23u8, 73u8, 36u8, 249u8, 40u8, 204u8, 42u8, 200u8, 24u8, 235u8, 100u8, 254u8, 216u8, 0u8, 78u8, 17u8, 95u8, 188u8, 202u8, 103u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { if log.topics.len() != 3usize { return false; } if log.data.len() != 160usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() == Self::TOPIC_ID; } pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( &[ ethabi::ParamType::Int(256usize), ethabi::ParamType::Int(256usize), ethabi::ParamType::Uint(160usize), ethabi::ParamType::Uint(128usize), ethabi::ParamType::Int(24usize), ], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { sender: ethabi::decode( &[ethabi::ParamType::Address], log.topics[1usize].as_ref(), ) .map_err(|e| { format!( "unable to decode param 'sender' from topic of type 'address': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), recipient: ethabi::decode( &[ethabi::ParamType::Address], log.topics[2usize].as_ref(), ) .map_err(|e| { format!( "unable to decode param 'recipient' from topic of type 'address': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), amount0: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, amount1: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, sqrt_price_x96: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, liquidity: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, tick: { let mut v = [0 as u8; 32]; values .pop() .expect(INTERNAL_ERR) .into_int() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_signed_bytes_be(&v) }, }) } } impl substreams_ethereum::Event for Swap { const NAME: &'static str = "Swap"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { Self::decode(log) } } }